/**
 * SIG-TFC — padrão único de modais
 * Referência: Central de Relatórios → «Estudantes com melhor desempenho»
 * Fixo, centrado; fecha só por Cancelar / botão fechar.
 */

:root {
    --sigtfc-md-wine: #8e1a4d;
    --sigtfc-md-wine-deep: #3a0820;
    --sigtfc-md-wine-dark: #5c0f32;
    --sigtfc-md-surface: #ffffff;
    --sigtfc-md-border: #ecdde5;
    --sigtfc-md-muted: #8a6678;
    --sigtfc-md-radius: 14px;
    --sigtfc-md-shadow: 0 20px 56px rgba(45, 16, 51, 0.18);
    --sigtfc-md-backdrop: rgba(28, 10, 19, 0.45);
}

/* ── Overlay genérico (md / custom) ── */
.md-overlay,
.modal-overlay,
.access-modal {
    position: fixed;
    inset: 0;
    z-index: 2200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: var(--sigtfc-md-backdrop);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}
.md-overlay.open,
.access-modal.open {
    display: flex;
}
.modal-overlay[style*="display: block"],
.modal-overlay[style*="display:block"] {
    display: flex !important;
}

.md-box,
.create-modal-content,
.access-modal .access-card,
.access-modal .modal-panel {
    width: 100%;
    max-width: 420px;
    background: var(--sigtfc-md-surface);
    border: 1px solid var(--sigtfc-md-border);
    border-radius: var(--sigtfc-md-radius);
    box-shadow: var(--sigtfc-md-shadow);
    padding: 18px 20px;
    position: relative;
    max-height: min(88vh, 920px);
    overflow: auto;
}
/* Modal de visitante / formulários largos do site público */
.access-modal .access-card.wide {
    max-width: min(96vw, 700px);
    width: min(96vw, 700px);
    padding: 0;
}
.create-modal-content {
    max-width: min(95vw, 680px);
    padding: 0;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    margin: 0 auto !important;
    position: relative !important;
}

