/* === STYLES CSS === */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.conteneur_principal {
    max-width: calc(100vw - 20px);
    margin: 0 auto;
    padding: 10px;
}

.titre_principal {
    text-align: center;
    color: white;
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.panneau_controles {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.section_acces_rapide {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.titre_section {
    font-size: 1.3rem;
    margin-bottom: 15px;
    color: #444;
    font-weight: 600;
}

.boutons_rapides {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.btn_rapide {
    background: linear-gradient(45deg, #2E86AB, #4fa8d8);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(46, 134, 171, 0.3);
}

.btn_rapide:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(46, 134, 171, 0.4);
}

.btn_jour_precedent {
    background: linear-gradient(45deg, #A23B72, #c4527a);
    box-shadow: 0 4px 15px rgba(162, 59, 114, 0.3);
}

.btn_jour_precedent:hover {
    box-shadow: 0 6px 20px rgba(162, 59, 114, 0.4);
}

.section_personnalise {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.groupe_champs {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.label_champ {
    font-weight: 600;
    color: #555;
}

.conteneur_date_heure {
    display: flex;
    gap: 10px;
}

.champ_saisie {
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    flex: 1;
}

.champ_saisie:focus {
    outline: none;
    border-color: #2E86AB;
    box-shadow: 0 0 0 3px rgba(46, 134, 171, 0.1);
}

.btn_valider {
    grid-column: 1 / -1;
    background: linear-gradient(45deg, #F18F01, #ffa726);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(241, 143, 1, 0.3);
}

.btn_valider:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(241, 143, 1, 0.4);
}

.panneau_graphique {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    position: relative;
}

.conteneur_canvas {
    position: relative;
    height: 400px;
    overflow: hidden;
}

#graphique_stats {
    width: 100%;
    height: 100%;
}

.popup_attente {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.contenu_popup {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2E86AB;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.info_stats {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding: 15px;
    background: rgba(46, 134, 171, 0.1);
    border-radius: 10px;
    font-weight: 600;
    flex-wrap: wrap;
    gap: 10px;
}

.controles_zoom {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn_zoom {
    background: linear-gradient(45deg, #6c5ce7, #a29bfe);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.btn_zoom:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.btn_zoom:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.navigation_temporelle {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(245, 245, 245, 0.8);
    border-radius: 10px;
}

.btn_navigation_temps {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
    font-size: 1rem;
}

.btn_navigation_temps:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.4);
}

.btn_navigation_temps:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.navigation_emissions {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(245, 245, 245, 0.8);
    border-radius: 10px;
}

.btn_navigation {
    background: linear-gradient(45deg, #e17055, #fdcb6e);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.btn_navigation:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(225, 112, 85, 0.4);
}

.panneau_analyse {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 15px;
    padding: 25px;
    margin-top: 25px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.tableau_analyse {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.tableau_analyse th,
.tableau_analyse td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.tableau_analyse th {
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.tableau_analyse th:hover {
    background: linear-gradient(45deg, #5a6de8, #6b47a0);
}

.tableau_analyse th.sortable::after {
    content: ' ↕';
    opacity: 0.5;
}

.tableau_analyse th.sort-asc::after {
    content: ' ↑';
    opacity: 1;
}

.tableau_analyse th.sort-desc::after {
    content: ' ↓';
    opacity: 1;
}

.tableau_analyse tr:hover {
    background: rgba(46, 134, 171, 0.05);
}

#message_aucune_donnee {
    text-align: center;
    padding: 60px 20px;
    background: rgba(255, 193, 7, 0.1);
    border: 2px dashed #ffc107;
    border-radius: 15px;
    font-size: 1.2rem;
    color: #856404;
    margin: 20px 0;
}

/* Emissions timeline */
.emissions-timeline {
    margin: 15px 25px 10px 25px;
    padding: 10px 0;
    border-top: 2px solid #f0f0f0;
    position: relative;
    min-height: 30px;
}

.emission-barre {
    position: absolute;
    height: 20px;
    border-radius: 10px;
    border: 2px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: white;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.7);
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.emission-barre:hover {
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transform: translateY(-1px);
}

.emission-nom {
    padding: 0 5px;
    text-overflow: ellipsis;
    overflow: hidden;
}

/* Grille des graphiques multiples */
.graphiques_multiples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.graphique_emission {
    background: white;
    border-radius: 10px;
    padding: 15px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.graphique_emission h4 {
    margin-bottom: 10px;
    color: #444;
    font-size: 0.9rem;
}

.graphique_emission canvas {
    height: 200px !important;
}

/* === STYLES RESPONSIVES === */
@media (max-width: 768px) {
    .conteneur_principal {
        max-width: calc(100vw - 10px);
        padding: 5px;
    }

    .titre_principal {
        font-size: 2rem;
        margin-bottom: 20px;
    }

    .panneau_controles,
    .panneau_graphique,
    .panneau_analyse {
        padding: 15px;
        margin-bottom: 15px;
    }

    .section_personnalise {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .conteneur_date_heure {
        flex-direction: column;
        gap: 8px;
    }

    .boutons_rapides {
        flex-direction: column;
        gap: 8px;
    }

    .btn_rapide {
        width: 100%;
        text-align: center;
        padding: 10px 15px;
    }

    .info_stats {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .info_stats>div {
        padding: 5px 0;
    }

    .navigation_temporelle {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .btn_navigation_temps {
        width: 100%;
        padding: 10px 15px;
    }

    .navigation_emissions {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }

    .btn_navigation {
        width: 100%;
        padding: 10px 15px;
    }

    .controles_zoom {
        justify-content: center;
    }

    .graphiques_multiples {
        grid-template-columns: 1fr;
    }

    .conteneur_canvas {
        height: 300px;
    }

    .groupe_emissions {
        margin-bottom: 10px !important;
    }

    .champ_saisie {
        padding: 10px 12px;
        font-size: 16px;
        /* Évite le zoom sur iOS */
    }

    .titre_section {
        font-size: 1.1rem;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .titre_principal {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    .panneau_controles,
    .panneau_graphique,
    .panneau_analyse {
        padding: 10px;
        margin-bottom: 10px;
    }

    .conteneur_canvas {
        height: 250px;
    }

    .btn_valider {
        padding: 12px 20px;
        font-size: 1rem;
    }

    .tableau_analyse th,
    .tableau_analyse td {
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .info_stats {
        font-size: 0.9rem;
    }
}

/* Styles spéciaux pour éviter les débordements */
body {
    overflow-x: hidden;
}

.conteneur_principal {
    width: 100%;
    overflow-x: hidden;
}

.panneau_controles,
.panneau_graphique,
.panneau_analyse {
    width: 100%;
    overflow-x: hidden;
}

.tableau_analyse {
    overflow-x: auto;
    display: block;
    white-space: nowrap;
}

.tableau_analyse thead,
.tableau_analyse tbody,
.tableau_analyse tr {
    display: table;
    width: 100%;
    table-layout: fixed;
}

@media (max-width: 768px) {
    .tableau_analyse {
        font-size: 0.8rem;
    }

    .tableau_analyse th,
    .tableau_analyse td {
        padding: 6px 8px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}