/* ============================================================
   Universal Toast Notification System
   Mobile-first, accessible, stackable notifications
   ============================================================ */

/* Toast Container */
.toast-container {
    position: fixed;
    z-index: 99999;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 100vh;
    overflow: hidden;
    padding: 16px;
}

/* Position Variants */
.toast-container.top-right { top: 0; right: 0; align-items: flex-end; }
.toast-container.top-left { top: 0; left: 0; align-items: flex-start; }
.toast-container.top-center { top: 0; left: 50%; transform: translateX(-50%); align-items: center; }
.toast-container.bottom-right { bottom: 0; right: 0; align-items: flex-end; }
.toast-container.bottom-left { bottom: 0; left: 0; align-items: flex-start; }
.toast-container.bottom-center { bottom: 0; left: 50%; transform: translateX(-50%); align-items: center; }

/* Individual Toast */
.toast-notification {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 300px;
    max-width: 420px;
    padding: 14px 16px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    border-left: 4px solid transparent;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Sarabun', sans-serif;
}

.toast-notification:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Toast Icon */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-top: 1px;
}

/* Toast Content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 2px;
    line-height: 1.3;
    font-family: 'Prompt', sans-serif;
}

.toast-message {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.4;
    word-break: break-word;
}

/* Close Button */
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    font-size: 1rem;
    color: #94a3b8;
    transition: color 0.2s;
    line-height: 1;
    border-radius: 4px;
}

.toast-close:hover {
    color: #334155;
    background: rgba(0, 0, 0, 0.05);
}

/* Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 12px;
    transition: width linear;
}

/* ============================================================
   Toast Type Variants
   ============================================================ */

/* Success */
.toast-notification.toast-success {
    border-left-color: #10b981;
    background: linear-gradient(135deg, #fff 0%, #f0fdf4 100%);
}
.toast-notification.toast-success .toast-icon { color: #10b981; }
.toast-notification.toast-success .toast-title { color: #065f46; }
.toast-notification.toast-success .toast-progress { background: #10b981; }

/* Error */
.toast-notification.toast-error {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, #fff 0%, #fef2f2 100%);
}
.toast-notification.toast-error .toast-icon { color: #ef4444; }
.toast-notification.toast-error .toast-title { color: #991b1b; }
.toast-notification.toast-error .toast-progress { background: #ef4444; }

/* Warning */
.toast-notification.toast-warning {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, #fff 0%, #fffbeb 100%);
}
.toast-notification.toast-warning .toast-icon { color: #f59e0b; }
.toast-notification.toast-warning .toast-title { color: #92400e; }
.toast-notification.toast-warning .toast-progress { background: #f59e0b; }

/* Info */
.toast-notification.toast-info {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, #fff 0%, #eff6ff 100%);
}
.toast-notification.toast-info .toast-icon { color: #3b82f6; }
.toast-notification.toast-info .toast-title { color: #1e40af; }
.toast-notification.toast-info .toast-progress { background: #3b82f6; }

/* ============================================================
   Animations
   ============================================================ */

/* Slide In Right */
@keyframes toastSlideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Slide In Left */
@keyframes toastSlideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Slide In Down */
@keyframes toastSlideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Slide In Up */
@keyframes toastSlideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Slide Out Right */
@keyframes toastSlideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Slide Out Left */
@keyframes toastSlideOutLeft {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Fade Out */
@keyframes toastFadeOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

.toast-enter-right { animation: toastSlideInRight 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-enter-left { animation: toastSlideInLeft 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-enter-down { animation: toastSlideInDown 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-enter-up { animation: toastSlideInUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-exit-right { animation: toastSlideOutRight 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-exit-left { animation: toastSlideOutLeft 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
.toast-exit { animation: toastFadeOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

/* ============================================================
   ARIA & Accessibility
   ============================================================ */

.toast-notification[role="alert"] {
    /* Screen reader friendly */
}

/* Focus indicator for keyboard users */
.toast-notification:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================================
   Mobile Responsive
   ============================================================ */

@media (max-width: 575.98px) {
    .toast-container {
        padding: 12px;
        left: 0 !important;
        right: 0 !important;
        transform: none !important;
        align-items: stretch !important;
    }
    
    .toast-container.top-right,
    .toast-container.top-left,
    .toast-container.top-center {
        top: 0;
    }
    
    .toast-container.bottom-right,
    .toast-container.bottom-left,
    .toast-container.bottom-center {
        bottom: 0;
    }
    
    .toast-notification {
        min-width: 0;
        max-width: 100%;
        width: 100%;
        padding: 12px 14px;
        border-radius: 10px;
    }
    
    .toast-title {
        font-size: 0.85rem;
    }
    
    .toast-message {
        font-size: 0.8rem;
    }
    
    .toast-icon {
        font-size: 1.1rem;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .toast-notification {
        transition: none;
    }
    
    .toast-enter-right,
    .toast-enter-left,
    .toast-enter-down,
    .toast-enter-up {
        animation: none;
        opacity: 1;
    }
    
    .toast-exit-right,
    .toast-exit-left,
    .toast-exit {
        animation-duration: 0.01s;
    }
}
