/* ========================================
   AutoArena Dashboard — Premium Dark Theme
   Performance-Optimized Build
   ======================================== */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.85);
    --bg-sidebar: #0d1220;
    --border-subtle: rgba(99, 102, 241, 0.15);
    --border-glow: rgba(99, 102, 241, 0.35);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-blue: #6366f1;
    --accent-blue-glow: rgba(99, 102, 241, 0.25);
    --accent-green: #22c55e;
    --accent-green-glow: rgba(34, 197, 94, 0.25);
    --accent-gold: #f59e0b;
    --accent-gold-glow: rgba(245, 158, 11, 0.25);
    --accent-purple: #a855f7;
    --accent-red: #ef4444;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.35);
    --shadow-glow-blue: 0 0 30px rgba(99, 102, 241, 0.12);
    --shadow-glow-green: 0 0 30px rgba(34, 197, 94, 0.12);

    --transition-fast: 0.15s ease-out;
    --transition-smooth: 0.25s ease-out;
}

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

html {
    font-size: 15px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Static gradient background — no animation, no massive oversized pseudo-element */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.06) 0%, transparent 50%),
                radial-gradient(ellipse at 80% 20%, rgba(34, 197, 94, 0.04) 0%, transparent 50%),
                radial-gradient(ellipse at 50% 80%, rgba(168, 85, 247, 0.04) 0%, transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* ========== LAYOUT ========== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-subtle);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    gap: 36px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    contain: layout style;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 4px;
}

.brand-icon {
    font-size: 1.4rem;
    color: var(--accent-blue);
    filter: drop-shadow(0 0 8px var(--accent-blue-glow));
}

.brand h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease-out, color 0.15s ease-out;
    position: relative;
}

.nav-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 3px;
    background: var(--accent-blue);
    border-radius: 0 4px 4px 0;
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.nav-item:hover {
    background: rgba(99, 102, 241, 0.08);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--text-primary);
}

.nav-item.active::before {
    opacity: 1;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 0.95rem;
}

/* ========== MAIN CONTENT ========== */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 28px 36px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    contain: layout style;
}

/* ========== TOPBAR ========== */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.6rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.82rem;
    color: var(--accent-green);
    font-weight: 500;
    padding: 6px 16px;
    background: rgba(34, 197, 94, 0.08);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 100px;
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--accent-green);
    border-radius: 50%;
    animation: pulseAnim 2s ease-in-out infinite;
}

@keyframes pulseAnim {
    0%, 100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
}

/* ========== STAT CARDS ========== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 24px 28px;
    border-radius: var(--radius-md);
    transition: transform 0.2s ease-out;
    cursor: default;
    position: relative;
    contain: layout style paint;
}

.stat-card:hover {
    transform: translateY(-3px);
}

.glow-blue {
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: var(--shadow-glow-blue);
}

.glow-blue .stat-icon {
    background: rgba(99, 102, 241, 0.12);
    color: var(--accent-blue);
}

.glow-green {
    border: 1px solid rgba(34, 197, 94, 0.2);
    box-shadow: var(--shadow-glow-green);
}

.glow-green .stat-icon {
    background: rgba(34, 197, 94, 0.12);
    color: var(--accent-green);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.stat-info p {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -1px;
    line-height: 1;
}

/* ========== GLASS CARD — No backdrop-filter (major perf killer) ========== */
.glass {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-card);
}

/* ========== CONTENT SPLIT ========== */
.content-split {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

/* ========== LOG TABLE ========== */
.log-section {
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow: hidden;
    contain: layout style;
}

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

.section-header h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-header h3 i {
    color: var(--accent-blue);
    font-size: 0.95rem;
}

.btn-refresh {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent-blue);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease-out, transform 0.3s ease-out;
}

.btn-refresh:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: rotate(90deg);
}

.btn-refresh:active {
    transform: rotate(180deg) scale(0.9);
}

.table-container {
    overflow-y: auto;
    max-height: 500px;
    border-radius: var(--radius-sm);
    contain: layout style;
}