.md-box .rg-card-head,
.sigtfc-md-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
    padding-right: 2rem;
}
.md-box .rg-card-head h6,
.sigtfc-md-head h6,
.sigtfc-md-head .modal-title,
.md-box .rg-card-head .modal-title {
    margin: 0;
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--sigtfc-md-wine-deep);
}
.md-box .rg-sub,
.sigtfc-md-head .rg-sub {
    font-size: 0.72rem;
    color: var(--sigtfc-md-muted);
    display: block;
    margin-top: 2px;
}
.md-box .rg-ico,
.sigtfc-md-ico {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fceef5, #f4d5e2);
    color: var(--sigtfc-md-wine);
    font-size: 1.05rem;
}
.md-hint {
    font-size: 0.74rem;
    color: var(--sigtfc-md-muted);
    margin: 8px 0 16px;
}
.md-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.md-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    width: 2rem;
    height: 2rem;
    border: 0;
    border-radius: 999px;
    background: #f5edf1;
    color: var(--sigtfc-md-wine-deep);
    display: grid;
    place-items: center;
    cursor: pointer;
    line-height: 1;
    font-size: 1.1rem;
}
.md-close:hover { background: #f0e0e8; }

.modal-header-ispm {
    background: transparent !important;
    color: var(--sigtfc-md-wine-deep) !important;
    padding: 18px 20px 12px !important;
    border-bottom: 1px solid var(--sigtfc-md-border) !important;
}
.modal-header-ispm h5 {
    color: var(--sigtfc-md-wine-deep) !important;
    font-weight: 800 !important;
    font-size: 0.95rem !important;
}
.modal-header-ispm .btn-close {
    filter: none !important;
    opacity: 0.7;
}
.modal-body-ispm { padding: 8px 20px 20px !important; }

/* ── Bootstrap modal (todas as páginas) ── */
.modal-backdrop {
    --bs-backdrop-bg: rgba(28, 10, 19, 0.45);
    --bs-backdrop-opacity: 1;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 2190 !important;
}
.modal {
    z-index: 2200 !important;
    padding: 16px !important;
}
.modal.show .modal-dialog {
    pointer-events: auto;
}
.modal-dialog {
    margin: auto;
    max-width: min(520px, 100%);
}
.modal-dialog.modal-lg { max-width: min(800px, 100%); }
.modal-dialog.modal-xl { max-width: min(1040px, 100%); }
.modal-dialog.modal-sm { max-width: min(400px, 100%); }

.modal-content {
    border: 1px solid var(--sigtfc-md-border);
    border-radius: var(--sigtfc-md-radius);
    overflow: hidden;
    background: var(--sigtfc-md-surface);
    box-shadow: var(--sigtfc-md-shadow);
}
.modal-header {
    background: var(--sigtfc-md-surface);
    color: var(--sigtfc-md-wine-deep);
    border-bottom: 1px solid var(--sigtfc-md-border);
    padding: 1rem 1.15rem 0.85rem;
    align-items: flex-start;
}
.modal-header .modal-title {
    font-weight: 800;
    font-size: 0.95rem;
    letter-spacing: -0.02em;
    color: var(--sigtfc-md-wine-deep);
    line-height: 1.3;
}
.modal-header .btn-close {
    filter: none;
    opacity: 0.65;
    box-shadow: none;
}
.modal-header .btn-close:hover { opacity: 1; }
.modal-header .btn-close-white {
    filter: none;
}
.modal-body {
    padding: 0.85rem 1.15rem 1rem;
    color: #1c0a13;
}
.modal-footer {
    background: #fdf9fb;
    border-top: 1px solid var(--sigtfc-md-border);
    padding: 0.85rem 1.15rem 1rem;
    gap: 0.55rem;
}
.modal-footer .btn,
.md-actions .btn,
.md-actions .btn-export,
.md-actions .btn-filter-clear {
    border-radius: 10px;
    font-weight: 700;
}
.modal .form-control,
.modal .form-select,
.md-box .form-control,
.md-box .form-select {
    border-radius: 10px;
    border-color: var(--sigtfc-md-border);
}
.modal .form-control:focus,
.modal .form-select:focus,
.md-box .form-control:focus,
.md-box .form-select:focus {
    border-color: var(--sigtfc-md-wine);
    box-shadow: 0 0 0 3px rgba(142, 26, 77, 0.12);
}
.modal .form-label,
.md-box .filter-label,
.md-box label {
    font-weight: 700;
    color: var(--sigtfc-md-wine-dark);
    font-size: 0.78rem;
}

/* Cabeçalhos com gradiente legado passam a seguir o padrão claro */
.modal-header[style*="background"],
.modal-custom .modal-header,
.profile-modal .modal-header,
.defesa-bs-modal .modal-header,
.modal-docente .modal-header {
    background: var(--sigtfc-md-surface) !important;
    color: var(--sigtfc-md-wine-deep) !important;
}
.modal-custom .modal-title,
.profile-modal .modal-title,
.defesa-bs-modal .modal-title {
    color: var(--sigtfc-md-wine-deep) !important;
}
.modal-custom .btn-close-custom {
    background: #f5edf1;
    color: var(--sigtfc-md-wine-deep);
}

[data-theme="dark"] .modal-content,
[data-theme="dark"] .md-box,
[data-theme="dark"] .create-modal-content {
    background: #1a1820;
    border-color: rgba(242, 238, 245, 0.1);
    color: #f2eef5;
}
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer,
[data-theme="dark"] .modal-header-ispm {
    background: #1a1820 !important;
    border-color: rgba(242, 238, 245, 0.1) !important;
    color: #f2eef5 !important;
}
[data-theme="dark"] .modal-header .modal-title,
[data-theme="dark"] .md-box .rg-card-head h6 {
    color: #f2eef5 !important;
}
