:root {
    --bg-dark: #1b1642;
    --panel-bg: #272252;
    --panel-border: #38316e;
    --tisseo-pink: #e63967;
    --tisseo-pink-hover: #c82954;
    --text-white: #ffffff;
    --text-dark: #222222;
    --text-muted: #a39ebc;
    --input-bg: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-white);
    margin: 0;
    padding: 20px;
}

/* --- CONTENEUR ET PANNEAUX --- */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    max-width: 1300px;
    margin: 0 auto;
}

.board, .panel {
    background: var(--panel-bg);
    border-radius: 16px;
    padding: 25px;
    border: 1px solid var(--panel-border);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    min-width: 0; /* Essentiel pour empêcher le contenu interne (tableaux) d'élargir l'écran */
}

.board {
    max-width: 1400px;
    margin: 0 auto;
}

/* --- TITRES --- */
h1, h2 {
    color: var(--text-white);
    margin-top: 0;
}

h2 {
    font-size: 1.5em;
    background: var(--tisseo-pink);
    margin: -25px -25px 20px -25px;
    padding: 18px 25px;
    border-top-left-radius: 15px;
    border-top-right-radius: 15px;
    text-align: center;
}

/* --- EN-TÊTE PANNEAU DÉPART --- */
.header {
    display: flex;
    flex-wrap: wrap; /* Permet le passage à la ligne sur petit écran */
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    border-bottom: 3px solid var(--tisseo-pink);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.header h1 {
    margin-bottom: 0;
    word-break: break-word;
    flex: 1;
    min-width: 200px;
}

.clock {
    font-size: 2.2em;
    font-weight: bold;
    color: var(--tisseo-pink);
    font-family: monospace;
}

/* --- INPUTS & RECHERCHE --- */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
}

input[type="text"] {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 30px;
    font-size: 1em;
    background: var(--input-bg);
    color: var(--text-dark);
    outline: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15);
}

input[type="text"]::placeholder {
    color: #888;
}

input[type="text"]:focus {
    box-shadow: 0 0 0 3px rgba(230, 57, 103, 0.4);
}

.stop-list {
    list-style: none;
    padding: 0;
    margin: 8px 0 0 0;
    background: var(--input-bg);
    color: var(--text-dark);
    border-radius: 12px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
}

.stop-list li {
    padding: 12px 20px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
}

.stop-list li:hover {
    background: var(--tisseo-pink);
    color: white;
}

/* --- TABLEAUX --- */
.table-wrapper {
    width: 100%;
    overflow-x: auto; /* Protège des dépassements si un nom d'arrêt est trop long */
    -webkit-overflow-scrolling: touch;
}

.board-table, .arrival-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 300px; /* Assure un minimum de lisibilité avant de scroller horizontalement */
}

.board-table th, .arrival-table th {
    text-align: left;
    padding: 14px 15px;
    color: var(--text-muted);
    font-size: 0.9em;
    text-transform: uppercase;
    border-bottom: 2px solid var(--panel-border);
}

.board-table td, .arrival-table td {
    padding: 16px 15px;
    border-bottom: 1px solid var(--panel-border);
    word-break: break-word; /* Évite que les noms à rallonge ne déforment le tableau */
}

.board-table td {
    font-size: 1.4em;
    font-weight: 500;
}

.time-col {
    font-weight: bold;
    font-family: monospace;
}

/* --- BADGES & BOUTONS --- */
.badge {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: bold;
    display: inline-block;
    text-align: center;
}

/* --- LIENS GLOBAUX --- */
a {
    color: var(--tisseo-pink); /* Utilise la couleur rose de Tisséo pour les liens par défaut */
    text-decoration: none; /* Enlève le soulignement par défaut */
    transition: color 0.2s ease, text-decoration 0.2s ease; /* Transition douce pour le survol */
}

