/**
 * Schema Viewer — Popup plein écran pour SVG inline
 * Caly-Quiz IRVE — Modules Borne IEC 61851
 *
 * Composants :
 *   1. Bouton "Agrandir" (overlay sur hover)
 *   2. Popup plein écran (overlay + card)
 *   3. Zoom controls (header bar)
 *   4. Zone de contenu (SVG zoomable + pannable)
 */

/* ═══════════════════════════════════════════════════
   1. BOUTON "AGRANDIR" — Overlay sur chaque schéma
   ═══════════════════════════════════════════════════ */

.sv-enlarge-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 14px;
    background: rgba(30, 58, 95, 0.88);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-family: 'Inter', 'Segoe UI', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.25s ease, background 0.2s ease, transform 0.15s ease;
    z-index: 5;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    letter-spacing: 0.02em;
    pointer-events: none;
}

/* Show on hover of parent container (SVG + HTML) */
.bm-waveform:hover .sv-enlarge-btn,
.bm-schema-box:hover .sv-enlarge-btn,
.bm-lock-svg:hover .sv-enlarge-btn,
.bm-radar-container:hover .sv-enlarge-btn,
.bm-formula:hover .sv-enlarge-btn,
.bm-info-card:hover > .sv-enlarge-btn {
    opacity: 1;
    pointer-events: auto;
}

.sv-enlarge-btn:hover {
    background: rgba(245, 158, 11, 0.95);
    transform: scale(1.05);
}

.sv-enlarge-btn:active {
    transform: scale(0.97);
}

/* ═══════════════════════════════════════════════════
   2. OVERLAY PLEIN ÉCRAN
   ═══════════════════════════════════════════════════ */

.sv-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.sv-overlay.active {
    display: flex;
}

/* Backdrop sombre avec blur */
.sv-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* ═══════════════════════════════════════════════════
   3. POPUP CARD
   ═══════════════════════════════════════════════════ */

.sv-popup {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    width: 94vw;
    height: 90vh;
    max-width: 1500px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.1);
    animation: svSlideIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    overflow: hidden;
}

@keyframes svSlideIn {
    from {
        transform: translateY(40px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ═══════════════════════════════════════════════════
   4. HEADER BAR — Titre + Contrôles zoom
   ═══════════════════════════════════════════════════ */

.sv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    color: #ffffff;
    flex-shrink: 0;
    border-radius: 16px 16px 0 0;
    user-select: none;
}

.sv-title {
    margin: 0;
    font-family: 'Outfit', 'Inter', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 60%;
}

.sv-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Boutons zoom +/- et fermer */
.sv-ctrl-btn {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 1.3rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.15s ease;
    font-family: 'Fira Mono', 'Consolas', monospace;
}

.sv-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.sv-ctrl-btn:active {
    transform: scale(0.95);
}

.sv-ctrl-btn.sv-close-btn:hover {
    background: rgba(239, 68, 68, 0.9);
}

/* Séparateur entre zoom et close */
.sv-separator {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.2);
    margin: 0 6px;
}

/* Label de zoom "150%" */
.sv-zoom-label {
    font-family: 'Fira Mono', 'Consolas', monospace;
    font-size: 0.88rem;
    font-weight: 700;
    min-width: 50px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    padding: 0 4px;
}

/* Bouton reset zoom */
.sv-zoom-label {
    cursor: pointer;
    border-radius: 6px;
    padding: 4px 8px;
    transition: background 0.2s;
}

.sv-zoom-label:hover {
    background: rgba(255,255,255,0.12);
}

/* ═══════════════════════════════════════════════════
   5. ZONE DE CONTENU — SVG zoomable
   ═══════════════════════════════════════════════════ */

.sv-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f1f5f9;
    cursor: default;
    position: relative;
}

.sv-content.sv-can-pan {
    cursor: grab;
}

.sv-content.sv-panning {
    cursor: grabbing;
}

/* Wrapper SVG — reçoit les transform scale/translate */
.sv-svg-wrapper {
    transform-origin: center center;
    transition: transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sv-svg-wrapper.sv-no-transition {
    transition: none;
}

/* Le SVG cloné dans le popup */
.sv-svg-wrapper svg {
    display: block;
    max-width: 90vw;
    max-height: 82vh;
    width: auto;
    height: auto;
}

/* ═══════════════════════════════════════════════════
   6. INDICATION DE ZOOM — Badge coin inférieur
   ═══════════════════════════════════════════════════ */

.sv-zoom-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 16px;
    background: rgba(30, 58, 95, 0.8);
    color: #ffffff;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    backdrop-filter: blur(4px);
}

.sv-zoom-hint.visible {
    opacity: 1;
}

/* ═══════════════════════════════════════════════════
   7. RESPONSIVE
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .sv-popup {
        width: 98vw;
        height: 95vh;
        border-radius: 10px;
    }
    .sv-header {
        padding: 10px 16px;
        border-radius: 10px 10px 0 0;
    }
    .sv-title {
        font-size: 0.9rem;
        max-width: 50%;
    }
    .sv-ctrl-btn {
        width: 34px;
        height: 34px;
        font-size: 1.1rem;
    }
}

/* ═══════════════════════════════════════════════════
   8. HTML MODE — Tables, formules, séquences en popup
   ═══════════════════════════════════════════════════ */

.sv-svg-wrapper.sv-html-mode {
    overflow: auto;
    max-width: 92vw;
    max-height: 86vh;
}

/* Make tables & formulas hoverable for the enlarge button */
.bm-formula {
    position: relative;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.bm-formula:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.bm-info-card {
    position: relative;
    transition: box-shadow 0.2s;
}

.bm-info-card:has(.bm-table):hover,
.bm-info-card:has(.bm-compare-table):hover,
.bm-info-card:has(.bm-sequence):hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    cursor: pointer;
}
