/* ═══════════════════════════════════════════
   VISITORS METAMETRY — Premium Command Center (v5.0.0)
   ═══════════════════════════════════════════ */

:root {
    --bg: #030308;
    --bg-accent: #070715;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --glass: rgba(10, 10, 25, 0.65);
    --glass-border: rgba(255, 255, 255, 0.12);
    --glass-highlight: rgba(167, 139, 250, 0.25);
    
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --text-tertiary: rgba(255, 255, 255, 0.45);

    --accent: #a78bfa;        /* Soft violet */
    --accent-glow: rgba(167, 139, 250, 0.5);
    --accent-2: #7dd3fc;      /* Cosmic blue */
    
    --radius: 28px;
    --radius-sm: 16px;
    
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
    
    --transition: 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    --blur: blur(40px);
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.tab-content.active {
    display: block;
}

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

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    letter-spacing: -0.01em;
}

#particle-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    opacity: 0.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
}

/* ── Navigation ─────────────────────────── */
#main-nav {
    position: fixed;
    top: 24px; 
    left: 50%;
    transform: translateX(-50%);
    width: min(1300px, calc(100% - 80px));
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px 24px;
    background: var(--glass);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: 40px;
    box-shadow: 
        0 20px 50px rgba(0, 0, 0, 0.6),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.nav-primary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.nav-secondary {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-links {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.nav-logo {
    font-size: 0.9rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.nav-logo-text {
    background: linear-gradient(90deg, #fff 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 0 8px rgba(167, 139, 250, 0.4));
}

.accent-text {
    opacity: 0.65;
    font-weight: 400;
    color: var(--text-secondary);
    text-transform: lowercase;
    -webkit-text-fill-color: initial;
    background: none;
}

.site-dropdown {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 8px 12px;
    font-family: var(--font);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    outline: none;
}

/* ── Command Center Layout ───────────────── */
.command-center {
    position: relative;
    padding-top: 220px; /* Adjusted for taller nav */
    min-height: 100vh;
}

.map-viewport {
    position: relative;
    width: 100%;
    height: 75vh;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--glass-border);
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    background: #000;
}

#visitor-map {
    width: 100%;
    height: 100%;
    z-index: 5;
}

/* ── Floating HUD ───────────────────────── */
.hud-container {
    position: absolute;
    top: 24px;
    left: 24px;
    right: 24px;
    pointer-events: none;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-left {
    display: flex;
    gap: 16px;
}

.hud-card {
    pointer-events: auto;
    background: var(--glass);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    padding: 24px 32px;
    border-radius: var(--radius-sm);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    min-width: 180px;
    transition: var(--transition);
}

.hud-card:hover {
    border-color: var(--glass-highlight);
    transform: translateY(-6px);
    background: rgba(25, 25, 60, 0.75);
    box-shadow: 
        0 20px 50px rgba(0,0,0,0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.hud-card h3 {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 8px;
    opacity: 0.8;
}

.hud-card .stat-value {
    font-size: 2.25rem;
    font-weight: 900;
    letter-spacing: -0.03em;
    display: block;
}

.hud-hint {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    margin-top: 8px;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
}

.nav-logo-emoji {
    font-size: 1.2rem;
}

.hud-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ── Map Overlay Info ───────────────────── */
.map-status {
    background: var(--glass);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    min-width: 220px;
    pointer-events: auto;
}

.status-site {
    font-size: 0.8rem;
    font-weight: 900;
    color: var(--accent);
    margin-bottom: 4px;
    text-shadow: 0 0 10px var(--accent-glow);
}

.status-time {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* ── Detailed Activity ───────────────────── */
.activity-section {
    padding-top: 60px;
    padding-bottom: 100px;
}

.glass-panel {
    background: var(--glass);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 40px;
}

.subsection-title {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 32px;
    letter-spacing: -0.02em;
}

table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--accent);
    padding-bottom: 20px;
    border-bottom: 1px solid var(--glass-border);
    text-transform: uppercase;
}
td {
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.site-badge {
    background: rgba(167, 139, 250, 0.12);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    border: 1px solid rgba(167, 139, 250, 0.2);
}

/* ── Animations ──────────────────────────── */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: all 1s var(--transition);
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Data Grid & Cards ──────────────────── */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    padding-bottom: 100px;
}

.card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    box-shadow: 
        0 15px 35px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 1px;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    opacity: 0.15;
}

.card:hover {
    background: var(--surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 
        0 30px 60px rgba(0, 0, 0, 0.7),
        inset 0 0 0 1px rgba(255, 255, 255, 0.15);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-family: var(--font-mono);
}

.card-meta {
    font-size: 0.7rem;
    opacity: 0.5;
}

.empty-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    padding: 8px 0;
}

.tech-stat-name {
    font-size: 0.8rem;
    width: 72px;
    flex-shrink: 0;
}

.tech-stat-count {
    font-size: 0.7rem;
    opacity: 0.5;
    min-width: 2rem;
    text-align: right;
}

.tech-bar-os {
    background: var(--accent-2) !important;
}

.card-engagement .engagement-note {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    line-height: 1.4;
    margin-bottom: 16px;
}

.engagement-metrics {
    display: flex;
    gap: 20px;
}

.engagement-metric {
    flex: 1;
}

.engagement-label {
    font-size: 0.6rem;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}

.engagement-value {
    font-size: 1.5rem;
    font-weight: 800;
}

.engagement-value-accent {
    color: var(--accent);
}

.ratio-label {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    margin-bottom: 4px;
    color: var(--text-secondary);
}

.activity-note {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 20px;
}

.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

#visitors-table {
    min-width: 640px;
}

.td-path {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    opacity: 0.75;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-ref {
    font-size: 0.8rem;
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.td-time {
    font-size: 0.75rem;
    opacity: 0.5;
    white-space: nowrap;
}

.site-footer {
    padding: 40px 0;
    border-top: 1px solid var(--glass-border);
    margin-top: 60px;
}

.footer-build {
    opacity: 0.4;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.footer-tag {
    font-weight: 800;
    font-size: 0.8rem;
    margin-top: 8px;
    color: var(--accent);
}

.text-center { text-align: center; }

/* ── Scrollable Rankings ────────────────── */
.ranking-list {
    max-height: 200px;
    overflow-y: auto;
    padding-right: 8px;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.85rem;
}

.ranking-item:last-child { border: none; }

.rank-val { font-weight: 700; color: var(--accent-2); }

/* Custom Scrollbar */
.ranking-list::-webkit-scrollbar { width: 4px; }
.ranking-list::-webkit-scrollbar-track { background: transparent; }
.ranking-list::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

/* ── Tech Stats (Browsers/OS) ───────────── */
.tech-stat {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tech-bar-container {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
    overflow: hidden;
}

.tech-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 10px;
    transition: width 1s ease-in-out;
}

.ratio-container {
    display: flex;
    height: 40px;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 10px;
}

.ratio-half {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    transition: width 1s ease-in-out;
}

.ratio-apple { background: rgba(255,255,255,0.1); color: #fff; }
.ratio-android { background: var(--accent); color: #000; }

/* ── Nav Enhancements ───────────────────── */
.tab-switcher {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 100px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn.active {
    background: var(--accent);
    color: #000;
}

.refresh-pill {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-right: 12px;
    transition: var(--transition);
}

.refresh-pill:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--accent);
}

.refresh-icon { font-size: 1rem; transition: transform 0.5s ease; }
.refresh-pill:active .refresh-icon { transform: rotate(360deg); }

@media (max-width: 1000px) {
    #main-nav { 
        top: 0; left: 0; right: 0; 
        width: 100%; 
        border-radius: 0 0 24px 24px;
        padding: 12px 16px;
        gap: 8px;
        transform: none;
    }
    .nav-primary { flex-direction: column; align-items: start; gap: 8px; }
    .nav-logo-text { font-size: 0.8rem; }
    .nav-links { width: 100%; justify-content: space-between; }
    .refresh-pill { margin: 0; padding: 6px 12px; }
    .site-dropdown { flex: 1; padding: 6px; font-size: 0.75rem; }
    .nav-secondary { padding-top: 8px; gap: 12px; }
    .tab-switcher { width: 100%; }
    .time-switches { width: 100%; }
    .container { padding: 0 16px; }
    .command-center { padding-top: 240px; }
    
    /* HUD Fix for Mobile: No longer absolute inside map viewport */
    .map-viewport { height: auto; min-height: none; overflow: visible; margin-bottom: 20px; display: flex; flex-direction: column; background: transparent; border: none; box-shadow: none; }
    #visitor-map { height: 80vh; border-radius: var(--radius); border: 1px solid var(--glass-border); box-shadow: 0 20px 50px rgba(0,0,0,0.5); order: 2; }
    .hud-container { 
        position: relative; 
        top: 0; left: 0; right: 0; 
        padding: 0 0 16px 0;
        flex-direction: column; 
        gap: 12px;
        pointer-events: auto;
        order: 1;
    }
    .hud-left { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; width: 100%; }
    .hud-card { width: 100%; padding: 16px; min-width: 0; }
    .hud-card .stat-value { font-size: 1.5rem; }
    .hud-left .hud-card:last-child { grid-column: span 2; }
    
    .hud-right { position: absolute; top: 12px; right: 12px; z-index: 30; }
    .map-status { min-width: 140px; padding: 8px 12px; background: rgba(5, 5, 20, 0.85); border-radius: 12px; }
    .status-site { font-size: 0.7rem; }
    .status-time { font-size: 0.6rem; }
    
    .analytics-grid { grid-template-columns: 1fr; }
    .engagement-metrics { flex-direction: column; }
}

@media (max-width: 520px) {
    .command-center { padding-top: 260px; }
    .map-viewport { min-height: 70vh; }
    .hud-card .stat-value { font-size: 1.25rem; }
    .hud-card h3 { font-size: 0.55rem; }
}

/* ── Time Filter Switches ─────────────────── */
.time-switches {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 100px;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    justify-self: center;
}

.time-switches::-webkit-scrollbar {
    display: none;
}

.time-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.time-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.time-btn.active {
    background: var(--accent);
    color: #000;
}

@media (max-width: 1200px) {
    #main-nav {
        flex-wrap: wrap;
        height: auto;
        padding: 12px 20px;
        gap: 12px;
    }
    .time-switches {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}

