/* ══════════════════════════════════════════════════════════════════════
   NOTIFICACIONES · macOS Sonoma
   Re-estiliza `.alert` de Bootstrap como los banners del Centro de
   notificaciones de macOS (Sonoma): tarjeta glass con hairline y sombra en
   capas, azulejo de icono en degradado de color de sistema, texto neutro y
   entrada con el spring de Apple.

   assets/notifications.js los MUEVE a #macos-noti-stack: pila fija centrada
   en la parte superior de la pantalla, por encima de todas las capas
   (z-index 3000 > modals 1055 / offcanvas 1045 / toasts 1100), con auto-
   cierre como un banner de macOS. Esta hoja define tanto la tarjeta como la
   pila; el aspecto funciona aunque el JS no cargue (alertas en su sitio).

   · Sólo presentación: no toca markup, semántica (role/aria) ni el JS de
     `data-bs-dismiss`; funciona también con alertas creadas desde JS.
   · Se carga LA ÚLTIMA (tras zenith/style.css en público y macos.css en
     admin), de modo que gana a los overrides previos de `.alert` — incluidos
     los `!important` de zenith en modo oscuro, que se redeclaran aquí.
   · Barra de título: `::before` dibuja la cabecera a todo el ancho con el
     tipo de la alerta (Éxito/Error/Aviso/Información/Nota) en versalitas y
     color de variante; los iconos propios del alert quedan en el cuerpo.
   · Respetado: prefers-reduced-motion, modo oscuro y utilidades Bootstrap
     (d-flex, justify-content-between, mt/mb siguen mandando donde aplica).
   ══════════════════════════════════════════════════════════════════════ */

.alert {
    --noti-radius: 18px;
    --noti-glyph: "•";
    --noti-title: "Notificación";
    --noti-rgb: 142, 142, 147;
    --noti-pad-l: 1.05rem;
    --noti-pad-r: 1.05rem;

    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0 0.4rem;
    margin-bottom: 0.75rem;
    padding: 0.8rem var(--noti-pad-r) 0.8rem var(--noti-pad-l);
    border: 0.5px solid rgba(0, 0, 0, 0.07);
    border-radius: var(--noti-radius);
    background-color: rgba(255, 255, 255, 0.72);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(255, 255, 255, 0.32));
    backdrop-filter: saturate(180%) blur(18px);
    -webkit-backdrop-filter: saturate(180%) blur(18px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 10px 30px rgba(0, 0, 0, 0.1),
        0 2px 8px rgba(0, 0, 0, 0.06);
    color: rgba(0, 0, 0, 0.85);
    font-size: 0.875rem;
    line-height: 1.45;
    animation: macosNotifIn 0.45s cubic-bezier(0.32, 0.72, 0, 1) both;
}

/* ── Barra de título: cabecera a todo el ancho que indica el tipo ────────
   Sobre la tarjeta (márgenes negativos que cubren el padding), a todo el
   ancho con flex-basis calc, glifo + tipo en versalitas y filete inferior
   del color de la variante. Los iconos propios del alert quedan como texto
   en el cuerpo; la barra es la que nombra el tipo. */
