/* F1 Dashboard Styles */
:root {
    --f1-red: #e10600;
    --f1-dark: #15151e;
    --f1-darker: #0d0d12;
    --f1-gray: #38383f;
    --f1-light-gray: #67676d;
    --f1-white: #ffffff;
    --f1-yellow: #ffd700;
    --f1-green: #00d100;
    --f1-purple: #9b59b6;
    --f1-blue: #3498db;

    /* Team Colors */
    --team-redbull: #3671c6;
    --team-mercedes: #27f4d2;
    --team-ferrari: #e8002d;
    --team-mclaren: #ff8000;
    --team-astonmartin: #229971;
    --team-alpine: #ff87bc;
    --team-williams: #64c4ff;
    --team-alphatauri: #6692ff;
    --team-alfaromeo: #52e252;
    --team-haas: #b6babd;
}

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

body {
    font-family: 'Titillium Web', sans-serif;
    background: var(--f1-darker);
    color: var(--f1-white);
    min-height: 100vh;
    overflow-x: hidden;
}

.dashboard {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header Styles */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--f1-dark) 0%, var(--f1-darker) 100%);
    border-bottom: 3px solid var(--f1-red);
}

/* Controls Bar */
.controls-bar {
    display: flex;
    align-items: center;
    gap: 2rem;
    padding: 0.75rem 2rem;
    background: var(--f1-dark);
    border-bottom: 1px solid var(--f1-gray);
    flex-wrap: wrap;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.8rem;
    color: var(--f1-light-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group select {
    background: var(--f1-darker);
    border: 1px solid var(--f1-gray);
    color: var(--f1-white);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: 'Titillium Web', sans-serif;
    font-size: 0.875rem;
    cursor: pointer;
    min-width: 180px;
}

.control-group select:hover {
    border-color: var(--f1-red);
}

.control-group select:focus {
    outline: none;
    border-color: var(--f1-red);
}

.time-control {
    flex: 1;
    min-width: 300px;
}

.time-control label {
    min-width: 140px;
}

#time-display {
    color: var(--f1-white);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.slider-container span {
    font-size: 0.75rem;
    color: var(--f1-light-gray);
    font-family: 'Courier New', monospace;
}

#time-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--f1-gray);
    border-radius: 3px;
    cursor: pointer;
}

#time-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--f1-red);
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.1s;
}

#time-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

#time-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--f1-red);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Playback Controls */
.playback-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.playback-btn {
    background: var(--f1-gray);
    border: 1px solid var(--f1-gray);
    color: var(--f1-white);
    width: 36px;
    height: 36px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.playback-btn:hover {
    background: var(--f1-purple);
    border-color: var(--f1-purple);
}

.playback-btn.playing {
    background: var(--f1-purple);
    border-color: var(--f1-purple);
}

#speed-select {
    background: var(--f1-darker);
    border: 1px solid var(--f1-gray);
    color: var(--f1-white);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-family: 'Titillium Web', sans-serif;
    font-size: 0.8rem;
    cursor: pointer;
    min-width: 60px;
}

#speed-select:hover {
    border-color: var(--f1-purple);
}

#speed-select:focus {
    outline: none;
    border-color: var(--f1-purple);
}

.live-btn {
    background: var(--f1-gray);
    border: 1px solid var(--f1-gray);
    color: var(--f1-white);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-family: 'Titillium Web', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.live-btn:hover {
    background: var(--f1-green);
    border-color: var(--f1-green);
}

.live-btn.active {
    background: var(--f1-green);
    border-color: var(--f1-green);
    animation: pulse-green 1.5s infinite;
}

@keyframes pulse-green {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0, 209, 0, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(0, 209, 0, 0); }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.f1-logo {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--f1-red);
    letter-spacing: -2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.race-info h1 {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.race-info .circuit {
    font-size: 0.875rem;
    color: var(--f1-light-gray);
}

.header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

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

.session-type {
    font-size: 1.25rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--f1-yellow);
}

.session-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem;
    background: rgba(0, 209, 0, 0.1);
    border-radius: 20px;
    border: 1px solid var(--f1-green);
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--f1-green);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

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

.last-update {
    font-size: 0.75rem;
    color: var(--f1-light-gray);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 400px 1fr 350px;
    gap: 1rem;
    padding: 1rem;
    flex: 1;
}

/* Panel Styles */
.standings-panel,
.center-panel,
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--f1-dark);
    border-radius: 8px 8px 0 0;
    border-left: 3px solid var(--f1-red);
}

/* Stats Panel */
.stats-panel {
    background: var(--f1-dark);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--f1-red);
}

.stats-panel h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--f1-red);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.stat-card {
    background: var(--f1-darker);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.stat-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--f1-white);
    font-family: 'Courier New', monospace;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--f1-light-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card.highlight .stat-value {
    color: var(--f1-purple);
}

.panel-header h2 {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.refresh-btn {
    background: transparent;
    border: 1px solid var(--f1-gray);
    color: var(--f1-white);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--f1-red);
    border-color: var(--f1-red);
}

