/* =========================================================================
   VigiCrécy® Hydro — Front CSS
   Couleurs : #016AB1 (bleu principal), #06D9FA (cyan), #1a2e4a (marine)
   ========================================================================= */

/* ── ARBRE HYDROLOGIQUE ─────────────────────────────────────────────────── */

.vch-tree {
    font-family: inherit;
    margin: 8px 0;
}

/* Niveau 0 : racines (Grand Morin, Petit Morin) */
.vch-tree-ul.level-0 {
    padding-left: 0;
    border-left: none;
    margin: 0;
    list-style: none;
}

/* Niveaux enfants */
.vch-tree-ul {
    list-style: none;
    padding-left: 20px;
    margin: 2px 0 2px 8px;
    border-left: 2px solid #dde9f5;
}

.vch-tree-li {
    margin: 2px 0;
    padding: 1px 0;
    position: relative;
}

/* Trait horizontal reliant au trait vertical */
.vch-tree-ul .vch-tree-li::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 11px;
    width: 14px;
    height: 2px;
    background: #dde9f5;
}

/* ── Niveau 0 : cours principaux (Grand Morin, Petit Morin) */
.vch-tree-ul.level-0 > .vch-tree-li {
    margin-bottom: 16px;
    padding: 10px 14px;
    background: linear-gradient(135deg, #016AB1 0%, #0288d1 100%);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(1,106,177,0.18);
}
.vch-tree-ul.level-0 > .vch-tree-li > .vch-tree-nom {
    color: #fff;
    font-size: 1.1em;
    font-weight: 700;
    letter-spacing: 0.02em;
}
.vch-tree-ul.level-0 > .vch-tree-li > .vch-tree-type {
    background: rgba(255,255,255,0.2);
    color: #e0f4ff;
    border: none;
}
.vch-tree-ul.level-0 > .vch-tree-li::before {
    display: none;
}

/* ── Niveau 1 : grandes rivières (Aubetin, affluents directs classe 6-7) */
.vch-tree-li.type-riviere > .vch-tree-nom {
    color: #016AB1;
    font-size: 1.02em;
    font-weight: 600;
}
.vch-tree-li.type-riviere > .vch-tree-nom::before {
    content: '🔵 ';
    font-size: 0.75em;
}

/* ── Niveaux 2+ : ruisseaux */
.vch-tree-li.type-ruisseau > .vch-tree-nom {
    color: #1a6e9e;
    font-weight: 500;
}
.vch-tree-li.type-ruisseau > .vch-tree-nom::before {
    content: '〰 ';
    font-size: 0.8em;
    color: #64b5f6;
}

/* ── Petits rus */
.vch-tree-li.type-ru > .vch-tree-nom {
    color: #4a7a9a;
    font-weight: 400;
}
.vch-tree-li.type-ru > .vch-tree-nom::before {
    content: '· ';
    color: #90caf9;
}

/* ── Fossés */
.vch-tree-li.type-fosse > .vch-tree-nom,
.vch-tree-li.type-autre > .vch-tree-nom {
    color: #7a9aaa;
    font-style: italic;
    font-weight: 400;
}

/* Badge type */
.vch-tree-nom {
    font-weight: 600;
    color: #1a2e4a;
}
.vch-tree-type {
    font-size: 10px;
    color: #888;
    background: #f0f4f8;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    font-weight: 400;
    vertical-align: middle;
}

/* Ligne de connexion colorée selon le bassin */
.vch-tree-ul.level-0 > .vch-tree-li:first-child ~ * .vch-tree-ul {
    border-left-color: #b3d9f5;
}

/* ── FICHE COURS D'EAU ──────────────────────────────────────────────────── */

.vch-fiche {
    border: 1.5px solid #dde9f5;
    border-radius: 12px;
    overflow: hidden;
    max-width: 680px;
    box-shadow: 0 2px 12px rgba(1,106,177,0.08);
}

/* En-tête */
.vch-fiche-header {
    background: linear-gradient(135deg, #016AB1, #06D9FA);
    padding: 14px 18px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}
.vch-fiche-header-text {
    flex: 1;
}
.vch-fiche-titre {
    color: #fff;
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.3;
}
.vch-fiche-nom-sandre {
    color: rgba(255,255,255,0.75);
    font-size: 0.78rem;
    margin-top: 3px;
    font-style: italic;
}
.vch-fiche-classe-badge {
    background: rgba(255,255,255,0.18);
    color: #e0f4ff;
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.3);
    white-space: nowrap;
    align-self: center;
}

/* Mini-carte */
.vch-fiche-map {
    width: 100%;
    height: 220px;
    border-bottom: 1.5px solid #dde9f5;
    background: #f0f4f8;
}

/* Table données */
.vch-fiche-table {
    width: 100%;
    border-collapse: collapse;
}
.vch-fiche-table th,
.vch-fiche-table td {
    padding: 8px 14px;
    border-bottom: 1px solid #eef2f7;
    font-size: .87rem;
}
.vch-fiche-table th {
    background: #f8fbff;
    color: #5a7a9a;
    font-weight: 600;
    width: 160px;
    white-space: nowrap;
}
.vch-fiche-table tr:last-child th,
.vch-fiche-table tr:last-child td {
    border-bottom: none;
}
.vch-fiche-chaine {
    font-size: 0.82rem;
    color: #4a7a9a;
    font-style: italic;
}
.vch-fiche-code {
    background: #eef6ff;
    color: #016AB1;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Communes & hameaux */
.vch-fiche-lieux {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}
.vch-fiche-lieux-sep {
    color: #06D9FA;
    font-weight: 700;
    font-size: 0.9rem;
    margin: 0 2px;
}
.vch-lieu-commune {
    background: #eef6ff;
    color: #016AB1;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 500;
    border: 1px solid #c8e0f5;
}
.vch-lieu-hameau {
    background: #f0fdf4;
    color: #1a7a4a;
    padding: 2px 9px;
    border-radius: 12px;
    font-size: 0.82rem;
    border: 1px solid #bbf0d0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.vch-lieu-hameau-nom {
    font-weight: 600;
}
.vch-lieu-commune-parent {
    color: #5a9a7a;
    font-size: 0.78rem;
    font-weight: 400;
}

/* ── RECHERCHE ──────────────────────────────────────────────────────────── */

.vch-search-wrap {
    position: relative;
    max-width: 500px;
}
.vch-search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border: 1.5px solid #dde9f5;
    border-radius: 10px;
    font-size: .9rem;
    outline: none;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23016AB1' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 12px center;
    transition: border-color .2s;
}
.vch-search-input:focus {
    border-color: #016AB1;
    box-shadow: 0 0 0 3px rgba(1,106,177,0.1);
}
.vch-search-results {
    margin-top: 8px;
}
.vch-result-item {
    background: #fff;
    border: 1px solid #e5eaf0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 6px;
    transition: border-color .15s, box-shadow .15s;
}
.vch-result-item:hover {
    border-color: #016AB1;
    box-shadow: 0 2px 8px rgba(1,106,177,0.1);
}
.vch-result-item strong {
    color: #016AB1;
}
.vch-type {
    font-size: 11px;
    background: #f0f4f8;
    padding: 1px 8px;
    border-radius: 10px;
    color: #666;
    margin-left: 6px;
}
.vch-rattachement {
    font-size: 12px;
    color: #888;
    margin-left: 8px;
}
.vch-rattachement::before {
    content: '→ ';
    color: #06D9FA;
}
.vch-no-result {
    color: #888;
    font-style: italic;
    padding: 12px;
    text-align: center;
}

/* ── SCROLLBAR CUSTOM — bleu dégradé, étroit ────────────────────────────── */

/* Webkit (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: #eef2f7;
    border-radius: 10px;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(90deg, #016AB1, #06D9FA);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(90deg, #0058a0, #04c8e8);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #016AB1 #eef2f7;
}

/* ── CONTRAINTE LARGEUR SHORTCODE HISTOIRE ──────────────────────────────── */

#vch-histoire-wrap * {
    box-sizing: border-box;
    max-width: 100%;
}