.alert::before {
    content: var(--noti-glyph) " " var(--noti-title);
    flex: 0 0 calc(100% + var(--noti-pad-l) + var(--noti-pad-r));
    margin: -0.8rem calc(-1 * var(--noti-pad-r)) 0.55rem calc(-1 * var(--noti-pad-l));
    padding: 0.42rem var(--noti-pad-r) 0.42rem var(--noti-pad-l);
    border-radius: var(--noti-radius) var(--noti-radius) 0 0;
    border-bottom: 1px solid rgba(var(--noti-rgb), 0.22);
    background: linear-gradient(180deg, rgba(var(--noti-rgb), 0.16), rgba(var(--noti-rgb), 0.08));
    color: rgb(var(--noti-rgb));
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    line-height: 1.35;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Variantes: tipo en la barra + tinte muy leve del color de sistema ── */
.alert-success {
    --noti-rgb: 52, 199, 89;
    --noti-glyph: "✓";
    --noti-title: "Éxito";
    background-color: rgba(52, 199, 89, 0.07);
}

.alert-danger {
    --noti-rgb: 255, 59, 48;
    --noti-glyph: "✕";
    --noti-title: "Error";
    background-color: rgba(255, 59, 48, 0.07);
}

.alert-warning {
    --noti-rgb: 255, 159, 10;
    --noti-glyph: "!";
    --noti-title: "Aviso";
    background-color: rgba(255, 159, 10, 0.08);
}

.alert-info {
    --noti-rgb: 10, 132, 255;
    --noti-glyph: "i";
    --noti-title: "Información";
    background-color: rgba(10, 132, 255, 0.07);
}

.alert-primary {
    --noti-rgb: 0, 122, 255;
    --noti-glyph: "!";
    --noti-title: "Aviso";
    background-color: rgba(0, 122, 255, 0.07);
}

.alert-secondary,
.alert-light {
    --noti-rgb: 142, 142, 147;
    --noti-glyph: "i";
    --noti-title: "Nota";
    background-color: rgba(142, 142, 147, 0.08);
}

/* ── Título (alert-heading) y énfasis como en las notificaciones ───────── */
.alert-heading {
    display: block;
    margin-bottom: 0.15rem;
    font-size: 0.975rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: inherit;
}

.alert-link {
    font-weight: 600;
    text-decoration-color: currentColor;
}

/* ── Botón cerrar: círculo frosted del Sonoma ──────────────────────────── */
.alert-dismissible {
    --noti-pad-r: 2.9rem;
}

.alert-dismissible .btn-close {
    position: absolute;
    top: 0.7rem;
    right: 0.8rem;
    width: 1.45rem;
    height: 1.45rem;
    padding: 0;
    border-radius: 50%;
    background-color: rgba(120, 120, 128, 0.14);
    box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.1);
    background-size: 0.62rem;
    opacity: 0.7;
    transition:
        background-color 0.2s cubic-bezier(0.32, 0.72, 0, 1),
        opacity 0.2s ease,
        transform 0.2s cubic-bezier(0.32, 0.72, 0, 1);
}

.alert-dismissible .btn-close:hover {
    background-color: rgba(120, 120, 128, 0.26);
    opacity: 1;
    transform: scale(1.06);
}

.alert-dismissible .btn-close:active {
    transform: scale(0.94);
}

/* ── Modo oscuro: glass oscuro, texto neutro (gana a los !important de
      zenith con la misma especificidad) y tintes más presentes ─────────── */
[data-bs-theme="dark"] .alert,
[data-bs-theme="dark"] .alert-success,
[data-bs-theme="dark"] .alert-danger,
[data-bs-theme="dark"] .alert-warning,
[data-bs-theme="dark"] .alert-info,
[data-bs-theme="dark"] .alert-primary,
[data-bs-theme="dark"] .alert-secondary,
[data-bs-theme="dark"] .alert-light {
    color: rgba(255, 255, 255, 0.92) !important;
}

[data-bs-theme="dark"] .alert {
    border-color: rgba(255, 255, 255, 0.14);
    background-color: rgba(44, 44, 46, 0.78);
    background-image: linear-gradient(180deg, rgba(58, 58, 60, 0.72), rgba(32, 32, 34, 0.6));
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 12px 32px rgba(0, 0, 0, 0.45),
        0 2px 8px rgba(0, 0, 0, 0.35);
}

[data-bs-theme="dark"] .alert-success { background-color: rgba(48, 209, 88, 0.13); }
[data-bs-theme="dark"] .alert-danger  { background-color: rgba(255, 69, 58, 0.14); }
[data-bs-theme="dark"] .alert-warning { background-color: rgba(255, 159, 10, 0.14); }
[data-bs-theme="dark"] .alert-info    { background-color: rgba(10, 132, 255, 0.14); }
[data-bs-theme="dark"] .alert-primary { background-color: rgba(10, 132, 255, 0.14); }
[data-bs-theme="dark"] .alert-secondary,
[data-bs-theme="dark"] .alert-light   { background-color: rgba(142, 142, 147, 0.16); }

/* Barra de título en oscuro: tinte más presente y filete del color. */
[data-bs-theme="dark"] .alert::before {
    border-bottom-color: rgba(var(--noti-rgb), 0.34);
    background: linear-gradient(180deg, rgba(var(--noti-rgb), 0.3), rgba(var(--noti-rgb), 0.14));
}

