/**
 * Nom du fichier : map.css
 * Chemin         : /var/www/html/analyses/assets/css/map.css
 *
 * Description :
 *  Styles globaux de la page "analyses" :
 *   - couleurs
 *   - panneaux
 *   - carte SVG + overlay + slider
 *   - tableau d'analyses
 *
 * Auteur        : Sylvain SCATTOLINI
 * Date création : 27/11/2025
 * Date modif.   : 27/11/2025
 * Version       : 1.0
 */

:root {
    --color-page-bg: #f5f5f5;
    --color-text-main: #333333;

    --color-panel-bg: #ffffff;
    --color-panel-border: #dddddd;

    --color-mer: #3a7bd5;          /* bleu moyen pour le fond de la carte */
    --color-terre-fill: #abd97b;   /* vert terres */
    --color-terre-stroke: #4c5a39;

    --color-zone-fill: #aecaff;    /* zones */
    --color-zone-stroke: #184063;

    --color-site-fill: #fee13b;    /* sites neutres */
    --color-site-stroke: #574d14;

    --color-error: #b00020;
}

html, body {
    margin: 0;
    height: 100%;
}
body {
    min-height: 100vh;
}

.layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--color-page-bg);
    color: var(--color-text-main);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.layout-top {
    display: flex;
    position: relative;
    box-sizing: border-box;
    padding: 0.5rem;
    gap: 0;
    height: 67vh; /* ~67% par défaut, le reste pour la synthèse */
    min-height: 0;
}

.layout-bottom {
    box-sizing: border-box;
    padding: 0.5rem;
    min-height: 0;
    height: 33vh; /* ~33% par défaut */
}

.top-left,
.top-right {
    display: flex;
    min-width: 0;
    min-height: 0;
}

.top-left {
    width: 34%;
}
.top-right {
    width: 66%;
}

.panel {
    width: 100%;
    height: 100%;
}

/* Splitters */
.layout-splitter-horizontal {
    height: 4px;
    cursor: row-resize;
    background: var(--color-panel-border);
}

.layout-splitter-vertical {
    width: 4px;
    cursor: col-resize;
    background: var(--color-panel-border);
    margin: 0 0.4rem;
}

.slider-tooltip {
    padding: 2px 6px;
    background: #333;
    color: #fff;
    font-size: 0.75rem;
    border-radius: 4px;
    white-space: nowrap;
}

/* Panneaux génériques */
.panel {
    background: var(--color-panel-bg);
    border: 1px solid var(--color-panel-border);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    box-sizing: border-box;
}

/* Carte */
.map-panel {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    box-sizing: border-box;
    min-height: 0;
}

.map-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 4px;
    overflow: hidden;
    background: var(--color-mer);
    position: relative;
}

.map-inner {
    width: 100%;
    height: 100%;
    min-height: 0;
}

.map-bottom-controls {
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.map-bottom-controls input[type="range"] {
    flex: 1;
    width: 100%;
}

/* SVG plein container */
.map-inner svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Debug panel (cartouche) */
.debug-panel {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(255,255,255,0.9);
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    max-width: 260px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);

    /* Stabilisation de la taille */
    width: 260px;        /* largeur fixe */
    min-height: 200px;   /* hauteur mini pour éviter les sauts */
    box-sizing: border-box;
}

.debug-panel > div {
    margin-bottom: 0.15rem;
}

.debug-panel > div:last-child {
    margin-bottom: 0;
}

#dbg-analyses {
    margin-top: 0.25rem;
    min-height: 70px;    /* espace réservé pour le mini-tableau */
}

.map-legend {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
    font-size: 0.75rem;
    z-index: 10;
}

.map-legend-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
    text-align: left;
}

.map-legend-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.map-legend-list li {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0.1rem 0;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.legend-label {
    white-space: nowrap;
}

/* Sélection visuelle sur la carte */
#sites path.is-selected,
#sites polygon.is-selected,
#sites polyline.is-selected {
    stroke-width: 0.5;
    stroke: #000000;
}

#zones path.is-selected,
#zones polygon.is-selected,
#zones polyline.is-selected {
    stroke-width: 1;
    stroke: #000000;
}