#vch-histoire-wrap input,
#vch-histoire-wrap textarea {
    width: 100% !important;
    max-width: 100% !important;
}

/* ── ANTI-GLOSSAIRE — Panneau Calques ───────────────────────────────────── */
/* Neutralise le style automatique du plugin Glossaire dans le panneau Calques */

[id$="-layers-ctrl"] .vcg-term,
[id$="-layers-ctrl"] .vcg-term a,
[id$="-layers-ctrl"] [class*="vcg-"] {
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
    cursor: inherit !important;
    pointer-events: none !important;
    color: inherit !important;
}
[id$="-layers-ctrl"] .vch-lc-group-title,
[id$="-layers-ctrl"] label {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* ── POPUPS LEAFLET — au-dessus de la barre de recherche ────────────────── */
.leaflet-popup {
    z-index: 500 !important;
}

/* ── POPUPS LEAFLET — Charte VigiCrécy® (bord à bord, bandeau obligatoire)
   Règle globale : toute popup de la carte VigiCrécy® DOIT avoir un bandeau
   coloré pleine largeur comme premier enfant direct. Pas de marges blanches.
   ------------------------------------------------------------------------ */
.leaflet-popup-content-wrapper {
    padding: 0 !important;
    overflow: hidden !important;
    border-radius: 6px !important;
}
.leaflet-popup-content {
    margin: 0 !important;
    width: auto !important;
    padding: 0 !important;
    line-height: 1.5;
}
.leaflet-popup-close-button {
    color: #fff !important;
    font-size: 18px !important;
    font-weight: 700 !important;
    top: 4px !important;
    right: 6px !important;
    z-index: 2;
    opacity: 0.9;
    transition: opacity 0.15s;
}
.leaflet-popup-close-button:hover {
    opacity: 1;
}
/* Racine du contenu des popups : on réserve la largeur complète */
.leaflet-popup-content > div:first-child {
    min-width: 220px;
}