/* Standings Table */
.standings-table {
    background: var(--f1-dark);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    max-height: calc(100vh - 220px);
    overflow-y: auto;
}

.driver-row {
    display: grid;
    grid-template-columns: 40px 6px 1fr 80px 60px;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--f1-gray);
    transition: background 0.2s;
}

.driver-row:hover {
    background: rgba(255,255,255,0.05);
}

.driver-row.fastest-lap {
    background: rgba(155, 89, 182, 0.2);
}

.position {
    font-size: 1.25rem;
    font-weight: 700;
    text-align: center;
}

.position.p1 { color: var(--f1-yellow); }
.position.p2 { color: #c0c0c0; }
.position.p3 { color: #cd7f32; }

.team-color {
    height: 100%;
    border-radius: 2px;
}

.driver-info {
    display: flex;
    flex-direction: column;
    padding-left: 0.75rem;
}

.driver-name {
    font-weight: 600;
    font-size: 0.9rem;
}

.driver-team {
    font-size: 0.75rem;
    color: var(--f1-light-gray);
}

.driver-gap {
    font-size: 0.875rem;
    text-align: right;
    color: var(--f1-light-gray);
}

.driver-gap.leader {
    color: var(--f1-green);
    font-weight: 600;
}

.tyre-compound {
    display: flex;
    justify-content: center;
}

.tyre {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--f1-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
}

.tyre.soft { background: var(--f1-red); }
.tyre.medium { background: var(--f1-yellow); color: var(--f1-dark); }
.tyre.hard { background: var(--f1-white); color: var(--f1-dark); }
.tyre.intermediate { background: #00c853; }
.tyre.wet { background: var(--f1-blue); }

/* Weather Widget */
.weather-widget {
    background: var(--f1-dark);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--f1-blue);
}

.weather-widget h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--f1-blue);
}

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

.weather-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

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

.weather-label {
    font-size: 0.7rem;
    color: var(--f1-light-gray);
    text-transform: uppercase;
}

.weather-value {
    font-size: 1rem;
    font-weight: 600;
}

/* Race Control Panel */
.race-control-panel {
    background: var(--f1-dark);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--f1-yellow);
    flex: 1;
}

.race-control-panel h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--f1-yellow);
}

.race-control-messages {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rc-message {
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.rc-message.flag-yellow {
    background: rgba(255, 215, 0, 0.15);
    border-left: 3px solid var(--f1-yellow);
}

.rc-message.flag-red {
    background: rgba(225, 6, 0, 0.15);
    border-left: 3px solid var(--f1-red);
}

.rc-message.flag-green {
    background: rgba(0, 209, 0, 0.15);
    border-left: 3px solid var(--f1-green);
}

.rc-message.flag-blue {
    background: rgba(52, 152, 219, 0.15);
    border-left: 3px solid var(--f1-blue);
}

.rc-message.drs {
    background: rgba(155, 89, 182, 0.15);
    border-left: 3px solid var(--f1-purple);
}

.rc-message.safety-car {
    background: rgba(255, 128, 0, 0.15);
    border-left: 3px solid var(--team-mclaren);
}

.rc-time {
    color: var(--f1-light-gray);
    font-size: 0.7rem;
    white-space: nowrap;
}

.rc-text {
    flex: 1;
}

/* Pit Stops Panel */
.pit-stops-panel {
    background: var(--f1-dark);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--f1-green);
}

.pit-stops-panel h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--f1-green);
}

.pit-stops-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 150px;
    overflow-y: auto;
}

.pit-stop-row {
    display: grid;
    grid-template-columns: 30px 6px 1fr 70px 50px;
    align-items: center;
    padding: 0.4rem;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    font-size: 0.8rem;
}

.pit-lap {
    color: var(--f1-light-gray);
    font-size: 0.7rem;
}

.pit-duration {
    font-weight: 600;
    color: var(--f1-green);
}

.pit-duration.slow {
    color: var(--f1-yellow);
}

/* Intervals Panel */
.intervals-panel {
    background: var(--f1-dark);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--f1-purple);
}

.intervals-panel h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--f1-purple);
}

.intervals-list {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 350px;
    overflow-y: auto;
}

.interval-row {
    display: grid;
    grid-template-columns: 25px 6px 1fr 60px;
    align-items: center;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.interval-row:nth-child(odd) {
    background: rgba(255,255,255,0.02);
}

.interval-gap {
    text-align: right;
    font-weight: 600;
}

.interval-gap.close {
    color: var(--f1-red);
}

/* Fastest Laps Panel */
.fastest-laps-panel {
    background: var(--f1-dark);
    border-radius: 8px;
    padding: 1rem;
    border-left: 3px solid var(--f1-purple);
    flex: 1;
}

.fastest-laps-panel h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem;
    color: var(--f1-purple);
}

.fastest-laps-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.lap-row {
    display: grid;
    grid-template-columns: 25px 6px 1fr 80px;
    align-items: center;
    padding: 0.4rem;
    background: rgba(255,255,255,0.03);
    border-radius: 4px;
    font-size: 0.8rem;
}

.lap-row.overall-fastest {
    background: rgba(155, 89, 182, 0.3);
}

