/* SweetAlert Form Customization for Dark Mode */
.swal2-container.swal2-center { align-items: flex-start !important; padding-top: 3vh; }
.swal2-popup { background: var(--purple) !important; color: var(--text) !important; border-radius: 20px !important; padding: 0 1.25rem 1.25rem !important; max-height: 95vh; display: flex !important; flex-direction: column !important; justify-content: flex-start !important; align-items: stretch; }
/* Hauteur fixe en desktop : la popup ne saute plus de taille quand on change d'onglet */
@media (min-width: 769px) {
    .swal2-popup { height: 80vh; }
    .swal2-popup.swal-small-popup { height: auto; }
}
.swal-small-popup { width: 350px !important; padding: 0 1.5rem 1.5rem !important; }
.swal-small-popup .swal2-title { font-size: 1.2rem !important; }
.swal-small-popup .swal2-html-container { font-size: 0.9rem !important; text-align: center !important; }
.swal2-title {
    color: #fff !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0.8em 0 0.9em !important;
    padding: 0 !important;
    text-align: left;
    line-height: 1.4;
    display: flex !important;
    align-items: center;
    flex-wrap: wrap;
    gap: 0 8px;
}
.swal2-title svg.lucide { flex-shrink: 0; vertical-align: middle; }
/* Vrai header de modale : titre + croix alignés sur une ligne */
.swal-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 -1.25rem 0.9rem !important;
    padding: 0.7em 0.75rem 0.7em 1.25rem;
    background: linear-gradient(135deg, var(--primary), #5b2c6f);
    border-bottom: 2px solid rgba(255,255,255,0.12);
    box-shadow: 0 3px 10px var(--black-30);
    box-sizing: border-box;
}
.swal-modal-header .swal2-title {
    margin: 0 !important;
    padding: 0 !important;
    background: none;
    border: none;
    text-align: left;
    flex: 1 1 auto;
    min-width: 0;
}
.swal-modal-close {
    border: none;
    background: none;
    color: rgba(255,255,255,0.55);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    line-height: 1;
    font-size: 1.05rem;
}
.swal-modal-close:hover { color: #fff; }
.swal-modal-close svg { width: 1.3em; height: 1.3em; }
.swal-modal-close.is-standalone {
    position: absolute;
    top: 0.3rem;
    right: 0.3rem;
    z-index: 3;
    font-size: 2.4rem;
}
.swal-modal-close.is-standalone svg {width: 0.9em;height: 0.9em;}
.swal-small-popup .swal-modal-header { margin: 0 -1.5rem 0.9rem !important; padding-left: 1.5rem; }
.swal2-styled { display: inline-flex !important; align-items: center; justify-content: center; gap: 0.5em; }
.swal2-styled svg.lucide { width: 1.1em; height: 1.1em; }
.swal2-html-container {
    text-align: left !important;
    overflow-y: auto !important;
    padding: 0.75rem;
    flex: 1 1 auto;
    min-height: 0;
      margin: 0 0 0.5rem;
      /* --black-25 pose le meme noir sur le fond du theme : #1c1b31 etait
         fige et ne suivait pas l'accent choisi. */
      background: var(--black-25);
    border: 1px solid var(--white-06);
    border-radius: 10px;
    box-sizing: border-box;
}
/* Styling Select Elements */
.swal-custom-input { 
    width: 100%; padding: 10px 12px; margin-bottom: 10px; border-radius: 8px; 
    border: 1px solid var(--white-10); background: var(--black-30); 
    color: white; font-size: 0.85rem; box-sizing: border-box; 
    appearance: none; -webkit-appearance: none;
}
.swal-custom-input:focus { border-color: var(--primary); outline: none; }

/* Customizing select options */
select.swal-custom-input option {
    background: var(--purple);
    color: white;
    padding: 10px;
}
.swal-form-group { margin-bottom: 10px; text-align: left; }
.swal-form-group label { display: block; margin-bottom: 3px; font-size: 0.7rem; color: var(--text-dim); font-weight: bold; text-transform: uppercase; }
.swal-row {display: flex;gap: 6px;}
.swal-col { flex: 1; }
.swal-row-tight { --swal-tight-h: 38px; display: flex; gap: 6px; align-items: flex-end; flex-wrap: nowrap; }
.swal-row-tight > .swal-form-group { margin-bottom: 0; min-width: 0; }
.swal-row-tight > .swal-cat-group { flex: 1 1 auto; }
.swal-row-tight .cat-select-trigger { height: var(--swal-tight-h); }
.swal-row-tight .swal-custom-input { margin-bottom: 0; height: var(--swal-tight-h); }
.ed-nights-group { flex: 0 0 56px; }
.ed-nights-group .swal-custom-input { padding: 10px 2px; text-align: center; appearance: textfield; -moz-appearance: textfield; }
.ed-nights-group .swal-custom-input::-webkit-outer-spin-button,
.ed-nights-group .swal-custom-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ed-flex-row { display: flex; gap: 5px; width: 100%; }
.ed-cost-hint { font-size: 0.7rem; opacity: 0.5; margin-top: 2px; }
.ed-j1-toggle { justify-content: flex-end; margin-top: -2px; }

/* Icon Picker Grid */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(45px, 1fr));
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: var(--black-30);
    border-radius: 12px;
    border: 1px solid var(--white-10);
}
.icon-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--white-05);
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-dim);
    transition: all 0.2s;
}
.icon-item:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.1);
}
.icon-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 0 15px var(--primary);
}
.icon-item img { width: 1.2em; height: 1.2em; pointer-events: none; filter: brightness(0) invert(1); }
.poi-marker img { vertical-align: middle; filter: brightness(0) invert(1); width: 20px; height: 20px; }
.icon-preview-wrapper img { filter: brightness(0) invert(1); }
.icon-preview-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--black-20);
    padding: 5px 10px;
    border-radius: 10px;
    border: 1px solid var(--white-10);
    cursor: pointer;
    height: 38px;
}
.icon-preview-wrapper:hover {
    border-color: var(--primary);
}
.legend-category-form { text-align: left; }
.legend-icon-controls { display: flex; gap: 8px; }
.legend-icon-preview { flex: 1; cursor: default; }
.legend-icon-preview #lg-icon-name { font-size: 0.6rem; opacity: 0.7; }
.legend-icon-preview:hover { border-color: var(--white-10); }
.legend-color-input { width: 44px; height: 38px; padding: 2px; flex-shrink: 0; }
.legend-icon-grid-label { margin-top: 10px; margin-bottom: 5px; font-size: 0.65rem; color: var(--text-dim); font-weight: 700; }
.legend-icon-grid { max-height: 220px; margin-top: 0; }
.legend-icon-grid .icon-item { border: 0; padding: 0; font: inherit; }

