/**
 * Toast Notifications Component
 * =============================
 * Sistema de notificaciones toast no-bloqueantes para Alpine.js
 *
 * Metodología: BEM (Block Element Modifier)
 * Mobile-First: Sí
 * Dependencias: Alpine.js store 'notifications'
 *
 * @author SuiteEducation Team
 * @since 2025-11-15
 */

/* ============================================
   CONTENEDOR DE NOTIFICACIONES
   ============================================ */

.toast-notifications {
    position: fixed;
    top: 140px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
}

/* ============================================
   TOAST INDIVIDUAL (BEM Block)
   ============================================ */

.toast {
    padding: 1rem 1.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    min-width: 300px;
    animation: toast-slide-in 0.3s ease-out;
}

/* ============================================
   ELEMENTOS DEL TOAST (BEM Elements)
   ============================================ */

.toast__message {
    font-weight: 500;
    font-size: 0.875rem;
    flex: 1;
}

.toast__close {
    background: transparent;
    border: none;
    cursor: pointer;
    opacity: 0.6;
    font-size: 1.25rem;
    line-height: 1;
    transition: opacity 0.2s;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast__close:hover,
.toast__close:focus {
    opacity: 1;
}

.toast__close:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ============================================
   MODIFICADORES DE TIPO (BEM Modifiers)
   ============================================ */

.toast--success {
    background: #d1fae5;
    border-left: 4px solid #10b981;
    color: #065f46;
}

.toast--error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.toast--warning {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.toast--info {
    background: #dbeafe;
    border-left: 4px solid #3b82f6;
    color: #1e40af;
}

/* ============================================
   ANIMACIONES
   ============================================ */

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Animación de salida (aplicada por Alpine.js) */
.toast--leaving {
    animation: toast-slide-out 0.2s ease-in forwards;
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* ============================================
   RESPONSIVE - MOBILE FIRST
   ============================================ */

/* Móvil (por defecto) */
.toast-notifications {
    right: 10px;
    left: 10px;
    max-width: none;
}

.toast {
    min-width: auto;
}

/* Tablet y superior */
@media (min-width: 640px) {
    .toast-notifications {
        right: 20px;
        left: auto;
        max-width: 400px;
    }

    .toast {
        min-width: 300px;
    }
}

/* Desktop grande */
@media (min-width: 1024px) {
    .toast-notifications {
        max-width: 450px;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */

/* Reducir movimiento para usuarios con preferencias de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .toast {
        animation: none;
    }

    .toast--leaving {
        animation: none;
        opacity: 0;
    }
}

/* Tema oscuro */
@media (prefers-color-scheme: dark) {
    .toast--success {
        background: #064e3b;
        color: #d1fae5;
    }

    .toast--error {
        background: #7f1d1d;
        color: #fee2e2;
    }

    .toast--warning {
        background: #78350f;
        color: #fef3c7;
    }

    .toast--info {
        background: #1e3a8a;
        color: #dbeafe;
    }
}

/* ============================================
   ESTADOS
   ============================================ */

.toast:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.toast:focus-within {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* Para usuarios de teclado */
.toast__close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 0.25rem;
}
