/* ============================================================
   ACADEMIKA PLUS — SISTEMA DE FEEDBACK
   Require: variables.css cargado antes en el <head>
   Cubre: Toasts · Alerts Inline · Form Errors ·
          Confirm Modal · Empty States · Skeleton Loading
   ============================================================ */


/* ══════════════════════════════════════════════════════════
   1. TOAST NOTIFICATIONS  (snackbar · bottom-center · pill)
   ══════════════════════════════════════════════════════════ */

/* Contenedor: centrado en la parte inferior */
#toast-container {
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    gap: 8px;
    pointer-events: none;
    width: max-content;
    max-width: calc(100vw - 32px);
}

/* Toast individual — pill compacto estilo glass */
.toast {
    pointer-events: all;
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 22px 11px 14px;
    border-radius: 999px;
    backdrop-filter: blur(24px) saturate(1.8);
    -webkit-backdrop-filter: blur(24px) saturate(1.8);
    overflow: hidden;
    white-space: nowrap;
    animation: toastIn 0.40s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.40),
        0 2px 10px rgba(0, 0, 0, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.toast.toast-hide {
    animation: toastOut 0.26s ease forwards;
}

/* Animaciones — entra desde abajo */
@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(0.88);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
        max-height: 80px;
        max-width: 600px;
        padding-left: 14px;
        padding-right: 22px;
        margin-bottom: 0;
    }

    to {
        opacity: 0;
        transform: translateY(16px) scale(0.88);
        max-height: 0;
        max-width: 0;
        padding: 0;
        margin-bottom: -8px;
    }
}

/* Ícono */
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.66rem;
}

/* Estructura de fila (compatible con HTML generado) */
.toast-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* Título */
.toast-title {
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

/* Mensaje — visible como texto secundario junto al título */
.toast-message {
    font-size: 0.80rem;
    line-height: 1.3;
    opacity: 0.72;
    padding-left: 0;
    display: inline;
}

/* Botón X — oculto, solo auto-dismiss */
.toast-close {
    display: none !important;
}

/* Barra de progreso */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    border-radius: 0;
    transform-origin: left center;
    animation: toastProgress linear forwards;
    opacity: 0.5;
}

/* ════════════════════════════════════════════════════════
   VARIANTES - Adaptativas Dark / Light
   ════════════════════════════════════════════════════════ */

/* base dark: sombra reforzada */
.dark .toast {
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.50),
        0 2px 10px rgba(0, 0, 0, 0.30),
        inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

/* base light: sombra suave, blanco/glass */
:root:not(.dark) .toast {
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.04),
        inset 0 1px 0 rgba(255, 255, 255, 0.80);
}

/* SUCCESS - dark */
.toast-success {
    background: rgba(0, 36, 17, 0.92);
    border: 1px solid rgba(51, 255, 146, 0.28);
    color: #ffffff;
}

.toast-success .toast-icon {
    background: rgba(51, 255, 146, 0.18);
    color: #33ff92;
}

.toast-success .toast-title {
    color: #33ff92;
}

.toast-success .toast-progress {
    background: #33ff92;
}

/* SUCCESS - light */
:root:not(.dark) .toast-success {
    background: rgba(229, 255, 241, 0.95);
    border: 1px solid rgba(0, 153, 71, 0.28);
    color: #003318;
}

:root:not(.dark) .toast-success .toast-icon {
    background: rgba(0, 153, 71, 0.14);
    color: #009947;
}

:root:not(.dark) .toast-success .toast-title {
    color: #009245;
}

:root:not(.dark) .toast-success .toast-progress {
    background: #009947;
}

/* ERROR - dark */
.toast-error {
    background: rgba(90, 15, 5, 0.90);
    border: 1px solid rgba(248, 113, 113, 0.30);
    color: #ffffff;
}

.toast-error .toast-icon {
    background: rgba(248, 113, 113, 0.20);
    color: #f87171;
}

.toast-error .toast-title {
    color: #f87171;
}

.toast-error .toast-progress {
    background: #f87171;
}

/* ERROR - light */
:root:not(.dark) .toast-error {
    background: rgba(255, 245, 245, 0.92);
    border: 1px solid rgba(239, 68, 68, 0.30);
    color: #7f1d1d;
}