.map-legend {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.map-legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.map-legend-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.legend-section {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.legend-color {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.2);
}

/* Admin */
.legend-admin-open  { background: #4caf50; }
.legend-admin-closed{ background: #e53935; }

/* Plans */
.legend-plan-A  { background: #00B8FB; }
.legend-plan-B1 { background: #7453F9; }
.legend-plan-B2 { background: #BA85FB; }
.legend-plan-B3 { background: #E353FA; }
.legend-plan-CC { background: #D00777; }
.legend-plan-C1 { background: #FF041C; }
.legend-plan-C2 { background: #FF7523; }
.legend-plan-C3 { background: #FFB82C; }
.legend-plan-D  { background: #259576; }

/* Switch style (optionnel, à ajuster comme tu veux) */
.legend-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    font-size: 0.75rem;
}

.legend-toggle input[type="checkbox"] {
    display: none;
}

.legend-toggle-slider {
    position: relative;
    width: 32px;
    height: 16px;
    border-radius: 999px;
    background: #ccc;
    transition: background 0.2s;
}

.legend-toggle-slider::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 0 2px rgba(0,0,0,0.3);
    transition: transform 0.2s;
}

.legend-toggle input[type="checkbox"]:checked + .legend-toggle-slider {
    background: #2196f3;
}

.legend-toggle input[type="checkbox"]:checked + .legend-toggle-slider::before {
    transform: translateX(16px);
}

/* Panel analyses (gauche) */
/* Modale analyses (volet gauche) */
.analyses-modal {
    position: absolute;
    top: 10px;
    left: 10px;
    bottom: 10px0;              /* hauteur = zone haute */
    width: 640px;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    z-index: 20;
    pointer-events: none;
    border-radius: 15px;
}

.analyses-modal-inner {
    height: 100%;
    background: var(--color-panel-bg);
    border-right: 1px solid var(--color-panel-border);
    box-shadow: 4px 0 10px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
        border-radius: 15px;
}

.analyses-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.2rem 0.6rem;
    border-bottom: 1px solid var(--color-panel-border);
    background: #f0f0f0;
    border-radius: 15px 15px 0 0;
}

.analyses-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
}

.analyses-modal-close {
    border: none;
    background: transparent;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}

.analyses-modal.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

/* voir si encore utilisé */
.analyses-panel {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.analyses-panel-header {
    flex: 0 0 auto;
    margin-bottom: 0.5rem;
}

.dbg-site-select {
    font-weight: 800;
    font-size: 1.1rem;
}

.analyses-filter-form {
    font-size: 0.7rem;
}

.analyses-filter-form select {
    min-width: 220px;
}

/* Tableau d'analyses */
.analyses-table-wrapper {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    border: 1px solid #ccc;
    border-radius: 0 0 15px 15px;
    background: #ffffff;
}

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

.analyses-table thead {
    position: sticky;
    top: 0;
    background: #f0f0f0;
    z-index: 1;
}

.analyses-table th,
.analyses-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #ddd;
    text-align: center;
    white-space: nowrap;
    font-size: 0.7rem;
}

.analyses-table tr:nth-child(even) {
    background: #fafafa;
}

.analyses-table tr:nth-child(odd) {
    background: #ffffff;
}

.analyses-table .no-data {
    text-align: center;
    padding: 10px;
    font-style: italic;
}

.analyses-meta-line {
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    padding: 0.15rem 0.25rem;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 3px;
}

.analyses-meta-block {
    margin: 0.5rem 0 0.75rem;
    font-size: 0.85rem;
}

.analyses-meta-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.etat-pill {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
}

.etat-open {
    background-color: #4caf50;
}

.etat-closed {
    background-color: #e53935;
}

.plan-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.1rem 0.4rem;
    border-radius: 999px;
    background-color: rgba(0,0,0,0.04);
    font-size: 0.75rem;
}

.plan-color-box {
    display: inline-block;
    width: 0.9em;
    height: 0.9em;
    border-radius: 2px;
    border: 1px solid rgba(0,0,0,0.2);
}

.plan-code {
    font-weight: 600;
}

.analyses-meta-details > div {
    margin: 0.1rem 0;
}

.analyses-separator {
    border-top: 1px solid rgba(0,0,0,0.08);
    margin: 0.3rem 0;
}

.analyses-mini-table {
    margin-top: 0.35rem;
}

.analyses-meta-block {
    font-size: 0.8rem;
    line-height: 1.2;
}

.result-positif .resultat-cell {
    color: #b30000;
    font-weight: bold;
}

.result-negatif .resultat-cell {
    color: #006400;
    font-weight: bold;
}

/* Panel placeholder (synthèse) */
.panel-placeholder {
    padding: 0.75rem;
}

.terre-shape {
    fill: var(--color-terre-fill);
    stroke: var(--color-terre-stroke);
    stroke-width: 0.2;
}

/* Terres */
.terre path,
.terre polygon,
.terre polyline {
    fill: var(--color-terre-fill);
    stroke: var(--color-terre-stroke);
    stroke-width: 0.2;
}

/* Terres (tout ce qui n'est ni zone ni site) */


/* Zones */
#zones path,
#zones polygon,
#zones polyline {
    fill: var(--color-zone-fill);
    stroke: var(--color-zone-stroke);
    stroke-width: 0.1;
}

/* Sites */
#sites path,
#sites polygon,
#sites polyline {
    fill: var(--color-site-fill);
    stroke: var(--color-site-stroke);
    stroke-width: 0.1;
}

/* Bloc synthèse (bas de page) */

.bottom-row {
    flex: 1 1 50%;
    min-height: 0;              /* IMPORTANT pour que le scroll interne fonctionne en flex */
}

.synthese-panel {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    background: var(--color-panel-bg);
    border-radius: 6px;
    border: 1px solid var(--color-panel-border);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.synthese-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

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

/* Switch "Mode plan" */

.mode-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.85rem;
}

.mode-toggle input {
    display: none;
}

.mode-toggle .slider {
    width: 40px;
    height: 20px;
    background: #ccc;
    border-radius: 20px;
    position: relative;
    transition: background 0.2s;
}

.mode-toggle .slider::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 2px;
    left: 2px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s;
}

.mode-toggle input:checked + .slider {
    background: #0077ff;
}

.mode-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

/* Couleurs de base : état ouvert/fermé */

.synthese-table td.cell-open {
    background-color: #4caf50;
    color: #ffffff;
    text-align: center;
    font-weight: 600;
}

.synthese-table td.cell-closed {
    background-color: #e53935;
    color: #ffffff;
    text-align: center;
    font-weight: 600;
}

/* Mode "plan" : on colore par plan si connu, sinon on garde vert/rouge */

.synthese-panel.mode-plan .synthese-table td.cell-open[data-plan=""],
.synthese-panel.mode-plan .synthese-table td.cell-closed[data-plan=""] {
    opacity: 0.75;              /* effet "pastel" / voilé */
}
/* Aucune couleur si pas de plan : on ne change rien */

/* Plans connus (couleurs de ta légende) */
.synthese-panel.mode-plan .synthese-table td[data-plan="A"] {
    background-color: #00B8FB;
    color: #000;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="B1"] {
    background-color: #7453F9;
    color: #fff;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="B2"] {
    background-color: #BA85FB;
    color: #000;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="B3"] {
    background-color: #E353FA;
    color: #000;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="CC"] {
    background-color: #D00777;
    color: #fff;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="C1"] {
    background-color: #FF041C;
    color: #fff;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="C2"] {
    background-color: #FF7523;
    color: #000;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="C3"] {
    background-color: #FFB82C;
    color: #000;
}
.synthese-panel.mode-plan .synthese-table td[data-plan="D"] {
    background-color: #259576;
    color: #fff;
}


.synthese-header h2 {
    margin: 0.5rem 0;
    font-size: 1rem;
}

.synthese-controls label {
    margin-right: 0.3rem;
}

.synthese-table-wrapper {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
    max-height: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.synthese-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    table-layout: fixed; /* colonnes homogènes */
}

.synthese-table thead {
    position: sticky;
    top: 0;
    background: #f0f0f0;
    z-index: 1;
}

.synthese-table th,
.synthese-table td {
    border: 1px solid #e0e0e0;
    padding: 2px 4px;
    text-align: center;
    white-space: nowrap;
}

.synthese-table .col-date,
.synthese-table .cell-date {
    position: sticky;
    left: 0;
    background: #f8f8f8;
    z-index: 2;
}

.synthese-table .cell-empty {
    background: #ffffff;
}

/* Rouge / vert comme sur ta capture */
.synthese-table .cell-pos {
    background: #e74c3c;
    color: #ffffff;
    font-weight: 600;
}

.synthese-table .cell-neg {
    background: #2ecc71;
    color: #000000;
    font-weight: 400;
}

.synthese-table td,
.synthese-table th {
    font-size: 10px;
    white-space: normal !important;  /* autorise les retours à la ligne */
    word-break: break-word;          /* coupe si trop long */
    overflow-wrap: break-word;       /* coupe naturellement */
}

.col-date{
    font-size: 10px;
    width: 70px;
}

.synthese-tooltip {
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 6px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.25);
    font-size: 0.75rem;
}

.synthese-tooltip-table {
    border-collapse: collapse;
}

.synthese-tooltip-table th,
.synthese-tooltip-table td {
    padding: 2px 4px;
    white-space: nowrap;
}

.histo-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
}

.histo-toggle input {
    display: none;
}

/* Slider */
.histo-toggle .slider {
    width: 42px;
    height: 22px;
    background: #ccc;
    border-radius: 22px;
    position: relative;
    transition: background 0.25s;
}

.histo-toggle .slider::before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: 2px;
    left: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.25s;
}

/* ON */
.histo-toggle input:checked + .slider {
    background: #0077ff;
}

.histo-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

.label-text {
    font-size: 14px;
}

.analyses-header-state {
    margin-bottom: 4px;
    font-size: 0.8rem;
    line-height: 1.3;
}

.analyses-header-state div {
    white-space: nowrap;
}