/* =============================================================
   CDS25 – Carte POI Spéléo  |  poi-map.css  v1.4
   Charte : bleu #1a3a5c / orange #E07B39 / fond #f4f1ec
   ============================================================= */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --poi-blue:        #1a3a5c;
    --poi-blue-mid:    #2a5280;
    --poi-blue-light:  #e8f0f8;
    --poi-orange:      #E07B39;
    --poi-orange-dark: #c4602a;
    --poi-bg:          #f4f1ec;
    --poi-surface:     #ffffff;
    --poi-border:      #ddd5c8;
    --poi-text:        #2c2c2c;
    --poi-text-light:  #6b6b6b;
    --poi-radius:      10px;
    --poi-map-height:  540px;
}

/* ── Conteneur global ──────────────────────────────────────── */
.poi-app {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    color: var(--poi-text);
    overflow-x: hidden;
}

/* ── Filtres ───────────────────────────────────────────────── */
.poi-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
}

.poi-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 2px solid var(--poi-border);
    border-radius: 50px;
    background: var(--poi-surface);
    color: var(--poi-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, color .15s ease;
    user-select: none;
    white-space: nowrap;
}

.poi-filter-btn:hover {
    border-color: var(--poi-blue);
    color: var(--poi-blue);
    background: var(--poi-surface);
}

.poi-filter-btn.active,
.poi-filter-btn.active-secondary,
.poi-filter-btn.active-partial {
    background: var(--poi-blue);
    color: #fff;
    border-color: var(--poi-blue);
    border-style: solid;
}

.poi-filter-btn.active .poi-filter-dot,
.poi-filter-btn.active-secondary .poi-filter-dot,
.poi-filter-btn.active-partial .poi-filter-dot {
    outline: 2px solid rgba(255,255,255,.45);
}

.poi-filter-btn.poi-filter-child {
    padding-left: 8px;
    border-style: dashed;
}
.poi-filter-btn.poi-filter-child.active,
.poi-filter-btn.poi-filter-child.active-secondary {
    border-style: solid;
}

.poi-filter-sep {
    display: inline-block;
    width: 1px;
    height: 22px;
    background: var(--poi-border);
    margin: 0 2px;
    vertical-align: middle;
    flex-shrink: 0;
}

.poi-filter-indent {
    font-size: 11px;
    opacity: .6;
    margin-right: 1px;
    line-height: 1;
}

.poi-filter-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    flex-shrink: 0;
}

.poi-filter-count {
    font-size: 11px;
    font-weight: 400;
    opacity: .75;
    margin-left: 1px;
}

/* ── Mode Favoris : filtres atténués mais cliquables ───────── */
.poi-app.fav-mode .poi-filter-btn {
    opacity: .5;
}
.poi-app.fav-mode .poi-filter-btn:hover {
    opacity: 1;
    border-color: var(--poi-blue);
    color: var(--poi-blue);
    background: var(--poi-surface);
}

/* ── Bouton Favoris ────────────────────────────────────────── */
.poi-fav-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: 2px solid var(--poi-border);
    border-radius: 50px;
    background: var(--poi-surface);
    color: var(--poi-text-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
    user-select: none;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}
