/* Modern Design System for LiveStats Engine */

:root {
    /* Brand Colors - "Pulling Power" Theme */
    --brand-red: #dc2626; /* Red-600 */
    --brand-red-dark: #991b1b; /* Red-800 */
    --brand-red-glow: rgba(220, 38, 38, 0.5);
    
    --brand-dark: #0f172a; /* Slate-900 */
    --brand-darker: #020617; /* Slate-950 */
    --brand-surface: #1e293b; /* Slate-800 */
    --brand-surface-highlight: #334155; /* Slate-700 */
    
    --text-primary: #f8fafc; /* Slate-50 */
    --text-secondary: #94a3b8; /* Slate-400 */
    --text-muted: #64748b; /* Slate-500 */

    --accent-green: #22c55e; /* Green-500 */
    --accent-blue: #3b82f6; /* Blue-500 */
    --accent-amber: #f59e0b; /* Amber-500 */

    /* Overrides for Legacy Variables */
    --primary: var(--brand-red);
    --primary-dark: var(--brand-red-dark);
    --primary-soft: var(--brand-red-dark);
    --primary-bright: #ef4444;
    --bg: var(--brand-darker);
    --bg-soft: var(--brand-dark);
    --card: var(--brand-surface);
    --border: var(--brand-surface-highlight);
    --muted: var(--text-secondary);
}

/* Global Reset & Typography */
body {
    background-color: var(--bg);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* Modern Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: var(--bg);
}
::-webkit-scrollbar-thumb {
    background: var(--brand-surface-highlight);
    border-radius: 5px;
    border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =========================================
   Component Modernization
   ========================================= */

/* 1. Cards & Containers */
.card, .status-chip, .chip-card {
    background: var(--card);
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.1);
    border-radius: 0.75rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    border-color: var(--text-muted);
}

/* 2. Header - "The Dashboard Look" */
header {
    background: linear-gradient(to right, #0f172a, #1e293b);
    border-bottom: 1px solid var(--brand-red);
    box-shadow: 0 4px 20px -5px var(--brand-red-glow);
    padding: 1rem 1.5rem;
}

header h1 {
    font-weight: 800;
    letter-spacing: -0.03em;
    text-transform: uppercase;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* 3. Buttons - "Tactile & Clickable" */
button, .btn {
    border-radius: 0.5rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-size: 0.875rem;
    transition: all 0.2s;
    border: 1px solid transparent;
}

button:hover, .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

button:active, .btn:active {
    transform: translateY(0);
}

/* Primary Action Buttons */
.btn-primary, button[type="submit"], .modal-btn.save {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    border: 1px solid rgba(255,255,255,0.1);
}

.btn-primary:hover {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
}

/* 4. Inputs - "High Contrast Data Entry" */
input, select, textarea {
    background: var(--brand-dark) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: 0.5rem !important;
    padding: 0.6rem 0.8rem !important;
    font-size: 0.95rem !important;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand-red) !important;
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2);
}

/* 5. Status Chips & Badges */
.badge {
    font-weight: 600;
    letter-spacing: 0.025em;
    padding: 0.25rem 0.75rem;
}

.badge.connected {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* 6. The "Lineup Rail" - Horizontal Scroll Area */
.lineup-rail {
    background: rgba(0,0,0,0.2);
    border-radius: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
}

.chip-card {
    background: var(--brand-surface);
    border: 1px solid var(--border);
}

.chip-card.current {
    /* background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(59, 130, 246, 0.1)); REMOVED: Don't override background */
    border-color: var(--accent-blue);
    border-width: 2px;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* 7. Class Pills */
.class-pill {
    background: var(--brand-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.class-pill:hover {
    background: var(--brand-surface-highlight);
    color: var(--text-primary);
    cursor: pointer;
}

.class-pill.active {
    background: linear-gradient(135deg, var(--accent-blue), #2563eb);
    border-color: var(--accent-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* 8. Tables (if any) */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background: var(--brand-surface-highlight);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 0.75rem 1rem;
}

td {
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255,255,255,0.02);
}

/* 9. Login & Loading Screens */
#login-overlay, #loading-screen {
    background: radial-gradient(circle at center, #1e293b 0%, #020617 100%);
}

.login-container, .loading-container {
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Modern Result Card Design - Full Width Layout */
.result-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
    border-color: var(--accent-blue);
}

/* Rank Badge - Top Left */
.result-rank {
    position: absolute;
    top: 1rem;
    left: 1rem;
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--text-muted);
    opacity: 0.3;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.result-rank.rank-1 { 
    color: #FFD700; 
    opacity: 0.6;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.4); 
}
.result-rank.rank-2 { 
    color: #C0C0C0; 
    opacity: 0.5;
}
.result-rank.rank-3 { 
    color: #CD7F32; 
    opacity: 0.5;
}

/* Info Section - Takes Full Width */
.result-info {
    margin-left: 0;
    padding-left: 100px;
}

.vehicle-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.vehicle-meta {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.driver-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--text-secondary);
}

/* Score Section - Full Width Stats Row */
.result-score {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 2rem;
    padding: 1rem;
    padding-left: 100px;
    padding-right: 1.5rem;
    border-top: 1px solid var(--border);
    background: rgba(0,0,0,0.1);
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-item .stat-value {
    font-size: 2.25rem;
    font-weight: 900;
    line-height: 1;
    font-family: 'Roboto Mono', monospace;
}

.stat-item .stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    opacity: 0.8;
}

.distance-stat .stat-value {
    color: var(--accent-blue);
}

.speed-stat .stat-value {
    color: var(--accent-blue);
}

.points-stat .stat-value {
    color: var(--accent-green);
}

.points-stat {
    background: rgba(16, 185, 129, 0.1);
    padding: 1rem;
    border-radius: 8px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

/* DQ Styling */
.result-card.dq {
    border: 2px solid var(--brand-red);
    background: linear-gradient(135deg, rgba(220, 38, 38, 0.15) 0%, rgba(220, 38, 38, 0.05) 50%, transparent 100%);
}

.result-card.dq .result-rank {
    color: var(--brand-red);
    opacity: 0.4;
    text-decoration: line-through;
}

.result-card.dq .vehicle-name {
    color: var(--brand-red);
}

.result-card.dq .distance-stat .stat-value {
    color: var(--text-muted);
    text-decoration: line-through;
    opacity: 0.5;
}

.dq-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--brand-red);
    color: white;
    font-size: 0.75rem;
    font-weight: 900;
    padding: 4px 12px;
    border-bottom-left-radius: 12px;
    letter-spacing: 1px;
    z-index: 1;
}