:root:not(.dark) .toast-error .toast-icon {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

:root:not(.dark) .toast-error .toast-title {
    color: #b91c1c;
}

:root:not(.dark) .toast-error .toast-progress {
    background: #ef4444;
}

/* WARNING - dark */
.toast-warning {
    background: rgba(90, 45, 0, 0.90);
    border: 1px solid rgba(251, 191, 36, 0.30);
    color: #ffffff;
}

.toast-warning .toast-icon {
    background: rgba(251, 191, 36, 0.20);
    color: #fbbf24;
}

.toast-warning .toast-title {
    color: #fbbf24;
}

.toast-warning .toast-progress {
    background: #fbbf24;
}

/* WARNING - light */
:root:not(.dark) .toast-warning {
    background: rgba(255, 251, 235, 0.92);
    border: 1px solid rgba(245, 158, 11, 0.30);
    color: #78350f;
}

:root:not(.dark) .toast-warning .toast-icon {
    background: rgba(245, 158, 11, 0.14);
    color: #d97706;
}

:root:not(.dark) .toast-warning .toast-title {
    color: #b45309;
}

:root:not(.dark) .toast-warning .toast-progress {
    background: #f59e0b;
}

/* INFO - dark */
.toast-info {
    background: rgba(5, 30, 70, 0.90);
    border: 1px solid rgba(125, 211, 252, 0.30);
    color: #ffffff;
}

.toast-info .toast-icon {
    background: rgba(125, 211, 252, 0.20);
    color: #7dd3fc;
}

.toast-info .toast-title {
    color: #7dd3fc;
}

.toast-info .toast-progress {
    background: #7dd3fc;
}

/* INFO - light */
:root:not(.dark) .toast-info {
    background: rgba(240, 249, 255, 0.92);
    border: 1px solid rgba(14, 165, 233, 0.30);
    color: #0c4a6e;
}

:root:not(.dark) .toast-info .toast-icon {
    background: rgba(14, 165, 233, 0.12);
    color: #0284c7;
}

:root:not(.dark) .toast-info .toast-title {
    color: #0369a1;
}

:root:not(.dark) .toast-info .toast-progress {
    background: #0ea5e9;
}

@keyframes toastProgress {
    from {
        transform: scaleX(1);
    }

    to {
        transform: scaleX(0);
    }
}


/* ══════════════════════════════════════════════════════════
   2. ALERTAS INLINE
   ══════════════════════════════════════════════════════════ */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    margin: 12px 0;
    border-radius: var(--radius-md, 12px);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: alertFadeIn 0.3s ease;
    position: relative;
}

@keyframes alertFadeIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes alertHide {
    from {
        opacity: 1;
        max-height: 200px;
        margin: 12px 0;
    }

    to {
        opacity: 0;
        max-height: 0;
        margin: 0;
        padding: 0;
    }
}

.alert.alert-hide {
    animation: alertHide 0.3s ease forwards;
}

.alert-icon {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.alert-body {
    flex: 1;
    min-width: 0;
}

.alert-title {
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.3;
    margin-bottom: 2px;
}

.alert-message {
    font-size: 0.81rem;
    line-height: 1.4;
    opacity: 0.85;
}

.alert-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    opacity: 0.5;
    color: inherit;
    transition: opacity 0.15s;
}

.alert-close:hover {
    opacity: 1;
}

.alert-success {
    background: rgba(0, 153, 71, 0.10);
    border: 1px solid rgba(0, 153, 71, 0.28);
    border-left: 3px solid #00cc5f;
    color: inherit;
}

.alert-success .alert-icon {
    background: rgba(0, 204, 95, 0.18);
    color: #00cc5f;
}

.alert-success .alert-title {
    color: #00cc5f;
}

.alert-error {
    background: rgba(204, 51, 0, 0.10);
    border: 1px solid rgba(204, 51, 0, 0.28);
    border-left: 3px solid #ef4444;
    color: inherit;
}

.alert-error .alert-icon {
    background: rgba(239, 68, 68, 0.18);
    color: #ef4444;
}

.alert-error .alert-title {
    color: #ef4444;
}

.alert-warning {
    background: rgba(224, 120, 0, 0.10);
    border: 1px solid rgba(224, 120, 0, 0.28);
    border-left: 3px solid #f59e0b;
    color: inherit;
}

.alert-warning .alert-icon {
    background: rgba(245, 158, 11, 0.18);
    color: #f59e0b;
}

