﻿/* ========================================
   STANDINGS - STILI COMUNI PER CLASSIFICHE
   ======================================== */

/* Header con info gara */
.race-header {
    margin-bottom: 20px;
}

.race-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 20px;
}

.race-info-item {
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 4px;
}

    .race-info-item strong {
        display: block;
        color: #666;
        font-size: 0.9em;
        margin-bottom: 5px;
    }

/* Pallino live lampeggiante */
.live-indicator {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #dc3545;
    border-radius: 50%;
    animation: blink 1.5s infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

/* Container tabella con scroll */
.table-container {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    position: relative;
    scroll-behavior: smooth;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

/* Tabella live - header fisso */
.table-live {
    min-width: 800px;
}

    .table-live thead {
        position: sticky;
        top: 0;
        z-index: 10;
        background-color: #fff;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }

        .table-live thead tr {
            background-color: inherit;
        }

        .table-live thead th {
            vertical-align: middle;
        }

    .table-live tbody td {
        vertical-align: middle;
    }

    /* Righe cliccabili con effetto hover */
    .table-live tbody tr[onclick] {
        cursor: pointer;
        transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    }

        .table-live tbody tr[onclick]:hover {
            background-color: #fff3cd !important;
            transform: scale(1.01);
            box-shadow: 0 2px 8px rgba(250, 165, 0, 0.4);
        }

    /* Evidenziazione pilota appena passato */
    .table-live tbody tr.pilot-highlight {
        background-color: #fff3cd !important;
        border: 2px solid #ffc107 !important;
        box-shadow: 0 0 15px rgba(255, 193, 7, 0.5) !important;
        animation: pulseHighlight 0.5s ease-in-out;
    }

@keyframes pulseHighlight {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.01); }
}

/* Indicatore di aggiornamento */
.update-indicator {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    background-color: #28a745;
    color: white;
    border-radius: 8px;
    display: none;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    font-size: 1em;
    font-weight: 500;
    max-width: 90%;
}

    .update-indicator .pilot-name {
        font-weight: bold;
        display: block;
        margin-top: 5px;
        font-size: 1.1em;
    }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }

    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

.update-indicator.hiding {
    animation: slideOut 0.3s ease-in;
}

/* Desktop: nascondi vista mobile */
.desktop-only {
    display: block;
}

.mobile-card-view {
    display: none;
}

/* ========================================
   STILI SPECIFICI GIMKANA - CRONOMETRO
   ======================================== */

.pilot-in-race {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: none;
    border: 2px solid #dee2e6;
}

    .pilot-in-race.active {
        display: block;
        animation: fadeIn 0.3s ease-out;
    }

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pilot-in-race-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #dee2e6;
}

