/**
 * Modale de formulaire — composant partage
 *
 * Boite de dialogue sobre du site : en-tete icone + titre + sous-titre,
 * corps en champs etiquetes, pied d'actions aligne a droite. Les valeurs
 * reprennent celles de la modale « Nouveau Bastion » (mychars), qui sert
 * de reference visuelle.
 *
 * Les couleurs passent par les variables de la page hote, avec repli sur
 * la palette grimoire : la modale s'accorde donc au fond de chaque page.
 */

.app-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .68);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9997;
    opacity: 0;
    visibility: hidden;
    transition: all .2s;
    padding: 1rem;
}

.app-modal-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

.app-modal {
    background: var(--bg-card, #1a1612);
    border: 1px solid rgba(212, 175, 55, .1);
    border-radius: 5px;
    width: min(92vw, 480px);
    max-height: 90vh;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
    transform: scale(.96);
    transition: transform .2s;
    overflow: auto;

    /* Widgets natifs en sombre, quelle que soit la page hote. */
    color-scheme: dark;
}

.app-modal--sm {
    width: min(92vw, 420px);
}

.app-modal-overlay.is-open .app-modal {
    transform: scale(1);
}

/* ── En-tête ── */
.app-modal-header {
    display: flex;
    align-items: flex-start;
    gap: .7rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid rgba(212, 175, 55, .08);
}

.app-modal-header > i {
    color: var(--gold, #d4af37);
    font-size: 1rem;
    margin-top: .15rem;
}

.app-modal-header > .app-modal-icon--danger {
    color: #e74c3c;
}

.app-modal-headings h3 {
    font-family: 'Cinzel', serif;
    font-size: .9rem;
    font-weight: 600;
    color: var(--text, #e8e4dc);
    margin: 0;
}

.app-modal-subtitle {
    margin: .25rem 0 0;
    color: var(--text-muted, #8a8070);
    font-size: .74rem;
}

/* ── Corps ── */
.app-modal-body {
    padding: 1.1rem 1.2rem;
}

.app-modal-field {
    margin-bottom: .9rem;
}

.app-modal-field label {
    display: block;
    margin-bottom: .35rem;
    color: var(--text-muted, #8a8070);
    font-size: .72rem;
}

.app-modal-field .required {
    color: #e74c3c;
}

.app-modal-input,
.app-modal-select {
    width: 100%;
    padding: .5rem .65rem;
    background: var(--bg-deep, #0e0c08);
    border: 1px solid rgba(212, 175, 55, .08);
    border-radius: 3px;
    color: var(--text, #e8e4dc);
    font-size: .82rem;
    font-family: inherit;
    transition: border-color .2s;
}

.app-modal-input:focus,
.app-modal-select:focus {
    outline: none;
    border-color: rgba(212, 175, 55, .32);
}

.app-modal-input::placeholder {
    color: rgba(138, 128, 112, .72);
}

/* Le contenu deroule d'un select n'herite pas du style du select. */
.app-modal-select option {
    background: var(--bg-card, #1a1612);
    color: var(--text, #e8e4dc);
    padding: .35rem .5rem;
}

.app-modal-hint {
    margin: .35rem 0 0;
    color: var(--text-muted, #8a8070);
    font-size: .68rem;
}

.app-modal-feedback {
    margin: 1rem 0 0;
    padding: .65rem .8rem;
    border-radius: 4px;
    font-size: .76rem;
    line-height: 1.45;
}

.app-modal-feedback[data-state="success"] {
    background: rgba(76, 175, 80, .12);
    border: 1px solid rgba(76, 175, 80, .22);
    color: #8ed39a;
}

.app-modal-feedback[data-state="error"] {
    background: rgba(231, 76, 60, .1);
    border: 1px solid rgba(231, 76, 60, .22);
    color: #f0a39a;
}

.app-modal-feedback[data-state="info"] {
    background: rgba(212, 175, 55, .08);
    border: 1px solid rgba(212, 175, 55, .14);
    color: var(--text-secondary, #c8c0b4);
}

/* ── Pied ── */
.app-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: .4rem;
    padding: .7rem 1.2rem;
    border-top: 1px solid rgba(212, 175, 55, .06);
}

.app-modal-cancel,
.app-modal-confirm {
    font-family: 'Cinzel', serif;
    font-size: .65rem;
    font-weight: 600;
    padding: .4rem .8rem;
    border-radius: 3px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: .04em;
    transition: all .2s;
}

.app-modal-cancel {
    background: none;
    border: 1px solid rgba(212, 175, 55, .12);
    color: var(--text-muted, #8a8070);
}

.app-modal-cancel:hover {
    background: rgba(212, 175, 55, .05);
    color: var(--text, #e8e4dc);
}

.app-modal-confirm {
    background: linear-gradient(180deg, #a68929, #8b7023);
    border: 1px solid #8b7023;
    color: #fff;
}

.app-modal-confirm:disabled {
    opacity: .35;
    cursor: not-allowed;
}

.app-modal-confirm:not(:disabled):hover {
    filter: brightness(1.06);
}

@media (max-width: 640px) {
    .app-modal-footer {
        flex-direction: column-reverse;
    }

    .app-modal-cancel,
    .app-modal-confirm {
        width: 100%;
    }
}