a:hover {
    color: var(--tisseo-pink-hover); /* Change légèrement la couleur au survol */
    text-decoration: underline; /* Ajoute un soulignement au survol pour plus de clarté */
}

/* S'assurer que le bouton d'affichage (qui est aussi un lien <a>) conserve son propre style et ne prend pas le style des liens par défaut */
.btn-display {
    display: block;
    width: 100%;
    text-align: center;
    margin-bottom: 20px;
    padding: 14px;
    background: var(--tisseo-pink);
    color: white !important; /* Force la couleur blanche, même si <a> global dit rose */
    text-decoration: none !important; /* Force l'absence de soulignement au survol */
    border-radius: 30px;
    font-weight: bold;
    transition: background 0.2s, transform 0.1s;
    box-shadow: 0 4px 12px rgba(230, 57, 103, 0.3);
}

.btn-display:hover {
    background: var(--tisseo-pink-hover);
    transform: translateY(-1px);
    color: white !important; /* Maintient le blanc au survol */
    text-decoration: none !important; /* Empêche le soulignement d'apparaître */
}

/* Optionnel : Styliser les liens à l'intérieur des détails/alertes (s'il y en a) pour qu'ils soient plus visibles sur le fond sombre */
.details-content a {
     color: #ff8fa3; /* Un rose plus clair pour ressortir sur le gris foncé/noir */
     text-decoration: underline; /* Souligne par défaut dans le texte pour qu'on comprenne que c'est cliquable */
}

.details-content a:hover {
    color: white;
}

.stop-delay, .delay {
    color: #ff5252;
    font-weight: bold;
    font-size: 0.85em;
    margin-left: 8px;
    white-space: nowrap; /* Empêche le "+1m" d'être coupé bizarrement en 2 lignes */
}

/* --- INFO TRAFIC / DETAILS --- */
details {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    margin-bottom: 12px;
    overflow: hidden;
}

details[open] {
    border-color: var(--tisseo-pink);
}

summary {
    padding: 14px 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

summary > div {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap; /* Le badge et le texte peuvent passer à la ligne proprement */
}

summary:hover {
    background: rgba(255, 255, 255, 0.08);
}

summary::-webkit-details-marker {
    display: none;
}

summary::after {
    content: "►";
    font-size: 0.8em;
    color: var(--text-muted);
    transition: transform 0.2s;
}

details[open] summary::after {
    transform: rotate(90deg);
}

.details-content {
    padding: 15px 18px;
    border-top: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.2);
    line-height: 1.5;
}

.details-content a {
     color: #ff8fa3; /* Un rose plus clair pour ressortir sur le gris foncé/noir */
     text-decoration: underline; /* Souligne par défaut dans le texte pour qu'on comprenne que c'est cliquable */
}

.details-content a:hover {
    color: white;
}

/* --- MODE MOBILE --- */
@media (max-width: 900px) {
    body {
        padding: 10px;
    }

    .container {
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    /* Ordre de la grille sur mobile : La recherche passe EN HAUT (1), Trafic (2) */
    .panel-search {
        order: 1;
    }
    .panel-trafic {
        order: 2;
    }

    .board, .panel {
        padding: 15px;
    }

    /* Le bandeau h2 s'adapte au nouveau padding réduit du panel */
    h2 {
        margin: -15px -15px 15px -15px;
        padding: 15px;
        font-size: 1.3em;
    }

    .header h1 {
        font-size: 1.5em;
    }

    .clock {
        font-size: 1.6em;
    }

    /* Réduction des tableaux et marges pour ne rien décentrer */
    .board-table th, .arrival-table th {
        padding: 10px 5px;
        font-size: 0.8em;
    }

    .board-table td, .arrival-table td {
        padding: 12px 5px;
        font-size: 1em;
    }
    
    .board-table td {
        font-size: 1.1em;
    }

    .badge {
        padding: 4px 8px;
        font-size: 0.75em;
    }
    
    summary {
        padding: 12px;
        font-size: 0.95em;
    }
}