/* ═══════════════════════════════════════════════════════════════════════════
   TrackPro — Admin Dashboard Styles
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --bg-root: #060a14;
    --bg-surface: #0c1223;
    --bg-card: rgba(12, 18, 35, .85);
    --bg-input: rgba(15, 23, 42, .8);
    --border: rgba(99, 102, 241, .1);
    --border-hover: rgba(99, 102, 241, .25);
    --text-primary: #e2e8f0;
    --text-secondary: #8896b3;
    --text-muted: #5b6b8a;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --green: #10b981;
    --red: #ef4444;
    --yellow: #f59e0b;
    --orange: #f97316;
    --purple: #8b5cf6;
    --blue: #3b82f6;
    --sidebar-w: 250px;
    --radius: 10px;
    --font-body: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--bg-root);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    background-image:
        radial-gradient(ellipse at 15% 10%, rgba(99, 102, 241, .06) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 90%, rgba(59, 130, 246, .04) 0%, transparent 50%);
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform .3s ease;
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex; align-items: center; gap: .6rem;
}

.logo-icon {
    width: 34px; height: 34px;
    background: linear-gradient(135deg, var(--accent), var(--blue));
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
}
.logo-icon svg { width: 18px; height: 18px; }

.logo-text {
    font-size: 1.2rem; font-weight: 700; color: #fff; letter-spacing: -.01em;
}
.logo-text em { font-style: normal; color: var(--accent); }

.sidebar-nav {
    flex: 1; padding: 1rem .75rem; overflow-y: auto;
}

.nav-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .7rem 1rem; border-radius: 8px;
    color: var(--text-secondary); text-decoration: none;
    font-size: .9rem; font-weight: 500;
    cursor: pointer; transition: all .15s;
    margin-bottom: .25rem;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; stroke-width: 1.8; }
.nav-item:hover { background: rgba(99, 102, 241, .08); color: var(--text-primary); }
.nav-item.active { background: rgba(99, 102, 241, .12); color: #fff; }
.nav-badge { background: var(--red); color: #fff; font-size: .65rem; padding: .1rem .4rem; border-radius: 10px; margin-left: auto; font-weight: 700; }

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}

.user-badge { display: flex; align-items: center; gap: .6rem; }
.user-avatar {
    width: 32px; height: 32px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), var(--purple));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; color: #fff;
}
.user-name { font-size: .85rem; font-weight: 600; color: var(--text-primary); }
.user-role { font-size: .7rem; color: var(--text-muted); text-transform: capitalize; }

.logout-btn {
    color: var(--text-muted); padding: .4rem; border-radius: 6px; transition: all .15s;
}
.logout-btn:hover { color: var(--red); background: rgba(239, 68, 68, .1); }
.logout-btn svg { width: 18px; height: 18px; }

/* ─── Mobile Header ────────────────────────────────────────────────────────── */
.mobile-header {
    display: none;
    position: fixed; top: 0; left: 0; right: 0;
    height: 56px; background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    align-items: center; gap: .75rem;
    padding: 0 1rem; z-index: 90;
}
.hamburger {
    background: none; border: none; color: var(--text-primary); cursor: pointer;
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
}
.hamburger svg { width: 22px; height: 22px; }

/* ─── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1; padding: 2rem;
    min-height: 100vh;
}

.page { display: none; }
.page.active { display: block; animation: fadeIn .3s ease; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem;
}
.page-header h1 { font-size: 1.6rem; font-weight: 700; color: #fff; }

.header-actions { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

/* ─── Stat Cards ───────────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    backdrop-filter: blur(10px);
}

.stat-icon {
    width: 44px; height: 44px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon.blue { background: rgba(59, 130, 246, .12); color: var(--blue); }
.stat-icon.green { background: rgba(16, 185, 129, .12); color: var(--green); }
.stat-icon.purple { background: rgba(139, 92, 246, .12); color: var(--purple); }
.stat-icon.red { background: rgba(239, 68, 68, .12); color: var(--red); }

.stat-value { font-size: 1.5rem; font-weight: 700; color: #fff; font-family: var(--font-mono); }
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .15rem; }

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    backdrop-filter: blur(10px);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: .95rem; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 1.25rem; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

/* ─── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%; border-collapse: collapse; font-size: .85rem;
}
.data-table th {
    text-align: left; padding: .75rem 1rem;
    font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted);
    background: rgba(15, 23, 42, .5);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: .65rem 1rem;
    border-bottom: 1px solid rgba(99, 102, 241, .05);
    color: var(--text-secondary);
    white-space: nowrap;
}
.data-table tr:hover td { background: rgba(99, 102, 241, .04); }

.table-footer {
    padding: .75rem 1rem;
    display: flex; align-items: center; justify-content: space-between;
    font-size: .8rem; color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ─── Badges ───────────────────────────────────────────────────────────────── */