.poi-fav-toggle svg {
    width: 15px; height: 15px;
    stroke: #e74c7a; fill: none;
    flex-shrink: 0;
    transition: fill .15s, stroke .15s;
}
.poi-fav-toggle:hover {
    border-color: #e74c7a;
    color: var(--poi-text);
    background: var(--poi-surface);
}
.poi-fav-toggle:hover svg { fill: #e74c7a; stroke: #e74c7a; }
.poi-fav-toggle.active {
    border-color: #e74c7a;
    background: #e74c7a;
    color: #fff;
}
.poi-fav-toggle.active svg { fill: #fff; stroke: #fff; }

/* ── Layout 2 colonnes ─────────────────────────────────────── */
.poi-layout {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 20px;
    align-items: start;
    width: 100%;
    box-sizing: border-box;
}

/* ── Carte Leaflet ─────────────────────────────────────────── */
.poi-map-wrapper {
    position: sticky;
    top: 80px;
    border-radius: var(--poi-radius);
    overflow: hidden;
    border: 1px solid var(--poi-border);
    height: var(--poi-map-height);
    min-width: 0;
    box-sizing: border-box;
}

#poi-leaflet-map {
    height: 100%;
    width: 100%;
    background: #e8e0d4;
}

/* ── Popup Leaflet ─────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
    border-radius: var(--poi-radius) !important;
    box-shadow: 0 4px 20px rgba(26,58,92,.18) !important;
    padding: 0 !important;
    overflow: hidden;
    min-width: 200px;
}
.leaflet-popup-content { margin: 0 !important; width: auto !important; }
.leaflet-popup-tip-container { margin-top: -1px; }

.poi-popup { padding: 14px 16px; }
.poi-popup-cat {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .08em;
    margin-bottom: 4px; opacity: .75;
}
.poi-popup-title {
    font-size: 14px; font-weight: 700;
    color: var(--poi-blue); margin: 0 0 8px; line-height: 1.3;
}
.poi-popup-meta {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--poi-text-light);
}
.poi-popup-meta svg { width: 12px; height: 12px; flex-shrink: 0; stroke: var(--poi-orange); }

/* ── Markers ───────────────────────────────────────────────── */
.poi-marker-icon { display: flex; align-items: center; justify-content: center; }

/* ── Liste scrollable ──────────────────────────────────────── */
.poi-list-wrapper {
    height: var(--poi-map-height);
    min-height: 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

.poi-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 4px 4px 2px;
    scrollbar-width: thin;
    scrollbar-color: var(--poi-border) transparent;
}
.poi-list::-webkit-scrollbar       { width: 6px; }
.poi-list::-webkit-scrollbar-track { background: transparent; }
.poi-list::-webkit-scrollbar-thumb { background: var(--poi-border); border-radius: 3px; }

/* Border par défaut transparente — visible au survol/highlight */
.poi-card {
    display: flex;
    flex-shrink: 0;
    min-height: 130px;
    width: 100%;
    box-sizing: border-box;
    background: var(--poi-surface);
    border-radius: var(--poi-radius);
    border: 2px solid transparent;
    overflow: hidden;
    transition: border-color .18s ease, transform .15s ease;
    cursor: pointer;
    scroll-margin-top: 8px;
}

.poi-card:hover,
.poi-card.highlighted {
    border-color: var(--poi-blue);
    transform: translateY(-2px);
}

/* Supprimer la border du body quand la card est sélectionnée — évite le double trait */
.poi-card:hover .poi-card-body,
.poi-card.highlighted .poi-card-body {
    border-color: transparent;
}

.poi-card.hidden { display: none; }

/* ── Thumbnail ─────────────────────────────────────────────── */
.poi-card-thumb {
    position: relative;
    width: 110px;
    min-width: 110px;
    background: var(--poi-bg);
    overflow: hidden;
    flex-shrink: 0;
}

.poi-card-thumb img {
    width: 100%; height: 100%;
    object-fit: cover; display: block;
    position: relative; z-index: 1;
    opacity: .82;
    transition: opacity .2s ease;
}

.poi-card:hover .poi-card-thumb img,
.poi-card.highlighted .poi-card-thumb img {
    opacity: 1;
}

.poi-card-thumb-fallback {
    position: absolute;
    inset: 0; z-index: 0;
    display: flex; align-items: center; justify-content: center;
    background: #eee8e0;
    padding: 12px;
}
.poi-card-thumb-fallback img {
    width: 100%; height: auto;
    object-fit: contain;
    opacity: .35;
    position: static;
}

/* Triangle couleur coin haut-gauche — via clip-path sur un pseudo-élément */
.poi-card-corner {
    position: absolute;
    top: 0; left: 0;
    z-index: 3;
    width: 36px;
    height: 36px;
    /* La couleur est injectée en inline background par JS */
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

/* Icône cœur */
.poi-card-fav {
    position: absolute;
    bottom: 6px; right: 6px;
    z-index: 3;
    width: 24px; height: 24px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,.85);
    border-radius: 50%;
    border: none; cursor: pointer; padding: 0;
    transition: background .15s;
}
.poi-card-fav svg {
    width: 13px; height: 13px;
    stroke: #e74c7a; fill: none;
    transition: fill .15s;
}
.poi-card-fav.active svg { fill: #e74c7a; }
.poi-card-fav:hover { background: #fff; }

/* ── Corps card ────────────────────────────────────────────── */
.poi-card-body {
    flex: 1;
    min-width: 0;
    padding: 10px 13px;
    display: flex; flex-direction: column; gap: 3px;
    border-top: 2px solid var(--poi-border);
    border-right: 2px solid var(--poi-border);
    border-bottom: 2px solid var(--poi-border);
    border-left: none;
    border-radius: 0 var(--poi-radius) var(--poi-radius) 0;
    transition: border-color .18s ease;
    box-sizing: border-box;
}

.poi-card-title {
    font-size: 13px; font-weight: 700;
    color: var(--poi-blue); margin: 0;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    line-height: 1.3;
}

.poi-card-city {
    font-size: 11px; color: var(--poi-text-light);
    margin: 0; font-style: italic;
}

.poi-card-meta {
    display: flex; align-items: center; gap: 5px;
    font-size: 11px; color: var(--poi-text-light); margin: 0;
}
.poi-card-meta svg { width: 11px; height: 11px; flex-shrink: 0; stroke: var(--poi-orange); }

.poi-card-cats {
    display: flex; flex-wrap: wrap; gap: 3px; margin: 1px 0;
}

.poi-cat-tag {
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .05em;
    padding: 1px 6px; border-radius: 50px;
    border: 1.5px solid currentColor; background: transparent;
}

.poi-card-desc {
    font-size: 11px; color: var(--poi-text-light);
    line-height: 1.45; margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; flex: 1;
}

.poi-card-footer { margin-top: 5px; }

.poi-card-pdf {
    display: inline-flex; align-items: center; gap: 4px;
    font-size: 11px; font-weight: 700;
    color: var(--poi-orange); text-decoration: none;
    padding: 3px 9px 3px 7px;
    border: 1.5px solid var(--poi-orange); border-radius: 50px;
    transition: background .15s, color .15s;
}
.poi-card-pdf:hover { background: var(--poi-orange); color: #fff; }
.poi-card-pdf svg { width: 11px; height: 11px; stroke: currentColor; flex-shrink: 0; }
.poi-card-pdf.disabled { color: var(--poi-border); border-color: var(--poi-border); pointer-events: none; }

/* ── Loading / Error ───────────────────────────────────────── */
.poi-loading, .poi-error {
    display: flex; align-items: center; gap: 10px;
    padding: 20px; color: var(--poi-text-light); font-size: 14px;
}
.poi-error { color: #c0392b; }

.poi-spinner {
    display: inline-block; width: 18px; height: 18px;
    border: 3px solid var(--poi-border);
    border-top-color: var(--poi-orange);
    border-radius: 50%;
    animation: poi-spin .7s linear infinite; flex-shrink: 0;
}
@keyframes poi-spin { to { transform: rotate(360deg); } }

.poi-no-results {
    padding: 24px 16px; text-align: center;
    color: var(--poi-text-light); font-size: 13px;
}

/* ── Commune ───────────────────────────────────────────────── */
.poi-card-city {
    font-size: 11px; color: var(--poi-text-light);
    margin: 0; font-style: italic;
}

/* ── Responsive Mobile ─────────────────────────────────────── */
@media (max-width: 900px) {

    /* Grille → colonne unique */
    .poi-layout {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Carte */
    .poi-map-wrapper {
        position: relative;
        top: 0;
        width: 100%;
        height: 280px;
    }

    /* ── Liste : scroll HORIZONTAL des cards ────────────── */
    .poi-list-wrapper {
        width: 100%;
        height: auto;
    }

    .poi-list {
        flex: none;
        height: auto;
        /* Scroll horizontal : les cards défilent côte à côte */
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 4px 4px 12px 2px;
        gap: 10px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--poi-border) transparent;
        /* Snap pour un scroll agréable */
        scroll-snap-type: x mandatory;
    }

    /* Cards en scroll horizontal : largeur fixe, hauteur auto */
    .poi-card {
        flex-shrink: 0;
        flex-direction: column;   /* image en haut, body en dessous */
        width: 220px;
        min-height: 280px;
        transform: none !important;
        scroll-snap-align: start;
    }
    .poi-card:hover,
    .poi-card.highlighted { transform: none !important; }

    /* Titre : autoriser le retour à la ligne sur mobile */
    .poi-card-title {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Thumbnail pleine largeur en haut de la card */
    .poi-card-thumb {
        width: 100%;
        min-width: 100%;
        height: 120px;
        min-height: 120px;
    }

    /* Body reprend le radius en bas */
    .poi-card-body {
        border: 2px solid var(--poi-border);
        border-top: none;
        border-left: 2px solid var(--poi-border);
        border-radius: 0 0 var(--poi-radius) var(--poi-radius);
        flex: 1;
    }
    .poi-card:hover .poi-card-body,
    .poi-card.highlighted .poi-card-body {
        border-color: transparent;
    }

    /* ── Filtres : flex-wrap sur mobile ─────────────────── */
    .poi-filters {
        flex-wrap: wrap;
        overflow: visible;
        padding-bottom: 0;
        /* Laisser de la place pour le bouton Favoris fixe */
        padding-right: 56px;
    }

    /* ── Bouton Favoris : fixe en bas à droite ───────────── */
    .poi-fav-toggle {
        position: fixed;
        bottom: 20px;
        right: 16px;
        z-index: 999;
        margin-left: 0;
        box-shadow: 0 4px 16px rgba(0,0,0,.18);
        /* Masqué par défaut via JS (display:none), visible dès 1 favori */
    }
}

@media (max-width: 480px) {
    .poi-filter-btn { font-size: 12px; padding: 5px 11px; }
    .poi-card { width: 180px; }
}
