/*
 * GestiónIDTX — avisos flotantes (arriba a la derecha). Los usan el login y el
 * panel de administración (partials/toasts.php + js/toasts.js). Se cierran solos
 * a los 3 s con una animación; la barra inferior muestra el tiempo que queda.
 */

.gx-toasts {
    --t-surface: rgba(12, 26, 52, .97);
    --t-border: #1c2e52;
    --t-text: #eaf1fb;
    --t-label: #c8d4e8;
    --t-muted: #8698b8;
    --t-focus: #6aa5f5;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
.gx-toast {
    --tone: #38bdf8;
    --tone-soft: rgba(56, 189, 248, .16);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-height: 240px;
    margin-bottom: 12px;
    padding: 14px 12px 16px 14px;
    border: 1px solid var(--t-border);
    border-left: 4px solid var(--tone);
    border-radius: 12px;
    background: var(--t-surface);
    box-shadow: 0 20px 44px -14px rgba(0, 0, 0, .55);
    color: var(--t-text);
    pointer-events: auto;
    animation: gxToastIn .4s cubic-bezier(.2, .8, .2, 1) both;
}
.gx-toast--error   { --tone: #f43f5e; --tone-soft: rgba(244, 63, 94, .16); }
.gx-toast--success { --tone: #22c55e; --tone-soft: rgba(34, 197, 94, .16); }
.gx-toast--warning { --tone: #f59e0b; --tone-soft: rgba(245, 158, 11, .16); }
.gx-toast--info    { --tone: #38bdf8; --tone-soft: rgba(56, 189, 248, .16); }
.gx-toast-icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--tone-soft);
    color: var(--tone);
    font-size: 1rem;
}
.gx-toast-body { flex: 1; min-width: 0; padding-top: 1px; }
.gx-toast-title { margin: 0; font-size: .9rem; font-weight: 700; line-height: 1.4; }
.gx-toast-msg { margin: 2px 0 0; font-size: .86rem; line-height: 1.45; color: var(--t-label); overflow-wrap: anywhere; }
.gx-toast-close {
    flex: none;
    margin: -2px 0 0;
    padding: 2px 6px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--t-muted);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.gx-toast-close:hover { color: var(--t-text); background: rgba(255, 255, 255, .06); }
.gx-toast-close:focus-visible { outline: 2px solid var(--t-focus); outline-offset: 1px; }
.gx-toast-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--tone);
    opacity: .85;
    transform-origin: left center;
    animation: gxToastBar var(--toast-ms, 3000ms) linear forwards;
}
.gx-toast.is-leaving { animation: gxToastOut .45s cubic-bezier(.4, 0, .2, 1) forwards; }

@keyframes gxToastIn { from { opacity: 0; transform: translateX(calc(100% + 24px)); } to { opacity: 1; transform: none; } }
@keyframes gxToastOut {
    0%   { opacity: 1; transform: none; }
    60%  { opacity: 0; transform: translateX(calc(100% + 24px)); max-height: 240px; margin-bottom: 12px; padding-top: 14px; padding-bottom: 16px; }
    100% { opacity: 0; transform: translateX(calc(100% + 24px)); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
}
@keyframes gxToastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes gxFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes gxFadeOut { to { opacity: 0; } }

@media (max-width: 560px) {
    .gx-toasts { top: 12px; right: 16px; left: 16px; width: auto; }
}
@media (prefers-reduced-motion: reduce) {
    .gx-toast { animation: gxFadeIn .2s ease both; }
    .gx-toast.is-leaving { animation: gxFadeOut .2s ease forwards; }
}

/* Tema claro: aviso blanco con el mismo borde de color (oscuro sigue igual). */
:root[data-theme="light"] .gx-toasts {
    --t-surface: rgba(255, 255, 255, .98);
    --t-border: #dfe6f1;
    --t-text: #0f172a;
    --t-label: #334155;
    --t-muted: #64748b;
    --t-focus: #2f6fd0;
}
:root[data-theme="light"] .gx-toast { box-shadow: 0 18px 40px -16px rgba(15, 23, 42, .28); }
:root[data-theme="light"] .gx-toast-close:hover { background: rgba(15, 23, 42, .05); }

/* ── Aviso de descarga con barra de progreso (js/exportar.js) ──────── */
.gx-descarga { --tone: #16a34a; --tone-soft: rgba(22, 163, 74, .16); max-height: 260px; }
.gx-descarga--pdf { --tone: #e11d48; --tone-soft: rgba(225, 29, 72, .16); }
.gx-descarga.is-ok { --tone: #22c55e; --tone-soft: rgba(34, 197, 94, .16); }
.gx-descarga.is-error { --tone: #f43f5e; --tone-soft: rgba(244, 63, 94, .16); }
.gx-descarga.is-cancelado { --tone: #94a3b8; --tone-soft: rgba(148, 163, 184, .16); }
.gx-descarga .gx-toast-msg { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gx-progreso {
    position: relative;
    height: 7px;
    margin-top: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--t-muted) 22%, transparent);
}
.gx-progreso span {
    position: absolute;
    inset: 0 auto 0 0;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, color-mix(in srgb, var(--tone) 70%, #fff), var(--tone));
    box-shadow: 0 0 12px -2px var(--tone);
    transition: width .25s ease-out;
}
/* Brillo que recorre la barra mientras trabaja. */
.gx-descarga:not(.is-ok):not(.is-error):not(.is-cancelado) .gx-progreso span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .45), transparent);
    transform: translateX(-100%);
    animation: gxBrillo 1.2s ease-in-out infinite;
}
.gx-progreso-pie { display: flex; justify-content: space-between; gap: 10px; margin: 6px 0 0; font-size: .74rem; color: var(--t-muted); font-variant-numeric: tabular-nums; }
.gx-progreso-pct { font-weight: 700; color: var(--t-label); }
.gx-descarga.is-ok .gx-progreso-pct { color: var(--tone); }
.gx-descarga.is-error .gx-progreso, .gx-descarga.is-error .gx-progreso-pie,
.gx-descarga.is-cancelado .gx-progreso, .gx-descarga.is-cancelado .gx-progreso-pie { display: none; }
.gx-descarga.is-error .gx-toast-msg { white-space: normal; }
@keyframes gxBrillo { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
    .gx-progreso span { transition: none; }
    .gx-descarga .gx-progreso span::after { animation: none; }
}