.pilot-in-race-title {
    font-size: 0.9em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .pilot-in-race-title .live-dot {
        display: inline-block;
        width: 12px;
        height: 12px;
        background-color: #28a745;
        border-radius: 50%;
        animation: blink 1.5s infinite;
    }

.pilot-in-race-manche {
    background-color: #e9ecef;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 600;
    color: #495057;
}

.pilot-in-race-body {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 30px;
    align-items: center;
}

.pilot-in-race-number-section {
    text-align: center;
    padding: 0 20px;
}

.pilot-in-race-number-label {
    display: block;
    color: #666;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.pilot-in-race-number {
    font-size: 5em;
    font-weight: 900;
    line-height: 1;
    color: #007bff;
    font-family: 'Arial Black', sans-serif;
}

.pilot-in-race-details {
    flex: 1;
    padding: 0 20px;
    border-left: 3px solid #007bff;
}

.pilot-in-race-name {
    font-size: 3em;
    font-weight: 700;
    line-height: 1.2;
    color: #212529;
    margin-bottom: 5px;
}

.pilot-in-race-subtitle {
    font-size: 1em;
    color: #6c757d;
    font-weight: 500;
}

.pilot-in-race-timer-section {
    text-align: right;
    padding: 0 20px;
}

.pilot-in-race-timer-label {
    display: block;
    color: #666;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    font-weight: 600;
}

.pilot-in-race-time {
    font-size: 4.5em;
    font-weight: 900;
    font-family: 'Courier New', monospace;
    line-height: 1;
    color: #28a745;
}

/* Griglia tempi controlli - Regolarità */
.pilot-in-race-regularity {
    grid-template-columns: auto 1fr;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
    margin-top: 15px;
}

.control-time-item {
    background-color: #e9ecef;
    padding: 10px;
    border-radius: 6px;
    text-align: center;
    transition: all 0.3s ease;
}

.control-time-item.control-active {
    background-color: #28a745;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.5);
}

.control-label {
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
    color: #666;
}

.control-time-item.control-active .control-label {
    color: white;
}

.control-time {
    font-size: 1.2em;
    font-weight: 900;
    font-family: 'Courier New', monospace;
    color: #212529;
}

.control-time-item.control-active .control-time {
    color: white;
}

.control-delta {
    font-size: 0.9em;
    font-weight: 700;
    margin-top: 4px;
    font-family: 'Courier New', monospace;
}

@media screen and (max-width: 1200px) {
    .pilot-in-race-body {
        grid-template-columns: 1fr;
        gap: 20px;
        text-align: center;
    }

    .pilot-in-race-details {
        border-left: none;
        border-top: 3px solid #007bff;
        padding: 20px 0 0 0;
    }

    .pilot-in-race-number {
        font-size: 4em;
    }

    .pilot-in-race-name {
        font-size: 2.2em;
    }

    .pilot-in-race-time {
        font-size: 3.5em;
    }

    .pilot-in-race-timer-section {
        text-align: center;
        padding: 0;
    }

    .pilot-in-race-number-section {
        padding: 0;
    }
}

@media screen and (max-width: 768px) {
    h1 {
        font-size: 1.5em;
    }

    .race-info {
        grid-template-columns: 1fr;
    }

    /* Mobile: nascondi desktop, mostra mobile */
    .desktop-only {
        display: none !important;
    }

    .table-container {
        display: none !important;
    }

    .mobile-card-view {
        display: block !important;
    }

    /* Cronometro mobile */
    .pilot-in-race {
        padding: 15px;
    }

    .pilot-in-race-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .pilot-in-race-number {
        font-size: 3em;
    }

    .pilot-in-race-name {
        font-size: 1.8em;
    }

    .pilot-in-race-time {
        font-size: 2.5em;
    }

    /* Card pilota */
    .pilot-card {
        background: #fff;
        border: 1px solid #ddd;
        border-radius: 8px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    /* ✅ EVIDENZIAZIONE CARD MOBILE - DEVE ESSERE QUI DENTRO */
    .pilot-card.pilot-highlight {
        background-color: #fff3cd !important;
        border: 3px solid #ffc107 !important;
        box-shadow: 0 0 20px rgba(255, 193, 7, 0.6) !important;
        animation: pulseHighlight 0.5s ease-in-out;
    }

    .pilot-card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 10px;
        padding-bottom: 10px;
        border-bottom: 2px solid #FAA500;
    }

        .pilot-card-header .position {
            font-size: 1.5em;
            font-weight: bold;
            color: #FAA500;
            min-width: 40px;
        }

        .pilot-card-header .pilot-info {
            flex: 1;
            margin: 0 10px;
        }

            .pilot-card-header .pilot-info .pilot-name {
                font-weight: bold;
                font-size: 1.1em;
                color: #333;
                display: block;
                margin-bottom: 3px;
                text-decoration: none;
            }

            .pilot-card-header .pilot-info .pilot-number {
                color: #666;
                font-size: 1.2em;
                font-weight: bold;
            }

        .pilot-card-header .total-score {
            font-size: 1.3em;
            font-weight: bold;
            color: #28a745;
        }

    .pilot-info-details {
        margin-bottom: 12px;
    }

    .info-row {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #ddd;
    }

        .info-row .label {
            font-weight: 600;
            color: #333;
        }

        .info-row .value {
            font-weight: 500;
            text-align: right;
        }

    /* Sezioni manche */
    .manches-grid {
        display: grid;
        gap: 10px;
        margin-bottom: 10px;
    }

    .manche-section {
        background-color: darkgrey;
        padding: 12px;
        border-radius: 4px;
        margin-bottom: 12px;
        border: 1px solid #000;
    }

    .manche-section-header {
        font-weight: bold;
        color: #FAA500;
        margin-bottom: 8px;
        font-size: 1em;
    }

    .manche-details {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
        gap: 8px;
    }

    .control-item {
        text-align: center;
        padding: 8px;
        background-color: #fff;
        border-radius: 3px;
        border: 1px solid #000;
    }

        .control-item label {
            display: block;
            font-size: 0.85em;
            color: #333;
            margin-bottom: 4px;
            font-weight: 600;
        }

        .control-item .value {
            font-weight: bold;
            font-size: 0.95em;
        }

    .manche-totals {
        display: flex;
        justify-content: space-around;
        padding-top: 8px;
        border-top: 1px solid #dee2e6;
        font-size: 0.9em;
    }

        .manche-totals .total-item {
            text-align: center;
        }

            .manche-totals .total-item label {
                display: block;
                font-size: 0.8em;
                color: #6c757d;
                margin-bottom: 2px;
            }

            .manche-totals .total-item .value {
                font-weight: bold;
            }

    .extra-total-section {
        background-color: #fff3cd;
        padding: 8px;
        border-radius: 4px;
        text-align: center;
        font-size: 0.9em;
    }

        .extra-total-section label {
            display: block;
            color: #856404;
            font-size: 0.85em;
            margin-bottom: 3px;
        }

        .extra-total-section .value {
            font-weight: bold;
            color: #856404;
            font-size: 1.1em;
        }

    .best-time-section {
        display: flex;
        justify-content: space-between;
        padding: 12px;
        background-color: #FAA500;
        border-radius: 4px;
        font-weight: bold;
        margin-top: 8px;
        border: 1px solid #000;
    }

        .best-time-section .label {
            color: #000;
        }

        .best-time-section .value {
            color: #000;
            font-size: 1.1em;
        }

    .update-indicator {
        top: 10px;
        right: 10px;
        left: 10px;
        text-align: center;
        font-size: 0.9em;
        padding: 12px 15px;
    }
}

/* Penalità e squalifica nel cronometro live */
.pilot-in-race-penalty {
    margin-top: 15px;
    padding: 10px 15px;
    background-color: #fff3cd;
    border: 2px solid #ffc107;
    border-radius: 6px;
    text-align: center;
    font-size: 1.2em;
}

.pilot-in-race-penalty .penalty-label {
    color: #856404;
    font-weight: 600;
    margin-right: 8px;
}

.pilot-in-race-penalty .penalty-value {
    color: #856404;
    font-weight: 900;
    font-size: 1.4em;
}

.pilot-in-race-disqualified {
    margin-top: 15px;
    padding: 15px 20px;
    background-color: #dc3545;
    color: white;
    border: 3px solid #a71d2a;
    border-radius: 8px;
    text-align: center;
    font-size: 1.8em;
    font-weight: 900;
    letter-spacing: 2px;
    animation: pulseRed 1.5s infinite;
    box-shadow: 0 0 20px rgba(220, 53, 69, 0.6);
}

@keyframes pulseRed {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 20px rgba(220, 53, 69, 0.6);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(220, 53, 69, 0.9);
    }
}

