/**
 * Toast Notification System
 * Academia Design System Component
 * 
 * Usage:
 * <div class="toast-container">
 *   <div class="toast toast--success">
 *     <i class="ph ph-check-circle toast__icon"></i>
 *     <div class="toast__content">
 *       <p class="toast__message">Success message here</p>
 *     </div>
 *     <button class="toast__close"><i class="ph ph-x"></i></button>
 *   </div>
 * </div>
 */

/* ========================================
   Toast Container
   ======================================== */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: var(--z-tooltip, 500);
    max-width: 400px;
    pointer-events: none;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: 24px;
}

/* ========================================
   Toast Base
   ======================================== */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    background: var(--color-glass-bg, rgba(255, 255, 255, 0.08));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-glass-border, rgba(255, 255, 255, 0.1));
    border-radius: var(--radius-lg, 16px);
    box-shadow:
        0 4px 30px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    pointer-events: auto;

    /* Animation */
    animation: toast-slide-in 0.4s var(--ease-out, cubic-bezier(0.16, 1, 0.3, 1)) forwards;
}

.toast.toast--exiting {
    animation: toast-slide-out 0.3s var(--ease-in, cubic-bezier(0.55, 0.06, 0.68, 0.19)) forwards;
}

/* ========================================
   Toast Variants
   ======================================== */
.toast--success {
    border-left: 4px solid var(--color-primary, #2DB84C);
}

.toast--success .toast__icon {
    color: var(--color-primary, #2DB84C);
}

.toast--error {
    border-left: 4px solid #FF6B6B;
}

.toast--error .toast__icon {
    color: #FF6B6B;
}

.toast--warning {
    border-left: 4px solid var(--color-accent-gold, #FFD700);
}

.toast--warning .toast__icon {
    color: var(--color-accent-gold, #FFD700);
}

.toast--info {
    border-left: 4px solid #64B5F6;
}

.toast--info .toast__icon {
    color: #64B5F6;
}

/* RTL border adjustment */
[dir="rtl"] .toast--success,
[dir="rtl"] .toast--error,
[dir="rtl"] .toast--warning,
[dir="rtl"] .toast--info {
    border-left: none;
    border-right: 4px solid currentColor;
}

[dir="rtl"] .toast--success {
    border-right-color: var(--color-primary, #2DB84C);
}

[dir="rtl"] .toast--error {
    border-right-color: #FF6B6B;
}

[dir="rtl"] .toast--warning {
    border-right-color: var(--color-accent-gold, #FFD700);
}

[dir="rtl"] .toast--info {
    border-right-color: #64B5F6;
}

/* ========================================
   Toast Elements
   ======================================== */
.toast__icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast__content {
    flex: 1;
    min-width: 0;
}

.toast__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text-primary, #ffffff);
    margin: 0 0 4px;
}

.toast__message {
    font-size: 0.875rem;
    color: var(--color-text-muted, rgba(255, 255, 255, 0.7));
    margin: 0;
    line-height: 1.4;
}

.toast__close {
    background: transparent;
    border: none;
    color: var(--color-text-muted, rgba(255, 255, 255, 0.5));
    cursor: pointer;
    padding: 4px;
    margin: -4px -4px -4px 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.toast__close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--color-text-primary, #ffffff);
}

.toast__close:focus-visible {
    outline: 2px solid var(--color-primary, #2DB84C);
    outline-offset: 2px;
}

/* ========================================
   Toast Animations
   ======================================== */
@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

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

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

    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

[dir="rtl"] .toast {
    animation-name: toast-slide-in-rtl;
}

[dir="rtl"] .toast.toast--exiting {
    animation-name: toast-slide-out-rtl;
}

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

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

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

    to {
        opacity: 0;
        transform: translateX(-100%);
    }
}

/* ========================================
   Reduced Motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .toast {
        animation-duration: 0.01ms;
    }

    .toast.toast--exiting {
        animation-duration: 0.01ms;
    }
}

/* ========================================
   Mobile Responsiveness
   ======================================== */
@media (max-width: 480px) {
    .toast-container {
        bottom: 16px;
        right: 16px;
        left: 16px;
        max-width: none;
    }

    [dir="rtl"] .toast-container {
        right: 16px;
        left: 16px;
    }

    .toast {
        padding: 12px 16px;
    }
}