/* F1 Stats - Dark/Light Theme Styles */

:root {
    /* Light theme (default) */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a1a;
    --text-secondary: #666666;
    --text-muted: #999999;
    --border-color: #e0e0e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    
    /* F1 Team Colors */
    --mercedes: #00d2be;
    --ferrari: #dc0000;
    --redbull: #0600ef;
    --mclaren: #ff8700;
    --alpine: #0090ff;
    --astonmartin: #006f62;
    --haas: #ffffff;
    --alphatauri: #2b4562;
    --williams: #005aff;
    --alfaromeo: #900000;
    --audi: #c0c0c0;
    --cadillac: #c0c0c0;
    
    /* Position colors */
    --pos-gold: #ffd700;
    --pos-silver: #c0c0c0;
    --pos-bronze: #cd7f32;
}

[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --text-muted: #707070;
    --border-color: #2a2a2a;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* Countdown Banner */
.countdown-banner {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f0f23 100%);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    overflow: hidden;
    position: relative;
}

.countdown-banner::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 200%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.05), transparent);
    animation: shimmer-bg 3s infinite;
}

@keyframes shimmer-bg {
    0% { transform: translateX(0); }
    100% { transform: translateX(50%); }
}

.countdown-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
    position: relative;
    z-index: 1;
}

.countdown-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.countdown-race {
    font-size: 1.125rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--ferrari), var(--mclaren));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.countdown-timer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.countdown-unit {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 60px;
}

