/* GPS Timing System — Design System v1 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    /* Backgrounds */
    --bg-root: #06060a;
    --bg-surface: #0e0e14;
    --bg-card: #14141c;
    --bg-card-hover: #1a1a24;
    --bg-elevated: #1e1e28;

    /* Borders */
    --border-subtle: #1c1c28;
    --border-default: #26263a;
    --border-strong: #3a3a52;

    /* Accent - Racing Red */
    --accent: #ef4444;
    --accent-bright: #f87171;
    --accent-dim: #991b1b;
    --accent-glow: rgba(239, 68, 68, 0.15);

    /* Secondary - Amber/Gold for live data */
    --secondary: #f59e0b;
    --secondary-bright: #fbbf24;
    --secondary-dim: #92400e;

    /* Tertiary - Emerald for positive */
    --positive: #10b981;
    --positive-dim: #065f46;

    /* Purple for highlights */
    --purple: #8b5cf6;
    --purple-dim: #4c1d95;

    /* Text */
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #55556a;
    --text-inverse: #06060a;

    /* Spacing */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-root);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* ===== HEADER ===== */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 52px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
}
.app-header .logo-mark {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
    color: #fff;
    letter-spacing: -1px;
}
.app-header .logo-text {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.app-header .logo-text span {
    color: var(--text-muted);
    font-weight: 400;
    margin-left: 8px;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
}
.header-nav {
    display: flex;
    gap: 2px;
    height: 100%;
    align-items: stretch;
}
.header-nav a {
    display: flex;
    align-items: center;
    padding: 0 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.header-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}
.header-nav a.active {
    color: var(--accent-bright);
    border-bottom-color: var(--accent);
}
.header-status {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}
.status-live {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--positive);
    font-weight: 600;
}
.status-live::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--positive);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* ===== LAYOUT ===== */
.page-content {
    padding: 32px;
    max-width: 1400px;
    margin: 0 auto;
}
.page-content-full {
    padding: 0;
    height: calc(100vh - 52px);
    overflow: hidden;
}
.section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}
.section { margin-bottom: 48px; }

/* ===== CARDS ===== */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all 0.15s;
}
.card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-default);
}
.card-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}
.card-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 500;
}
.card-accent { border-left: 3px solid var(--accent); }
.card-positive .card-value { color: var(--positive); }
.card-warning .card-value { color: var(--secondary); }

/* ===== TIMING TABLE ===== */
.timing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.timing-table thead th {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-default);
    background: var(--bg-surface);
    position: sticky;
    top: 0;
}
.timing-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background 0.1s;
}
.timing-table tbody tr:hover {
    background: var(--bg-card);
}
.timing-table td {
    padding: 10px 16px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}
.pos-cell { font-weight: 700; text-align: center; width: 40px; }
.pos-1 { color: var(--secondary-bright); }
.pos-2 { color: var(--text-secondary); }
.pos-3 { color: #cd7f32; }
.driver-name { font-family: 'Inter', sans-serif; font-weight: 600; color: var(--text-primary); }
.time-best { color: var(--purple); font-weight: 600; }
.time-improve { color: var(--positive); }
.time-slower { color: var(--secondary); }
.sector-purple { background: rgba(139, 92, 246, 0.15); color: var(--purple); border-radius: 3px; padding: 4px 8px; }
.sector-green { background: rgba(16, 185, 129, 0.12); color: var(--positive); border-radius: 3px; padding: 4px 8px; }
.sector-yellow { background: rgba(245, 158, 11, 0.12); color: var(--secondary); border-radius: 3px; padding: 4px 8px; }

/* ===== BUTTONS ===== */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-strong);
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-bright); border-color: var(--accent-bright); }
.btn-outline-accent { border-color: var(--accent-dim); color: var(--accent-bright); }
.btn-outline-accent:hover { background: var(--accent-glow); border-color: var(--accent); }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

/* ===== STATUS BADGES ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-live { background: rgba(16, 185, 129, 0.15); color: var(--positive); }
.badge-idle { background: rgba(245, 158, 11, 0.15); color: var(--secondary); }
.badge-offline { background: rgba(85, 85, 106, 0.2); color: var(--text-muted); }

/* ===== LEADERBOARD ===== */
.leaderboard { display: flex; flex-direction: column; gap: 2px; }
.lb-row {
    display: grid;
    grid-template-columns: 40px 4px 1fr 120px 120px 80px 80px 80px;
    align-items: center;
    gap: 0;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    overflow: hidden;
    height: 44px;
    transition: background 0.1s;
}
.lb-row:hover { background: var(--bg-card-hover); }
.lb-pos {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 16px;
    text-align: center;
    color: var(--text-secondary);
}
.lb-row:nth-child(1) .lb-pos { color: var(--secondary-bright); }
.lb-row:nth-child(2) .lb-pos { color: #ccc; }
.lb-row:nth-child(3) .lb-pos { color: #cd7f32; }
.lb-bar { height: 100%; }
.lb-row:nth-child(1) .lb-bar { background: var(--secondary-bright); }
.lb-row:nth-child(2) .lb-bar { background: #999; }
.lb-row:nth-child(3) .lb-bar { background: #cd7f32; }
.lb-row:nth-child(n+4) .lb-bar { background: var(--border-default); }
.lb-driver {
    padding: 0 16px;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lb-time, .lb-gap, .lb-sector {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    padding: 0 12px;
    color: var(--text-secondary);
}

/* ===== NAV CARDS ===== */
a.nav-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 20px 24px;
    text-decoration: none;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}
a.nav-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 3px; height: 100%;
    background: var(--accent);
    opacity: 0;
    transition: opacity 0.2s;
}
a.nav-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-default);
    transform: translateY(-1px);
}
a.nav-card:hover::before { opacity: 1; }
a.nav-card .nav-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
a.nav-card .nav-card-desc {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== FORM INPUTS ===== */
.input {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}
.input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.input-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
select.input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2355556a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

/* ===== PANEL ===== */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.panel-header {
    padding: 12px 20px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
}
.panel-body { padding: 20px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app-header { padding: 0 12px; }
    .header-nav { display: none; }
    .page-content { padding: 16px; }
    .card-grid { grid-template-columns: 1fr 1fr; }
    .lb-row { grid-template-columns: 32px 3px 1fr 100px; }
    .lb-gap, .lb-sector { display: none; }
}