@media screen and (max-width: 768px) {
    .pilot-in-race-penalty {
        font-size: 1em;
    }
    
    .pilot-in-race-penalty .penalty-value {
        font-size: 1.2em;
    }
    
    .pilot-in-race-disqualified {
        font-size: 1.4em;
        padding: 12px 15px;
    }
}

/* ========================================
   FILTRO CATEGORIA E LEGENDA CLASSI
   ======================================== */

.filter-and-legend-container {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
}

.filter-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
}

.filter-section label {
    display: block;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    font-size: 1em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-section select {
    width: 100%;
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #ced4da;
    border-radius: 6px;
    background-color: #fff;
    color: #495057;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-section select:hover {
    border-color: #007bff;
}

.filter-section select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.class-legend {
    background-color: transparent;
}

.class-legend h3 {
    font-size: 1em;
    font-weight: 600;
    color: #495057;
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.class-legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.class-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background-color: #fff;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease;
}

.class-legend-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.class-legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px #dee2e6;
    flex-shrink: 0;
}

.class-legend-item span {
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
}

/* Responsive per filtro e legenda */
@media screen and (max-width: 768px) {
    .filter-and-legend-container {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .filter-section {
        margin-bottom: 15px;
        padding-bottom: 15px;
    }
    
    .class-legend-items {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .class-legend-item {
        padding: 6px 10px;
    }
    
    .class-legend h3 {
        font-size: 0.9em;
    }
}