.countdown-value {
    font-size: 1.75rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(180deg, #ffffff 0%, #b0b0b0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.countdown-label-small {
    font-size: 0.625rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

.countdown-separator {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    line-height: 1;
}

/* Countdown complete state */
.countdown-banner.race-time {
    background: linear-gradient(135deg, var(--ferrari), #ff3333);
    animation: pulse-bg 2s infinite;
}

@keyframes pulse-bg {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.85; }
}

.countdown-banner.race-time .countdown-value {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: white;
}

@media (max-width: 600px) {
    .countdown-content {
        gap: 0.75rem;
    }
    
    .countdown-unit {
        min-width: 48px;
    }
    
    .countdown-value {
        font-size: 1.25rem;
    }
    
    .countdown-separator {
        font-size: 1rem;
    }
    
    .countdown-race {
        font-size: 0.9rem;
    }
}

/* Header */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Live Banner */
.live-banner {
    background: linear-gradient(135deg, #dc0000, #ff3333);
    color: white;
    padding: 0.75rem 1rem;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.live-banner.upcoming {
    background: linear-gradient(135deg, #1a1a2e, #16213e);
}

.live-dot {
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.8); }
}

.live-text {
    font-size: 0.9rem;
    letter-spacing: 0.02em;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.logo-icon {
    font-size: 1.5rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--mercedes), var(--ferrari));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.season-badge {
    background: var(--ferrari);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.beta-badge {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 1rem;
    font-size: 0.65rem;
    font-weight: 600;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

.theme-toggle, .refresh-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

.theme-toggle:hover, .refresh-btn:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

.refresh-btn.loading .refresh-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Main */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .grid {
        grid-template-columns: 1fr;
    }
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card h2 .icon {
    font-size: 1.25rem;
}

/* Race Card */
.race-card {
    grid-column: span 2;
}

@media (max-width: 900px) {
    .race-card {
        grid-column: span 1;
    }
}

.race-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 0.5rem;
}

.race-name {
    font-size: 1.5rem;
    font-weight: 700;
}

.race-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.race-circuit {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.session-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.session-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.session-item.active {
    border-color: var(--ferrari);
    background: rgba(220, 0, 0, 0.1);
}

.session-name {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.session-time {
    font-size: 0.875rem;
    font-weight: 600;
}

.session-utc {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.session-live {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, rgba(220, 0, 0, 0.2), rgba(220, 0, 0, 0.1));
    border: 1px solid var(--ferrari);
    border-radius: 0.5rem;
    margin-bottom: 0.75rem;
}

.live-indicator {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--ferrari);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.live-session {
    font-size: 0.875rem;
    font-weight: 600;
}

/* Standings */
.standings-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.driver-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: background 0.2s ease;
}

.driver-row:hover {
    background: var(--bg-secondary);
}

.position {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.position.p1 {
    background: var(--pos-gold);
    color: #000;
    border: none;
}

.position.p2 {
    background: var(--pos-silver);
    color: #000;
    border: none;
}

.position.p3 {
    background: var(--pos-bronze);
    color: #fff;
    border: none;
}

.driver-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.driver-name {
    font-weight: 500;
}

.team-tag {
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-weight: 600;
    text-transform: uppercase;
}

.team-tag.team-mercedes { background: var(--mercedes); color: #000; }
.team-tag.team-ferrari { background: var(--ferrari); color: #fff; }
.team-tag.team-redbull { background: var(--redbull); color: #fff; }
.team-tag.team-mclaren { background: var(--mclaren); color: #000; }
.team-tag.team-alpine { background: var(--alpine); color: #fff; }
.team-tag.team-astonmartin { background: var(--astonmartin); color: #fff; }
.team-tag.team-haas { background: #e0e0e0; color: #000; }
.team-tag.team-williams { background: var(--williams); color: #fff; }
.team-tag.team-audi { background: var(--audi); color: #000; }
.team-tag.team-cadillac { background: #e0e0e0; color: #000; }
.team-tag.team-racingbulls { background: #666; color: #fff; }

.driver-points {
    font-weight: 600;
    color: var(--text-secondary);
}

/* Fastest Lap - Purple Badge (like F1 TV) */
.fl-badge {
    display: inline-block;
    background: #a855f7;
    color: white;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    margin-left: 0.25rem;
    vertical-align: middle;
}

.fastest-lap-header {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-left: 0.75rem;
    color: #a855f7;
    font-size: 0.75rem;
    font-weight: 500;
}

.fastest-lap-header .fl-badge {
    margin-left: 0;
}

/* Results Table */
.results-header {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.results-header .session-label {
    background: linear-gradient(90deg, #e10600, #ff8c00);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

.results-header .race-location {
    color: var(--text-secondary);
    font-weight: 500;
}

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

.results-table th,
.results-table td {
    padding: 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.results-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.results-table td {
    font-size: 0.875rem;
}

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

.results-table .position {
    width: 1.75rem;
    height: 1.75rem;
    font-size: 0.75rem;
}

/* Loading States */
.loading-skeleton {
    height: 2.5rem;
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.loading-cell {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.footer a {
    color: var(--mercedes);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.cache-status {
    margin-top: 0.5rem;
    font-size: 0.75rem;
}

/* Poll Card */

/* Error State */
.error-message {
    color: var(--ferrari);
    text-align: center;
    padding: 1rem;
}

/* Weather Card */
.weather-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 1rem;
}

.weather-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 0.5rem;
    text-align: center;
}

.weather-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.weather-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.weather-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-top: 0.25rem;
}

/* Pit Stops */
.tire-soft, .tire-medium, .tire-hard, .tire-intermediate, .tire-wet {
    font-weight: 600;
    padding: 0.1rem 0.3rem;
    border-radius: 0.25rem;
    font-size: 0.7rem;
}

.tire-soft { color: #e10600; }
.tire-medium { color: #ffd12e; }
.tire-hard { color: #3695c7; }
.tire-intermediate { color: #78c457; }
.tire-wet { color: #4296d9; }

/* Responsive */
@media (max-width: 600px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }
    
    .main {
        padding: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .race-name {
        font-size: 1.25rem;
    }
    
    .session-list {
        flex-direction: column;
    }
    
    .weather-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.last-updated {
    font-size: 0.75rem;
    color: var(--text-muted, #888);
    text-align: right;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

/* News Section */
.news-card {
    grid-column: span 1;
}

.news-card h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.news-disclaimer {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-intro {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.news-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.news-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: inherit;
    transition: background 0.15s ease;
    gap: 1rem;
}

.news-item:last-child {
    border-bottom: none;
}

.news-item:hover {
    background: var(--bg-secondary);
    margin: 0 -1rem;
    padding-left: 1rem;
    padding-right: 1rem;
}

.news-item-content {
    flex: 1;
    min-width: 0;
}

.news-source {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--mercedes);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-headline {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0.25rem 0;
    line-height: 1.4;
}

.news-excerpt {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-arrow {
    font-size: 1rem;
    color: var(--text-muted);
    flex-shrink: 0;
    padding-top: 0.25rem;
}

.news-item:hover .news-arrow {
    color: var(--mercedes);
}

.news-footer {
    margin-top: 0.75rem;
    text-align: right;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.news-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
    font-size: 0.9rem;
}

@media (max-width: 900px) {
    .news-card {
        grid-column: span 1;
    }
}


/* DNF Rows */
.dnf-row {
    background: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 10px,
        rgba(220, 38, 38, 0.05) 10px,
        rgba(220, 38, 38, 0.05) 20px
    );
}

.dnf-row td {
    opacity: 0.7;
}

.dnf-pos {
    background: #dc2626 !important;
    color: white !important;
}

.dnf-row:hover {
    background: repeating-linear-gradient(
        135deg,
        transparent,
        transparent 10px,
        rgba(220, 38, 38, 0.1) 10px,
        rgba(220, 38, 38, 0.1) 20px
    );
}