.alert-warning .alert-title {
    color: #f59e0b;
}

.alert-info {
    background: rgba(14, 165, 233, 0.10);
    border: 1px solid rgba(14, 165, 233, 0.28);
    border-left: 3px solid #0ea5e9;
    color: inherit;
}

.alert-info .alert-icon {
    background: rgba(14, 165, 233, 0.18);
    color: #0ea5e9;
}

.alert-info .alert-title {
    color: #0ea5e9;
}


/* ══════════════════════════════════════════════════════════
   3. FORM ERROR MESSAGES
   ══════════════════════════════════════════════════════════ */

.form-error {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 0.78rem;
    color: #ef4444;
    animation: alertFadeIn 0.2s ease;
}

.form-error i {
    font-size: 0.72rem;
}

.form-field-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18) !important;
}


/* ══════════════════════════════════════════════════════════
   4. CONFIRM MODAL
   ══════════════════════════════════════════════════════════ */

.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: confirmFadeIn 0.2s ease;
}

@keyframes confirmFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.confirm-overlay.hide {
    animation: confirmFadeOut 0.2s ease forwards;
}

@keyframes confirmFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

.confirm-modal {
    background: #fff;
    border-radius: 18px;
    padding: 28px 28px 24px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25), 0 4px 16px rgba(0, 0, 0, 0.12);
    animation: confirmSlideIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.dark .confirm-modal {
    background: #0a1f12;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.60), 0 4px 16px rgba(0, 0, 0, 0.40);
}

@keyframes confirmSlideIn {
    from {
        opacity: 0;
        transform: scale(0.90) translateY(12px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-overlay.hide .confirm-modal {
    animation: confirmSlideOut 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes confirmSlideOut {
    from {
        opacity: 1;
        transform: scale(1) translateY(0);
    }

    to {
        opacity: 0;
        transform: scale(0.90) translateY(12px);
    }
}

.confirm-modal .confirm-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin: 0 auto 16px;
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.confirm-modal .confirm-icon.warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.confirm-modal .confirm-title {
    font-size: 1.05rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 8px;
}

.confirm-modal .confirm-description {
    font-size: 0.875rem;
    text-align: center;
    opacity: 0.70;
    line-height: 1.5;
    margin-bottom: 22px;
}

.confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-actions button {
    flex: 1;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 0.875rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.15s;
}

.confirm-actions button:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

.confirm-btn-cancel {
    background: rgba(0, 0, 0, 0.06);
    color: inherit;
}

.dark .confirm-btn-cancel {
    background: rgba(255, 255, 255, 0.10);
}

.confirm-btn-danger {
    background: #ef4444;
    color: #fff;
}

.confirm-btn-primary {
    background: #009245;
    color: #fff;
}

.confirm-btn-warning {
    background: #009245;
    color: #fff;
}

.confirm-btn-primary:hover,
.confirm-btn-warning:hover {
    background: #007535;
    color: #fff;
}

.confirm-btn-danger:hover {
    background: #dc2626;
    color: #fff;
}


/* ══════════════════════════════════════════════════════════
   5. EMPTY STATES
   ══════════════════════════════════════════════════════════ */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    gap: 12px;
    opacity: 0.75;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    background: rgba(0, 0, 0, 0.06);
    margin-bottom: 4px;
}

.dark .empty-state-icon {
    background: rgba(255, 255, 255, 0.08);
}

.empty-state-title {
    font-size: 1rem;
    font-weight: 700;
}

.empty-state-message {
    font-size: 0.85rem;
    opacity: 0.70;
    max-width: 300px;
    line-height: 1.5;
}


/* ══════════════════════════════════════════════════════════
   6. PAGE LOADER & SKELETON
   ══════════════════════════════════════════════════════════ */

#page-loader {
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: confirmFadeIn 0.2s ease;
}

.page-loader-spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(255, 255, 255, 0.20);
    border-top-color: #009245;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg,
            rgba(0, 0, 0, 0.06) 25%,
            rgba(0, 0, 0, 0.10) 50%,
            rgba(0, 0, 0, 0.06) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
    border-radius: 6px;
}

.dark .skeleton {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.10) 50%,
            rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s infinite;
}

@keyframes shimmer {
    from {
        background-position: 200% 0;
    }

    to {
        background-position: -200% 0;
    }
}
