﻿/* =====================================================================
   MODALES — contenedor de todos los modales (ModalHost.razor)
   Prefijo: md-   ·   HTML/CSS puro, sin Tailwind.
   El contenido de cada modal trae sus propios estilos (mc-modal, wa-modal…);
   aquí solo va el marco: fondo, panel, cabecera, cuerpo y tamaños.
   ===================================================================== */

:root {
    --md-font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
    --md-radius: 18px;
    --md-shadow: 0 2px 6px rgba(15, 23, 42, .08), 0 32px 64px -24px rgba(30, 27, 75, .45);
    --md-ease: cubic-bezier(.2, .8, .2, 1);

    /* Cabecera por tipo (ModalType) */
    --md-head-default: linear-gradient(135deg, #1e1b4b 0%, #153286 55%, #312e81 100%);
    --md-head-info:    linear-gradient(135deg, #0c4a6e 0%, #1d4ed8 60%, #0891b2 100%);
    --md-head-success: linear-gradient(135deg, #064e3b 0%, #047857 60%, #10b981 100%);
    --md-head-warning: linear-gradient(135deg, #78350f 0%, #b45309 60%, #f59e0b 100%);
    --md-head-danger:  linear-gradient(135deg, #7f1d1d 0%, #b91c1c 60%, #ef4444 100%);
}

/* ── Fondo ─────────────────────────────────────────────────────────── */
.md-overlay {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .5);
    font-family: var(--md-font);
    animation: md-fade .2s ease-out;
    outline: none;
}

.md-overlay--blur { background: rgba(15, 23, 42, .4); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.md-overlay--transparent { background: transparent; }

/* ── Panel ─────────────────────────────────────────────────────────── */
.md-panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 32rem;
    max-height: calc(100vh - 32px);
    background: #fff;
    border-radius: var(--md-radius);
    box-shadow: var(--md-shadow);
    overflow: hidden;
    color: #334155;
    animation: md-rise .28s var(--md-ease);
    outline: none;
}

.md-panel *, .md-panel *::before, .md-panel *::after { box-sizing: border-box; }

.md-panel--sm { max-width: 28rem; }
.md-panel--md { max-width: 32rem; }
.md-panel--lg { max-width: 42rem; }
.md-panel--xl { max-width: 56rem; }

.md-panel--full {
    max-width: none;
    width: 100vw;
    height: 100vh;
    max-height: none;
    border-radius: 0;
}

.md-overlay:has(.md-panel--full) { padding: 0; }

/* ── Cabecera ──────────────────────────────────────────────────────── */
.md-head {
    position: relative;
    flex: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 14px 20px;
    background: var(--md-head-default);
    color: #fff;
    isolation: isolate;
}

/* Trama de puntos, igual que las cabeceras Aurora */
.md-head::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, .14) 1px, transparent 1px);
    background-size: 16px 16px;
    -webkit-mask-image: linear-gradient(90deg, transparent 35%, #000 100%);
    mask-image: linear-gradient(90deg, transparent 35%, #000 100%);
    z-index: -1;
}

.md-head--info    { background: var(--md-head-info); }
.md-head--success { background: var(--md-head-success); }
.md-head--warning { background: var(--md-head-warning); }
.md-head--danger  { background: var(--md-head-danger); }

.md-head__main { display: flex; align-items: center; gap: 12px; min-width: 0; }

.md-head__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .16);
    border: 1px solid rgba(255, 255, 255, .24);
}

.md-head__icon .material-symbols-outlined { font-size: 20px; line-height: 1; }

.md-head__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.md-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -.01em;
    color: #fff;
}

.md-subtitle {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: rgba(255, 255, 255, .78);
}

.md-close {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin: -2px -2px 0 0;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 10px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    cursor: pointer;
    transition: background .15s, transform .15s var(--md-ease);
}

.md-close:hover { background: rgba(255, 255, 255, .24); }
.md-close:active { transform: scale(.94); }
.md-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.md-close svg { width: 18px; height: 18px; display: block; }

/* Botón cerrar flotante cuando el modal no tiene título */
.md-close--float {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    margin: 0;
    border-color: #e2e8f0;
    background: #fff;
    color: #64748b;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.md-close--float:hover { background: #f1f5f9; color: #0f172a; }
.md-close--float:focus-visible { outline-color: #4f46e5; }

/* ── Cuerpo ────────────────────────────────────────────────────────── */
.md-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.md-panel--full .md-body { padding: 24px; }

/* ── Animaciones ───────────────────────────────────────────────────── */
@keyframes md-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes md-rise { from { opacity: 0; transform: translateY(14px) scale(.985); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
    .md-overlay { padding: 8px; align-items: flex-end; }
    .md-panel { max-height: calc(100vh - 16px); border-radius: 16px; }
    .md-body { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .md-overlay, .md-panel { animation: none; }
}
