/**
 * CSS de la visionneuse de cartes interactives.
 */

.dnd-carte-modal {
    position: fixed;
    inset: 0;
    background: rgba(13, 13, 26, 0.94);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    backdrop-filter: blur(4px);
}

.dnd-carte-modal[hidden] { display: none; }

.dnd-carte-modal-contenu {
    background: #1a1a2e;
    border: 1px solid #b8893d;
    border-radius: 6px;
    width: 100%;
    max-width: 1600px;
    height: 100%;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
    color: #fdf8f0;
    font-family: 'Crimson Text', Georgia, serif;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}

.dnd-carte-entete {
    padding: 0.7rem 1.2rem;
    border-bottom: 1px solid #2d2d44;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.dnd-carte-entete h2 {
    margin: 0;
    font-family: 'Cinzel', serif;
    font-size: 1.3rem;
    color: #b8893d;
}

.dnd-carte-controles {
    display: flex;
    gap: 4px;
}

.dnd-carte-controles button {
    background: rgba(255, 255, 255, 0.05);
    color: #fdf8f0;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.15s ease;
}

.dnd-carte-controles button:hover {
    background: #b8893d;
    color: #1a1a2e;
}

.dnd-carte-fermer {
    background: #c0392b !important;
    color: #fff !important;
}

/* ------------------------------------------------------------------------
   Navigation entre étages (cartes multi-niveaux)
   ------------------------------------------------------------------------ */

.dnd-carte-etages {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-right: 10px;
    padding: 2px 6px;
    background: rgba(184, 137, 61, 0.08);
    border: 1px solid rgba(184, 137, 61, 0.35);
    border-radius: 4px;
}

.dnd-carte-etages button {
    /* hérite des styles .dnd-carte-controles button, mais on appuie le visuel */
    min-width: 30px;
    line-height: 1;
    padding: 4px 8px;
    font-size: 13px;
}

.dnd-carte-etages button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.03);
    color: rgba(253, 248, 240, 0.5);
}

.dnd-carte-etages button:disabled:hover {
    background: rgba(255, 255, 255, 0.03);
    color: rgba(253, 248, 240, 0.5);
}

.dnd-carte-etage-indicateur {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 110px;
    padding: 0 6px;
    line-height: 1.1;
    text-align: center;
    color: #f3c97a;
    font-family: 'Cinzel', serif;
}

.dnd-carte-etage-nom {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.dnd-carte-etage-position {
    font-size: 11px;
    color: rgba(253, 248, 240, 0.65);
    font-family: 'Crimson Text', Georgia, serif;
}

/* Conteneur d'un étage : seul l'étage actif est visible */
.dnd-carte-etage[hidden] { display: none !important; }

.dnd-carte-etage .dnd-carte-svg-wrapper {
    display: block;
}

.dnd-carte-etage .dnd-carte-svg-wrapper svg {
    display: block;
    max-width: none;
    user-select: none;
}

/* Responsive : sur petit écran on garde le bloc d'étages compact */
@media (max-width: 720px) {
    .dnd-carte-entete {
        flex-wrap: wrap;
        gap: 6px;
    }
    .dnd-carte-etages {
        margin-right: 0;
        order: 3;
        width: 100%;
        justify-content: center;
    }
    .dnd-carte-etage-indicateur {
        min-width: 0;
        flex: 1;
    }
}

.dnd-carte-viewport {
    flex: 1;
    overflow: hidden;
    position: relative;
    cursor: grab;
    background:
        linear-gradient(45deg, rgba(255,255,255,.02) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255,255,255,.02) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255,255,255,.02) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255,255,255,.02) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.dnd-carte-viewport.dnd-en-pan { cursor: grabbing; }

.dnd-carte-conteneur {
    position: absolute;
    transform-origin: 0 0;
    transition: transform 0.05s linear;
}

.dnd-carte-image {
    display: block;
    max-width: none;
    user-select: none;
    -webkit-user-drag: none;
}

.dnd-zone-cliquable {
    position: absolute;
    border: 2px solid rgba(184, 137, 61, 0.75);
    background: rgba(184, 137, 61, 0.18);
    cursor: pointer;
    transition: all 0.15s ease;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dnd-zone-cliquable:hover {
    background: rgba(184, 137, 61, 0.45);
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.35);
    z-index: 2;
}

/* Badge numéroté permanent au centre de la zone */
.dnd-zone-badge {
    background: rgba(13, 13, 26, 0.92);
    color: #f39c12;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid #b8893d;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 14px;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease;
}
.dnd-zone-cliquable:hover .dnd-zone-badge {
    transform: scale(1.2);
    background: #f39c12;
    color: #1a1a2e;
    border-color: #fff;
}

/* Étiquette nom au survol (au-dessus du badge) */
.dnd-zone-label {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(13, 13, 26, 0.95);
    color: #f3c97a;
    padding: 4px 10px;
    border: 1px solid #b8893d;
    border-radius: 3px;
    font-size: 13px;
    font-family: 'Cinzel', serif;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    z-index: 3;
}

.dnd-zone-cliquable:hover .dnd-zone-label { opacity: 1; }

/* ========================================================================
   PIED DE LA CARTE — aide + bouton « Fermer la carte » visible
   ======================================================================== */

.dnd-carte-pied {
    padding: 0.6rem 1.2rem;
    border-top: 1px solid #2d2d44;
    background: rgba(13, 13, 26, 0.5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.dnd-carte-aide {
    font-size: 12px;
    color: rgba(253, 248, 240, 0.65);
    font-style: italic;
}

.dnd-carte-btn-fermer {
    background: #8b2c2c;
    color: #fff;
    border: 1px solid #6b1f1f;
    padding: 0.5rem 1.4rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Cinzel', serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.dnd-carte-btn-fermer:hover {
    background: #b13838;
    border-color: #8b2c2c;
    transform: translateY(-1px);
}

/* Responsive : sur petit écran, on empile aide + bouton */
@media (max-width: 720px) {
    .dnd-carte-pied {
        flex-direction: column-reverse;
        align-items: stretch;
    }
    .dnd-carte-aide {
        text-align: center;
        font-size: 11px;
    }
    .dnd-carte-btn-fermer {
        width: 100%;
    }
}

/* Mode éditeur de zones (admin) */
.dnd-zone-editor-wrap {
    position: relative;
    display: inline-block;
    border: 1px solid #ccd0d4;
    margin: 1rem 0;
    background: #f0f0f1;
}

#dnd-zone-editor-img {
    display: block;
    max-width: 100%;
    user-select: none;
}

#dnd-zone-editor-overlay {
    position: absolute;
    inset: 0;
    cursor: crosshair;
}

.dnd-zone-editor-rect {
    position: absolute;
    border: 2px solid #2271b1;
    background: rgba(34, 113, 177, 0.15);
    pointer-events: none;
}

.dnd-zone-editor-rect.dnd-zone-saved {
    border-color: #00a32a;
    background: rgba(0, 163, 42, 0.15);
    pointer-events: auto;
    cursor: pointer;
}

.dnd-zones-table input[type="number"] { width: 70px; }
.dnd-zones-table input[type="text"] { width: 100%; }
.dnd-zones-table .dnd-supprimer-zone { background: #c0392b; color: #fff; border: none; padding: 4px 8px; border-radius: 3px; cursor: pointer; }
