/* ============================================================
   FOCAL MODAL — composant partagé
   Trigger  : $(document).trigger("focal:show-modal", [opts])
   opts     : { title, body (HTML string), size? "sm"|"md"(défaut)|"lg" }
   Close    : $(document).trigger("focal:close-modal")
   ============================================================ */

#focal-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(248, 246, 243, 0.72);
    backdrop-filter: blur(12px) saturate(180%);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.focal-modal-card {
    background: var(--blanc-focal, #F8F6F3);
    border: 1px solid var(--gris-clair, #D8D4CE);
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(20, 18, 16, 0.16);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 32px);
    width: 100%;
    overflow: hidden;
    animation: focal-modal-in 140ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.focal-modal-card.sm { max-width: 400px; }
.focal-modal-card.md { max-width: 520px; }
.focal-modal-card.lg { max-width: 720px; }

@keyframes focal-modal-in {
    from { opacity: 0; transform: scale(0.96) translateY(6px); }
    to   { opacity: 1; transform: scale(1)    translateY(0);   }
}

.focal-modal-topbar {
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 var(--space-s, 16px);
    box-sizing: border-box;
    background: #ECEAE7;
    flex-shrink: 0;
    gap: 8px;
    border-bottom: 1px solid var(--gris-clair, #D8D4CE);
}

.focal-modal-title {
    flex: 1;
    font-size: var(--text-sm, 14px);
    font-weight: 600;
    color: var(--noir-focal, #141210);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.focal-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--gris-moyen, #8A8580);
    display: flex;
    align-items: center;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 4px;
    transition: color 0.1s, background 0.1s;
}

.focal-modal-close:hover {
    color: var(--noir-focal, #141210);
    background: rgba(20, 18, 16, 0.06);
}

.focal-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-s, 16px);
    box-sizing: border-box;
    color: var(--noir-focal, #141210);
    font-size: var(--text-sm, 14px);
    line-height: 1.6;
}

/* ---- Utilitaires pour le contenu ---- */
.focal-modal-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--gris-tres-clair, #F0EDE9);
    gap: 12px;
}

.focal-modal-row:last-child { border-bottom: none; }

.focal-modal-key {
    font-size: var(--text-xs, 12px);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gris-moyen, #8A8580);
    flex-shrink: 0;
}

.focal-modal-val {
    font-size: var(--text-sm, 14px);
    font-weight: 500;
    color: var(--noir-focal, #141210);
    text-align: right;
}

.focal-modal-error-block {
    margin-top: 12px;
    border: 1px solid rgba(196, 58, 58, 0.25);
    border-radius: 6px;
    overflow: hidden;
}

.focal-modal-error-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--text-xs, 12px);
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--rouge-alerte, #C43A3A);
    background: rgba(196, 58, 58, 0.06);
    padding: 5px 8px 5px 12px;
    border-bottom: 1px solid rgba(196, 58, 58, 0.15);
}

.stt-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid rgba(196, 58, 58, 0.25);
    border-radius: 4px;
    color: var(--rouge-alerte, #C43A3A);
    cursor: pointer;
    padding: 3px 6px;
    font-size: 11px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
    flex-shrink: 0;
}

.stt-copy-btn:hover {
    background: rgba(196, 58, 58, 0.10);
}

.stt-copy-btn i { pointer-events: none; }

.focal-modal-pre {
    margin: 0;
    padding: 10px 12px;
    font-size: 12px;
    font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
    color: var(--noir-focal, #141210);
    background: transparent;
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.55;
    max-height: 220px;
    overflow-y: auto;
}