/* Étape : visuel libre ou piloté par la catégorie */
.ed-visual-controls { display: flex; gap: 8px; }
.ed-icon-trigger { flex: 1; min-width: 0; }
.ed-icon-trigger span { font-size: 0.6rem; opacity: 0.7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-color-input { width: 40px; height: 38px; padding: 2px; flex-shrink: 0; cursor: pointer; }
.ed-color-input:disabled { cursor: not-allowed; opacity: 0.6; }
.ed-visual-hint { margin-top: 4px; font-size: 0.62rem; opacity: 0.55; }
.ed-visual-group[hidden] { display: none; }

/* Selecteur de categorie */
.cat-select-wrap { position: relative; display: block; width: 100%; }
.cat-select-trigger { width: 100%; height: 2.9em; justify-content: flex-start; padding: 0 10px; border-radius: 10px; }
.cat-select-trigger .cat-opt-name { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-select-gear {
    width: 26px; height: 26px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    margin-right: 2px; padding: 0; border: 0; border-radius: 7px;
    background: transparent; color: #555; cursor: pointer;
}
.cat-select-gear:hover { background: rgba(0,0,0,0.07); color: var(--primary); }
.cat-select-gear:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.cat-select-gear[hidden] { display: none; }
.cat-select-menu { left: 0; right: 0; min-width: 100%; max-height: 290px; overflow-y: auto; z-index: 9999; padding: 4px; }
.cat-select-group {
    padding: 8px 9px 3px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    opacity: 0.65;
}
.cat-select-menu .custom-select-option { gap: 8px; }
.cat-opt-badge {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.7rem;
    line-height: 1;
    overflow: hidden;
}
.cat-opt-badge img { width: 12px; height: 12px; }
.cat-opt-name { flex: 1; min-width: 0; }
.cat-opt-tag {
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 1px 5px;
    border-radius: 4px;
    background: var(--primary-25);
    color: var(--primary);
    font-weight: 700;
}
/* Le prefixe .cat-select-menu est indispensable : components.css est charge
   APRES modals.css, donc un simple .cat-select-new (meme specificite que
   .custom-select-option) perdrait la couleur d'accent et le survol. */
.cat-select-menu .cat-select-new { color: var(--primary); font-weight: 600; }
.cat-select-menu .cat-select-new:hover { background: var(--primary-25); color: var(--primary); }
.cat-select-new-icon { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cat-select-trigger .cat-opt-badge { width: 22px; height: 22px; border-radius: 7px; font-size: 0.78rem; }
.ed-cat-btn {
    min-height: 36px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid var(--white-10);
    background: var(--black-30);
    color: var(--text-dim);
    font: inherit;
    font-size: 0.68rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ed-cat-btn:hover { border-color: var(--primary); color: var(--text); }
.ed-category-view { text-align: left; }
.ed-category-view[hidden] { display: none; }
.ed-category-current { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.ed-category-current-name { font-weight: 700; }
.ed-category-scope { font-size: 0.62rem; opacity: 0.6; }
.ed-cat-editor-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.ed-cat-icon-preview { flex: 1; display: flex; align-items: center; justify-content: center; height: 38px; background: var(--white-05); border: 1px solid var(--white-10); border-radius: 10px; font-size: 1.1rem; }
.ed-cat-color-input { width: 44px; height: 38px; padding: 2px; flex-shrink: 0; cursor: pointer; }
.ed-cat-icon-grid { max-height: 230px; padding: 8px; }
.ed-cat-icon-grid .icon-item { border: 0; padding: 0; font: inherit; }
.ed-category-editor-actions { display: flex; gap: 8px; margin-top: 10px; }
.ed-category-editor-actions .swal2-confirm,
.ed-category-editor-actions .swal2-cancel { margin: 0; min-height: 36px; flex: 1; }

.map-legend-item { display: flex; align-items: center; gap: 8px; padding: 3px 0; white-space: nowrap; }
.map-legend-item + .map-legend-item { border-top: 1px solid rgba(0,0,0,0.08); }
.map-legend-dot {
    width: 20px; height: 20px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid rgba(255,255,255,0.35);
    flex-shrink: 0;
}
.map-legend-dot i { font-size: 0.6rem; }
.map-legend-dot img { width: 11px; height: 11px; }
.map-legend-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.legend-item { cursor: pointer; }
.legend-item .legend-icon-dot {
    width: 26px; height: 26px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid rgba(255,255,255,0.3);
    flex-shrink: 0;
}
.legend-item .legend-icon-dot i { font-size: 0.7rem; }
.legend-item .legend-icon-dot img { width: 13px; height: 13px; }
.legend-del { display: inline-flex; align-items: center; }

@media (max-width: 768px) {
    .swal2-container { padding: 0 !important; }
    .swal2-popup {
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
        margin: 0;
        border-radius: 0 !important;
        padding: 0 0.75rem 1.25rem !important;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }
    .swal-modal-header { margin: 0 -0.75rem 0.75rem !important; padding: 0.7em 0.5rem 0.7em 0.75rem; }
    .swal-modal-close.is-standalone {top: 0.15rem;right: 0.75rem;}
    .swal2-html-container { flex: 1 1 auto; min-height: 0; overflow-y: auto !important; }
    .swal2-actions { flex-direction: row !important; flex-wrap: wrap; justify-content: flex-end; gap: 6px; width: 100%; }
    .swal2-actions button.swal2-styled { min-width: 105px; margin: 0 !important; }
    .swal-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; }
    .swal-col { flex: none; min-width: 0; }
    .swal2-html-container [style*="display:flex"] { flex-wrap: wrap; }
    .swal-custom-input { padding: 8px 10px; }
}

/* Les toasts ne sont PAS ici : ils sont dans base.css, avec le reste de
   l'habillage global. Un toast n'appartient pas aux modales, et settings.php
   n'importe pas cette feuille-la. */


/* --- Fiche etape en lecture seule (droit edit_steps absent) -----------
   Remplace le formulaire d'edition : meme information, aucun champ, aucun
   onglet. Voir openStepView() dans assets/js/step_editor.js. */
.swal-stepview .swal2-html-container { text-align: left; }
/* Toutes les modales desktop ont une hauteur fixe de 80vh (voir en haut du
   fichier, pour que la popup ne saute pas d'un onglet a l'autre). La fiche
   n'a pas d'onglet et n'a pas besoin de cette hauteur : on reprend donc
   l'excape de swal-small-popup, sinon 80vh de vide sous le contenu. */
@media (min-width: 769px) {
    .swal2-popup.swal-stepview { height: auto; }
}
/* Un seul conteneur defile, et c'est swal2-html-container : il est deja en
   flex 1 1 auto / min-height 0 / overflow-y auto (regle plus haut). .stepview
   avait en plus un max-height fixe a 62% de la hauteur de fenetre, plafonne
   independamment de la place reellement disponible : sur une fiche longue il
   affichait une barre de defilement alors qu'il restait ~70px sous lui dans le
   conteneur. Sans ce plafond, la popup en height:auto grossit avec le contenu
   et la barre n'apparait que lorsqu'il n'y a vraiment plus de place. */

/* Barre de defilement sombre dans TOUTES les popups Swal, pas seulement
   .swal-stepview : la popup Recapitulatif (et toutes les autres qui debordent)
   avait la scrollbar native, lisible mais disgracieuse sur le fond --purple.
   Le meme motif etait deja applique a la vue detail d'etape ; on le generalise
   a toutes les popups, et le selecteur .swal-stepview specifique disparait.

   Deux familles de proprietes : Firefox utilise scrollbar-width/scrollbar-color,
   WebKit/Blink utilise les pseudo-elements ::-webkit-scrollbar. Les deux
   donnent le meme rendu (fond sombre, pouce primary arrondi, hover primary-2). */
.swal2-popup .swal2-html-container { scrollbar-width: thin; scrollbar-color: var(--primary) var(--white-05); }
.swal2-popup .swal2-html-container::-webkit-scrollbar { width: 8px; }
.swal2-popup .swal2-html-container::-webkit-scrollbar-track { background: var(--white-05); border-radius: 8px; }
.swal2-popup .swal2-html-container::-webkit-scrollbar-thumb {
    background: var(--primary); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box;
}
.swal2-popup .swal2-html-container::-webkit-scrollbar-thumb:hover { background: var(--primary-2); background-clip: padding-box; }



.stepview { text-align: left; }
.stepview-head {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding-bottom: 10px; margin-bottom: 4px;
    border-bottom: 1px solid var(--white-10);
}
.stepview-cat {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; border-radius: 8px; color: #fff; flex-shrink: 0;
}
.stepview-catname { font-size: 0.85rem; color: var(--text-dim); flex: 1; }

.stepview-row {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 7px 0;
    border-bottom: 1px solid var(--white-05);
    font-size: 0.85rem;
}
.stepview-row:last-of-type { border-bottom: none; }
.stepview-label {
    display: inline-flex; align-items: center; gap: 6px;
    width: 108px; flex-shrink: 0; color: var(--text-dim); font-size: 0.78rem;
}
.stepview-label .lucide { flex-shrink: 0; }
.stepview-value { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.stepview-gps {
    display: inline-flex; align-items: center; gap: 5px;
    margin-left: 8px; color: var(--primary); font-size: 0.78rem;
    text-decoration: none; white-space: nowrap;
}
.stepview-gps:hover { text-decoration: underline; }

.stepview-block { padding: 9px 0; border-top: 1px solid var(--white-05); }
.stepview-block-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-dim); margin-bottom: 5px;
}
.stepview-desc { font-size: 0.85rem; overflow-wrap: anywhere; }
.stepview-atts { margin: 0; padding-left: 18px; font-size: 0.82rem; }
.stepview-atts a { color: var(--primary); }
/* Etat explicitement vide : mieux vaut le dire que d'afficher une fiche
   quasi nue, qui se lit comme un bug d'affichage. */
.stepview-empty {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.82rem; color: var(--text-dim);
    padding: 10px 0; font-style: italic;
}

@media (max-width: 480px) {
    .stepview-row { flex-direction: column; gap: 2px; }
    .stepview-label { width: auto; }
}