.table-container::-webkit-scrollbar {
    width: 5px;
}

.table-container::-webkit-scrollbar-track {
    background: transparent;
}

.table-container::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.2);
    border-radius: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

th {
    background: rgba(17, 24, 39, 0.95);
    padding: 10px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

td {
    padding: 12px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(99, 102, 241, 0.06);
    /* NO transition on every cell — huge INP killer */
}

/* Only apply hover highlight at row level, no per-cell transition */
tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

tbody tr:hover td {
    color: var(--text-primary);
}

.loading-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px !important;
    font-style: italic;
}

/* Mutation badge styling */
.mutation-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.mutation-none {
    background: rgba(148, 163, 184, 0.12);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.mutation-gold {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.25);
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.mutation-diamond {
    background: rgba(56, 189, 248, 0.12);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.25);
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}

.mutation-emerald {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.25);
    text-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

.mutation-electric {
    background: rgba(168, 85, 247, 0.12);
    color: #a855f7;
    border: 1px solid rgba(168, 85, 247, 0.25);
    text-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

/* ========== LEADERBOARD ========== */
.side-section {
    border-radius: var(--radius-md);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    contain: layout style;
}

.side-section .section-header h3 i {
    color: var(--accent-gold);
}

.leaderboard-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.leaderboard-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    transition: background 0.15s ease-out;
    font-size: 0.88rem;
}

.leaderboard-list li:hover {
    background: rgba(99, 102, 241, 0.06);
}

.rank {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-muted);
}

.rank-1 {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.1));
    color: var(--accent-gold);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.15);
}

.rank-2 {
    background: linear-gradient(135deg, rgba(148, 163, 184, 0.3), rgba(148, 163, 184, 0.1));
    color: #cbd5e1;
}

.rank-3 {
    background: linear-gradient(135deg, rgba(180, 83, 9, 0.3), rgba(180, 83, 9, 0.1));
    color: #d97706;
}

.lb-username {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s ease-out;
}

.lb-username:hover {
    color: var(--accent-blue);
}

.lb-count {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1rem;
    color: var(--accent-blue);
}

/* ========== FADE-IN ANIMATION (initial load only) ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card,
.log-section,
.side-section {
    animation: fadeInUp 0.4s ease-out both;
}

.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.log-section { animation-delay: 0.15s; }
.side-section { animation-delay: 0.2s; }

/* Row fade-in — only first 10 rows, rest appear instantly */
@keyframes rowFadeIn {
    from {
        opacity: 0;
        transform: translateX(-8px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

tbody tr:nth-child(-n+10) {
    animation: rowFadeIn 0.2s ease-out both;
}

tbody tr:nth-child(1) { animation-delay: 0s; }
tbody tr:nth-child(2) { animation-delay: 0.02s; }
tbody tr:nth-child(3) { animation-delay: 0.04s; }
tbody tr:nth-child(4) { animation-delay: 0.06s; }
tbody tr:nth-child(5) { animation-delay: 0.08s; }
tbody tr:nth-child(6) { animation-delay: 0.1s; }
tbody tr:nth-child(7) { animation-delay: 0.12s; }
tbody tr:nth-child(8) { animation-delay: 0.14s; }
tbody tr:nth-child(9) { animation-delay: 0.16s; }
tbody tr:nth-child(10) { animation-delay: 0.18s; }

/* Skeleton loading pulse */
.skeleton-text {
    animation: skeletonPulse 1.5s ease-in-out infinite;
}

@keyframes skeletonPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ========== RESPONSIVE ========== */
@media (max-width: 1024px) {
    .sidebar {
        width: 64px;
        padding: 20px 8px;
        align-items: center;
    }

    .brand h1,
    .nav-item span {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .nav-item i {
        margin: 0;
    }

    .main-content {
        margin-left: 64px;
        padding: 20px;
    }

    .content-split {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stat-info p {
        font-size: 1.6rem;
    }
}