[data-bs-theme="dark"] .alert-dismissible .btn-close {
    background-color: rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.16);
}

/* ── Pila flotante: centrada arriba, sobre todas las capas ───────────────
   #macos-noti-stack la crea notifications.js y en ella viven los alert
   movidos desde su posición original. z-index 3000 > bootstrap modal (1055),
   offcanvas (1045) y toasts (1100), y por encima de las z-index máximas del
   proyecto (1100). pointer-events en la pila pero no en los huecos, para no
   tapar clics de la página. */
#macos-noti-stack {
    position: fixed;
    top: 14px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3000;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: min(440px, calc(100vw - 24px));
    max-height: calc(100vh - 28px);
    overflow: visible;
    pointer-events: none;
}

#macos-noti-stack .alert {
    position: relative;
    width: 100%;
    margin-bottom: 0;
    flex: 0 0 auto;
    pointer-events: auto;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 16px 44px rgba(0, 0, 0, 0.16),
        0 4px 12px rgba(0, 0, 0, 0.1);
}

[data-bs-theme="dark"] #macos-noti-stack .alert {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.1),
        0 18px 48px rgba(0, 0, 0, 0.55),
        0 4px 14px rgba(0, 0, 0, 0.4);
}

/* ── Entrada: la banner entra deslizándose desde arriba con spring ─────── */
@keyframes macosNotifIn {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ── Salida automática (la añade notifications.js al agotar el tiempo) ─── */
.alert.noti-out {
    animation: macosNotifOut 0.26s cubic-bezier(0.32, 0.72, 0, 1) both;
}

@keyframes macosNotifOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-10px) scale(0.97);
    }
}