.badge {
    display: inline-block; padding: .2rem .6rem;
    border-radius: 6px; font-size: .72rem; font-weight: 600;
    font-family: var(--font-mono);
}
.badge-green { background: rgba(16, 185, 129, .12); color: #34d399; }
.badge-red { background: rgba(239, 68, 68, .12); color: #f87171; }
.badge-yellow { background: rgba(245, 158, 11, .12); color: #fbbf24; }
.badge-blue { background: rgba(99, 102, 241, .12); color: #818cf8; }
.badge-gray { background: rgba(100, 116, 139, .12); color: #94a3b8; }

.flag {
    display: inline-block; padding: .15rem .4rem;
    border-radius: 4px; font-size: .65rem; font-weight: 700;
    font-family: var(--font-mono); margin-right: .2rem;
}
.flag-green { background: rgba(16, 185, 129, .1); color: #34d399; }
.flag-yellow { background: rgba(245, 158, 11, .1); color: #fbbf24; }
.flag-red { background: rgba(239, 68, 68, .1); color: #f87171; }
.flag-orange { background: rgba(249, 115, 22, .1); color: #fb923c; }
.flag-purple { background: rgba(139, 92, 246, .1); color: #a78bfa; }
.flag-blue { background: rgba(59, 130, 246, .1); color: #60a5fa; }

.uid-code {
    font-family: var(--font-mono); font-size: .8rem;
    background: rgba(99, 102, 241, .08); padding: .15rem .4rem;
    border-radius: 4px; color: #818cf8;
}
.mono { font-family: var(--font-mono); font-size: .82rem; }

/* ─── Forms ────────────────────────────────────────────────────────────────── */
.field { margin-bottom: 1.1rem; }
.field label {
    display: block; font-size: .72rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-muted); margin-bottom: .4rem;
}

.field input, .field select, .field textarea {
    width: 100%; padding: .7rem .9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary);
    font-size: .9rem; font-family: var(--font-body);
    transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}
.field textarea { resize: vertical; }

.search-input {
    padding: .55rem .9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-primary);
    font-size: .85rem; font-family: var(--font-body);
    min-width: 160px;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.radio-group { display: flex; gap: 1.5rem; }
.radio { display: flex; align-items: center; gap: .4rem; font-size: .9rem; color: var(--text-secondary); cursor: pointer; }

/* ─── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: .4rem;
    padding: .6rem 1.1rem; border-radius: 8px;
    font-size: .85rem; font-weight: 600; font-family: var(--font-body);
    border: none; cursor: pointer; transition: all .15s;
    text-decoration: none;
}
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    color: #fff;
}
.btn-primary:hover { box-shadow: 0 4px 15px rgba(99, 102, 241, .3); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text-primary); }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }

.btn-icon {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: .35rem; border-radius: 6px; transition: all .15s;
}
.btn-icon:hover { color: var(--accent); background: rgba(99, 102, 241, .08); }
.btn-danger:hover { color: var(--red); background: rgba(239, 68, 68, .08); }

.actions { display: flex; gap: .25rem; }

/* ─── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px);
    z-index: 200; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal-overlay.open { display: flex; animation: fadeIn .2s ease; }

.modal {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
}
.modal-lg { max-width: 900px; }

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 1.5rem; }
.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: .75rem;
}

/* ─── Session Detail ───────────────────────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.detail-section h4 {
    font-size: .8rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--accent); margin-bottom: .75rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border);
}

.detail-section dl {
    display: grid; grid-template-columns: auto 1fr; gap: .35rem .75rem;
}
.detail-section dt { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.detail-section dd { font-size: .82rem; color: var(--text-secondary); word-break: break-all; }
.detail-section code {
    font-family: var(--font-mono); font-size: .75rem;
    background: rgba(99, 102, 241, .06); padding: .1rem .3rem; border-radius: 3px;
}

.ua-cell { font-size: .72rem; font-family: var(--font-mono); line-height: 1.4; max-width: 350px; }

/* ─── Country List ─────────────────────────────────────────────────────────── */
.country-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.country-name { font-size: .82rem; color: var(--text-secondary); min-width: 120px; white-space: nowrap; }
.country-bar { flex: 1; height: 6px; background: rgba(99, 102, 241, .08); border-radius: 3px; overflow: hidden; }
.country-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--blue)); border-radius: 3px; transition: width .5s ease; }
.country-count { font-size: .78rem; color: var(--text-muted); font-family: var(--font-mono); min-width: 30px; text-align: right; }

/* ─── Toast ────────────────────────────────────────────────────────────────── */
.toast {
    position: fixed; bottom: 2rem; right: 2rem;
    background: var(--accent); color: #fff;
    padding: .75rem 1.25rem; border-radius: 10px;
    font-size: .9rem; font-weight: 500;
    box-shadow: 0 8px 30px rgba(99, 102, 241, .3);
    animation: toastIn .3s ease;
    z-index: 500;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ─── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.5); }
    .mobile-header { display: flex; }
    .main-content { margin-left: 0; padding: 1rem; padding-top: 72px; }
    .page-header { flex-direction: column; align-items: flex-start; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .modal { max-width: 100%; margin: .5rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .header-actions { width: 100%; }
    .search-input { width: 100%; }
}
