/* ══════════════════════════════════════════
   CPALTracker — Styles principaux
   ══════════════════════════════════════════ */

:root {
    --primary:       #1A237E;
    --primary-hover: #303F9F;
    --bg:            #f5f5f5;
    --white:         #ffffff;
    --border:        #ddd;
    --text:          #333;
    --error:         #c62828;
    --success:       #2e7d32;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
}

/* ── Layout principal ── */
.container {
    display: flex;
    height: 100vh;
}

/* ── Panneau latéral (formulaire) ── */
.form-section {
    width: 320px;
    min-width: 280px;
    background: var(--white);
    padding: 24px;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.form-section h1 {
    color: var(--primary);
    font-size: 1.3rem;
    margin: 0 0 20px 0;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

select, input[type="number"] {
    padding: 8px 10px;
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.15);
}

button {
    padding: 10px 16px;
    width: 100%;
    border: none;
    border-radius: 6px;
    background-color: var(--primary);
    color: var(--white);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--primary-hover);
}

/* ── Radio buttons ── */
.radio-group {
    display: flex;
    gap: 16px;
    margin-top: 4px;
}

.radio-group label {
    display: inline;
    font-weight: normal;
    cursor: pointer;
}

.radio-group input[type="radio"] {
    width: auto;
    margin-right: 4px;
    cursor: pointer;
}