.lap-time {
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.lap-time.fastest {
    color: var(--f1-purple);
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--f1-light-gray);
    font-size: 0.875rem;
}

/* Footer */
.footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--f1-dark);
    border-top: 1px solid var(--f1-gray);
    font-size: 0.75rem;
    color: var(--f1-light-gray);
}

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

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

.separator {
    color: var(--f1-gray);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--f1-darker);
}

::-webkit-scrollbar-thumb {
    background: var(--f1-gray);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--f1-light-gray);
}

/* Responsive - Tablet */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr 1fr;
    }

    .standings-panel {
        grid-column: 1 / -1;
    }

    .standings-table {
        max-height: 350px;
    }

    .header {
        padding: 0.75rem 1rem;
    }

    .controls-bar {
        padding: 0.5rem 1rem;
        gap: 1rem;
    }

    .time-control {
        min-width: 250px;
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
        padding: 0.5rem;
        gap: 0.75rem;
    }

    .header {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        align-items: flex-start;
    }

    .header-left {
        width: 100%;
    }

    .header-right {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .f1-logo {
        font-size: 2rem;
    }

    .race-info h1 {
        font-size: 1.1rem;
    }

    .race-info .circuit {
        font-size: 0.75rem;
    }

    .session-type {
        font-size: 1rem;
    }

    .controls-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .control-group select {
        min-width: 100%;
        padding: 0.6rem 1rem;
    }

    .time-control {
        min-width: 100%;
    }

    .time-control label {
        min-width: auto;
    }

    .slider-container {
        width: 100%;
    }

    .playback-controls {
        justify-content: center;
        gap: 1rem;
    }

    .playback-btn {
        width: 44px;
        height: 44px;
    }

    #speed-select {
        min-width: 70px;
        padding: 0.5rem;
    }

    .live-btn {
        width: 100%;
        padding: 0.6rem 1rem;
    }

    .standings-table {
        max-height: 300px;
    }

    .driver-row {
        grid-template-columns: 35px 5px 1fr 65px 50px;
        padding: 0.4rem 0.5rem;
    }

    .position {
        font-size: 1rem;
    }

    .driver-name {
        font-size: 0.8rem;
    }

    .driver-team {
        font-size: 0.65rem;
    }

    .driver-gap {
        font-size: 0.75rem;
    }

    .tyre {
        width: 20px;
        height: 20px;
        font-size: 0.5rem;
    }

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

    .stat-card {
        padding: 0.75rem;
    }

    .stat-icon {
        font-size: 1.25rem;
    }

    .stat-value {
        font-size: 1rem;
    }

    .stat-label {
        font-size: 0.6rem;
    }

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

    .weather-icon {
        font-size: 1.25rem;
    }

    .weather-value {
        font-size: 0.9rem;
    }

    .race-control-messages {
        max-height: 180px;
    }

    .rc-message {
        font-size: 0.75rem;
        gap: 0.5rem;
    }

    .pit-stops-list {
        max-height: 120px;
    }

    .pit-stop-row {
        grid-template-columns: 25px 5px 1fr 60px 45px;
        font-size: 0.75rem;
    }

    .intervals-list {
        max-height: 250px;
    }

    .interval-row {
        grid-template-columns: 22px 5px 1fr 55px;
        font-size: 0.75rem;
    }

    .fastest-laps-list {
        max-height: 200px;
    }

    .lap-row {
        grid-template-columns: 22px 5px 1fr 70px;
        font-size: 0.75rem;
    }

    .panel-header {
        padding: 0.5rem 0.75rem;
    }

    .panel-header h2 {
        font-size: 0.875rem;
    }

    .stats-panel,
    .weather-widget,
    .race-control-panel,
    .pit-stops-panel,
    .intervals-panel,
    .fastest-laps-panel {
        padding: 0.75rem;
    }

    .stats-panel h3,
    .weather-widget h3,
    .race-control-panel h3,
    .pit-stops-panel h3,
    .intervals-panel h3,
    .fastest-laps-panel h3 {
        font-size: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .footer {
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem;
        font-size: 0.65rem;
        text-align: center;
    }

    .separator {
        display: none;
    }

    .footer span {
        width: 100%;
    }
}

/* Extra small screens */
@media (max-width: 400px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

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

    .header-left {
        gap: 0.75rem;
    }

    .f1-logo {
        font-size: 1.75rem;
    }

    .race-info h1 {
        font-size: 1rem;
    }

    .driver-row {
        grid-template-columns: 30px 4px 1fr 55px 40px;
    }

    .driver-info {
        padding-left: 0.5rem;
    }

    .tyre {
        width: 18px;
        height: 18px;
    }
}

/* No Data State */
.no-data {
    text-align: center;
    padding: 2rem;
    color: var(--f1-light-gray);
    font-style: italic;
}

/* Error State */
.error-message {
    background: rgba(225, 6, 0, 0.1);
    border: 1px solid var(--f1-red);
    border-radius: 4px;
    padding: 1rem;
    color: var(--f1-red);
    text-align: center;
    font-size: 0.875rem;
}