@media (prefers-reduced-motion: reduce) {
    .alert {
        animation: none;
    }
    .alert.noti-out {
        animation: none;
        opacity: 0;
    }
    .alert-dismissible .btn-close {
        transition: none;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   DIÁLOGOS · macOS Sonoma
   Los `.modal` de Bootstrap pasan a ventana de diálogo de Sonoma: glass,
   barra de título con el rótulo centrado, filetes hairline y — firmado de
   macOS — **semáforo rojo** a la izquierda de la barra que cierra el modal
   (cruz que aparece con un hover sutil: escala + halo + opacidad). Todo con
   el spring de Apple; se carga tras zenith/macos.css y les gana en cascada
   (los `!important` de zenith en oscuro se redeclaran con igual especificidad).
   ══════════════════════════════════════════════════════════════════════ */

/* Fondo de atenuación Sonoma: además del velo oscuro, el contenido que queda
   debajo se ve ligeramente distorsionado — desenfoque, saturación y un punto
   de brillo menos (backdrop-filter actúa sobre lo que hay BAJO el backdrop,
   es decir, la página). */
.modal-backdrop.show {
    opacity: 0.32;
    backdrop-filter: blur(14px) saturate(140%) brightness(0.96);
    -webkit-backdrop-filter: blur(14px) saturate(140%) brightness(0.96);
}

/* Oscuro: velo algo más denso y la misma distorsión. */
[data-bs-theme="dark"] .modal-backdrop.show {
    opacity: 0.42;
    backdrop-filter: blur(16px) saturate(150%) brightness(0.9);
    -webkit-backdrop-filter: blur(16px) saturate(150%) brightness(0.9);
}

/* Quien pide menos transparencia/no-distorsión se queda con el velo plano. */
@media (prefers-reduced-transparency: reduce) {
    .modal-backdrop.show,
    [data-bs-theme="dark"] .modal-backdrop.show {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* Ventana: glass con filete, esquinas de16px y sombra profunda. */
.modal-content {
    border: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px;
    background-color: rgba(255, 255, 255, 0.92);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
    backdrop-filter: saturate(180%) blur(24px);
    -webkit-backdrop-filter: saturate(180%) blur(24px);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 24px 64px rgba(0, 0, 0, 0.28),
        0 6px 18px rgba(0, 0, 0, 0.14);
}

/* Zenith fija var(--zen-card) en claro con mayor especificidad: se redeclara. */
[data-bs-theme="light"] .modal-content {
    border-color: rgba(0, 0, 0, 0.08);
    background-color: rgba(255, 255, 255, 0.92);
    background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.58));
}

/* Entrada: la ventana se asienta con el spring (diálogo + micro-escala). */
.modal.fade .modal-dialog {
    transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
    transform: translate(0, -14px);
}

.modal.fade.show .modal-dialog {
    transform: none;
}

.modal.show .modal-content {
    animation: macosModalIn 0.4s cubic-bezier(0.32, 0.72, 0, 1) both;
}

@keyframes macosModalIn {
    from {
        opacity: 0;
        transform: scale(0.965) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Barra de título: rótulo centrado como en las ventanas de Sonoma. */
.modal-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.95rem 1.25rem;
    border-bottom: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 16px 16px 0 0;
}

.modal-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    text-align: center;
    color: inherit;
}

/* Semáforo rojo de cierre (izquierda de la barra, como en macOS). */
.modal-header .btn-close {
    position: absolute;
    left: 0.95rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.85rem;
    height: 0.85rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background-color: #ff5f57;
    background-image: none;
    filter: none;
    box-shadow:
        inset 0 0 0 0.5px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.45);
    opacity: 1;
    transition:
        background-color 0.2s cubic-bezier(0.32, 0.72, 0, 1),
        transform 0.25s cubic-bezier(0.32, 0.72, 0, 1),
        box-shadow 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

/* La cruz sólo se revela al pasar el ratón (como las luces de macOS). */
.modal-header .btn-close::before {
    content: "✕";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.5rem;
    font-weight: 700;
    line-height: 1;
    color: rgba(120, 0, 0, 0.8);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.modal-header .btn-close:hover {
    background-color: #ff453a;
    transform: translateY(-50%) scale(1.18);
    box-shadow:
        inset 0 0 0 0.5px rgba(0, 0, 0, 0.18),
        0 0 0 3px rgba(255, 95, 87, 0.24);
}

.modal-header .btn-close:hover::before {
    opacity: 1;
}

.modal-header .btn-close:active {
    transform: translateY(-50%) scale(0.95);
}

.modal-header .btn-close:focus-visible {
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.5);
}

/* Pie: filete superior, botones redondeados y azul del sistema. */
.modal-footer {
    gap: 0.5rem;
    border-top: 0.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 0 0 16px 16px;
}

.modal-footer .btn {
    border-radius: 10px;
    transition:
        transform 0.2s cubic-bezier(0.32, 0.72, 0, 1),
        background-color 0.2s ease,
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

.modal-footer .btn:active {
    transform: scale(0.97);
}

.modal-footer .btn-primary {
    background-color: #007aff;
    border-color: #007aff;
}

.modal-footer .btn-primary:hover,
.modal-footer .btn-primary:focus {
    background-color: #0071e3;
    border-color: #0071e3;
}

/* ── Modo oscuro (gana a los !important de zenith con igual especificidad) ── */
[data-bs-theme="dark"] .modal-content {
    border-color: rgba(255, 255, 255, 0.14);
    background-color: rgba(44, 44, 46, 0.92) !important;
    background-image: linear-gradient(180deg, rgba(58, 58, 60, 0.82), rgba(32, 32, 34, 0.72));
    color: rgba(255, 255, 255, 0.92) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 24px 64px rgba(0, 0, 0, 0.6),
        0 6px 18px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .modal-footer {
    border-top-color: rgba(255, 255, 255, 0.1);
}

@media (prefers-reduced-motion: reduce) {
    .modal.fade .modal-dialog {
        transition: none;
        transform: none;
    }
    .modal.show .modal-content {
        animation: none;
    }
    .modal-header .btn-close {
        transition: none;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   SILEO · ÚNICO CANAL VISUAL DE ALERTAS
   Las alertas del markup se ocultan hasta que notifications.js las
   convierte en toasts de Sileo. No se muestra la pila macOS ni estilos
   alternativos de alerta.
   ══════════════════════════════════════════════════════════════════════ */
.alert {
    display: none !important;
}

/* Alertas inline explícitas (p. ej. condiciones dentro de un modal): se
   muestran en su sitio y notifications.js no las convierte en toast. */
.alert[data-sileo-inline="1"] {
    display: flex !important;
}