/* ── Messages d'erreur / info ── */
.msg-error {
    color: var(--error);
    background: #ffebee;
    border: 1px solid #ef9a9a;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

.msg-info {
    color: var(--primary);
    background: #e8eaf6;
    border: 1px solid #9fa8da;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}

/* ── Zone de résultats ── */
.results-section {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    position: relative;
}

.results-section h2 {
    color: var(--primary);
    margin-top: 0;
}

/* ── Carte Leaflet ── */
#map {
    width: 100%;
    height: calc(100vh - 48px);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.map-controls {
    position: absolute;
    top: 36px;
    right: 36px;
    z-index: 1000;
}

.map-controls button {
    width: auto;
    padding: 8px 14px;
    font-size: 0.85rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.legend {
    position: absolute;
    bottom: 36px;
    right: 36px;
    background: var(--white);
    padding: 14px 18px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    font-size: 0.85rem;
}

.legend h4 {
    margin: 0 0 8px 0;
    color: var(--primary);
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.legend-color {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    margin-right: 8px;
    border: 1px solid #ccc;
}

/* ── Tableau de données ── */
.data-table-wrapper {
    overflow-x: auto;
    margin-top: 16px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
}

th {
    background-color: var(--primary);
    color: var(--white);
    font-weight: 600;
    position: sticky;
    top: 0;
}

tr:nth-child(even) {
    background-color: #f5f7ff;
}

tr:hover {
    background-color: #e8eaf6;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination a, .pagination span {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    text-decoration: none;
    color: var(--primary);
    font-size: 0.9rem;
}

.pagination span.current {
    background-color: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

.pagination a:hover {
    background-color: #e8eaf6;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
    }
    .form-section {
        width: 100%;
        min-width: unset;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    }
    #map {
        height: 400px;
    }
}

/* ══════════════════════════════════════════
   Carte à curseur temporel + Tableau de bord
   Ajouté le 2026-08-02
   ══════════════════════════════════════════ */

/* ── Marqueur : anneau = device, remplissage = masse ── */
.tl-pin {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid #1A237E;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    font-size: 11px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* ── Étiquette au survol ── */
.leaflet-tooltip.tl-tooltip {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
    padding: 0;
    white-space: normal;
    max-width: 320px;
}
.leaflet-tooltip.tl-tooltip::before { display: none; }

.tl-tip-head {
    color: var(--white);
    font-weight: 600;
    padding: 7px 12px;
    border-radius: 7px 7px 0 0;
    font-size: 0.88rem;
}
.tl-tip table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.tl-tip th, .tl-tip td {
    border: none;
    border-bottom: 1px solid #f0f0f0;
    padding: 4px 12px;
    text-align: left;
    white-space: nowrap;
}
.tl-tip th { color: #666; font-weight: 600; }
.tl-tip tr:last-child th, .tl-tip tr:last-child td { border-bottom: none; }

/* ── Curseur temporel ── */
.curseur {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 4px 14px 4px;
    flex-wrap: wrap;
}
.curseur input[type="range"] {
    flex: 1;
    min-width: 200px;
    accent-color: var(--primary);
    cursor: pointer;
}
.curseur input[type="range"]:disabled { cursor: not-allowed; opacity: 0.4; }

.curseur-borne { font-size: 0.75rem; color: #888; white-space: nowrap; }

.curseur-valeur {
    font-family: 'Consolas', 'Menlo', monospace;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--primary);
    background: #e8eaf6;
    padding: 5px 12px;
    border-radius: 6px;
    white-space: nowrap;
}

/* ── Légende du code couleur de masse ── */
.legende-masse {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-top: 12px;
    font-size: 0.82rem;
    color: #555;
}
.legende-masse span { display: flex; align-items: center; gap: 7px; }

.pastille {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
    display: inline-block;
}

/* ── Mise en page du tableau de bord ── */
.dashboard-main { display: flex; flex-direction: column; gap: 22px; }

.panneau {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 18px 20px 20px 20px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.panneau-titre {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.panneau-titre h2 { margin: 0; font-size: 1.05rem; }

.panneau-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn-mini {
    width: auto;
    margin-top: 0;
    padding: 6px 13px;
    font-size: 0.82rem;
}

.case {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    font-size: 0.85rem;
    margin: 0;
    cursor: pointer;
}
.case input { width: auto; cursor: pointer; }

.carte-dashboard {
    width: 100%;
    height: 480px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.graphe { height: 440px; margin-top: 10px; }

/* ── Sélecteur de devices ── */
.device-actions {
    display: flex;
    gap: 14px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}
.device-actions a { color: var(--primary); text-decoration: none; }
.device-actions a:hover { text-decoration: underline; }

.device-list {
    border: 1px solid var(--border);
    border-radius: 6px;
    max-height: 260px;
    overflow-y: auto;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 11px;
    margin: 0;
    font-weight: normal;
    font-size: 0.85rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.device-item:last-child { border-bottom: none; }
.device-item:hover { background: #f5f7ff; }
.device-item input { width: auto; cursor: pointer; }

.device-puce { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.device-nom  { flex: 1; font-family: 'Consolas', 'Menlo', monospace; font-size: 0.8rem; }

.device-compte {
    color: #888;
    font-size: 0.75rem;
    background: #f0f0f0;
    padding: 1px 7px;
    border-radius: 9px;
}

.device-vide { display: block; padding: 12px; color: #888; font-size: 0.85rem; }

/* ── Encart de synthèse ── */
.resume {
    margin-top: 22px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.resume h3 { margin: 0 0 10px 0; font-size: 0.88rem; color: var(--primary); }

.resume-ligne {
    display: flex;
    justify-content: space-between;
    font-size: 0.83rem;
    padding: 4px 0;
}
.resume-ligne span { color: #666; }

/* ── Boutons de navigation ── */
.btn-retour, .btn-dashboard {
    display: block;
    text-align: center;
    text-decoration: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.btn-retour {
    background: #e8eaf6;
    color: var(--primary);
    border: 1px solid #c5cae9;
}
.btn-retour:hover { background: #c5cae9; }

.btn-dashboard {
    background: var(--success);
    color: var(--white);
    margin-top: 8px;
    margin-bottom: 0;
}
.btn-dashboard:hover { background: #1b5e20; }

@media (max-width: 768px) {
    .carte-dashboard { height: 340px; }
    .graphe { height: 300px; }
}

/* ══════════════════════════════════════════
   Logo c-PAL (bandeau gauche), titre + logo
   client (zone centrale), messages
   Ajouté le 2026-08-28
   ══════════════════════════════════════════ */

/* ── Logo c-PAL, en haut du bandeau latéral ── */
.cpal-logo-sidebar {
    display: flex;
    justify-content: center;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.cpal-logo-icone {
    height: 48px;
    width: auto;
}

/* ── Titre, seul, en haut de la zone centrale ── */
.cpal-titre {
    margin: 0 0 16px 0;
    color: var(--primary);
    font-size: 1.7rem;
}

/* ── Logo du client connecté, dans la zone centrale ── */
.logo-client {
    display: flex;
    justify-content: flex-start;
    padding-bottom: 16px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.logo-client img {
    max-width: 220px;
    max-height: 80px;
    object-fit: contain;
}

/* ── Messages / annonces (globaux ou par contrat) ── */
.msg-annonce {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: #fff8e1;
    border: 1px solid #ffe082;
    color: #6d4c00;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.87rem;
}
.msg-annonce i { margin-top: 2px; color: #f9a825; }
.msg-annonce-date {
    font-size: 0.75rem;
    color: #8d6e00;
    margin-bottom: 2px;
}
.msg-annonce-texte { white-space: pre-line; }

@media (max-width: 768px) {
    .cpal-logo-icone { height: 40px; }
    .cpal-titre { font-size: 1.3rem; }
}
