/* ─── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f1117;
    --bg-card: #1a1d27;
    --bg-card-hover: #222636;
    --border: #2a2e3d;
    --text: #e4e6ed;
    --text-muted: #8b8fa3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --up: #22c55e;
    --down: #ef4444;
    --radius: 10px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* ─── Navbar ───────────────────────────────────────────── */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text) !important;
    text-decoration: none !important;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-links a { color: var(--text-muted); font-size: 0.95rem; }
.nav-links a:hover { color: var(--text); text-decoration: none; }

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-sm { padding: 6px 14px; font-size: 0.85rem; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: #363a4d; }

.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ─── Cards ────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body { padding: 20px; }

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 8px;
}

/* ─── Tracker Cards ────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 0 16px;
}

.page-header h1 { font-size: 1.5rem; }

.tracker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
    padding-bottom: 40px;
}

.tracker-card.inactive { opacity: 0.5; }

.tracker-info h3 { font-size: 1.1rem; margin-bottom: 4px; }

.participant { margin-bottom: 6px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    background: var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.badge-sm { font-size: 0.75rem; padding: 1px 6px; }

.interval, .discord-status { font-size: 0.9rem; color: var(--text-muted); margin-top: 4px; }
.muted { opacity: 0.5; }

/* ─── Toggle Switch ────────────────────────────────────── */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    transition: 0.3s;
}

.slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

input:checked + .slider { background: var(--primary); }
input:checked + .slider::before { transform: translateX(20px); }

/* ─── Chart ────────────────────────────────────────────── */
.chart-container { min-height: 200px; text-align: center; }
.chart-img { max-width: 100%; height: auto; border-radius: 8px; }

/* ─── Table ────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th, .data-table td {
    padding: 10px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    text-align: right;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.85rem;
}

.data-table th:first-child, .data-table td:first-child { text-align: left; }

.text-up { color: var(--up); font-weight: 500; }
.text-down { color: var(--down); font-weight: 500; }

/* ─── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.9rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.95rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 0.8rem; }

.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ─── Modal ────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 { font-size: 1.2rem; }

.close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 4px;
}

.modal-content form { padding: 20px; }

/* ─── Toast ────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    z-index: 300;
    transition: all 0.3s;
}

.toast.error { border-color: var(--danger); color: var(--danger); }

/* ─── Utilities ────────────────────────────────────────── */
.hidden { display: none !important; }
.loading { color: var(--text-muted); padding: 40px; }

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h2 { margin-bottom: 8px; color: var(--text); }

.back-link {
    font-size: 0.9rem;
    color: var(--text-muted);
    display: inline-block;
    margin-bottom: 8px;
}

.subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 4px; }

.header-actions { display: flex; gap: 8px; }

.help-section h4 { margin-top: 20px; margin-bottom: 8px; }
.help-section h4:first-child { margin-top: 0; }
.help-section p, .help-section ul, .help-section ol { margin-bottom: 8px; }
.help-section code {
    display: block;
    padding: 10px 14px;
    background: var(--bg);
    border-radius: var(--radius);
    margin: 8px 0;
    font-size: 0.85rem;
    word-break: break-all;
}
.help-section ul, .help-section ol { padding-left: 20px; }

/* ─── Participant Group ────────────────────────────────── */
.participant-group {
    margin-bottom: 32px;
}

.participant-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.participant-group-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Responsive ───────────────────────────────────────── */
@media (max-width: 640px) {
    .tracker-grid { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .header-actions { width: 100%; }
}
