/**
 * Toast Notification Styles v2.0
 * Premium UI สำหรับ SweetAlert2 Toast mode
 * ดีไซน์ทันสมัย, อนิเมชั่นสมูท, รองรับ Multi-toast
 */

/* =====================================================
   CSS Variables for Theming
   ===================================================== */
:root {
    --toast-bg: rgba(15, 23, 42, 0.95);
    --toast-border: rgba(255, 255, 255, 0.08);
    --toast-text: #f1f5f9;
    --toast-shadow: 0 20px 50px -12px rgba(0, 0, 0, 0.4), 
                    0 8px 20px -8px rgba(0, 0, 0, 0.3);
    
    /* Type Colors - Soft, Modern Palette */
    --toast-success: #10b981;
    --toast-success-bg: rgba(16, 185, 129, 0.12);
    --toast-success-border: rgba(16, 185, 129, 0.25);
    
    --toast-error: #f43f5e;
    --toast-error-bg: rgba(244, 63, 94, 0.12);
    --toast-error-border: rgba(244, 63, 94, 0.25);
    
    --toast-warning: #f59e0b;
    --toast-warning-bg: rgba(245, 158, 11, 0.12);
    --toast-warning-border: rgba(245, 158, 11, 0.25);
    
    --toast-info: #0ea5e9;
    --toast-info-bg: rgba(14, 165, 233, 0.12);
    --toast-info-border: rgba(14, 165, 233, 0.25);
}

/* =====================================================
   Toast Container - Multi-toast support
   ===================================================== */
.swal2-container.swal2-top-end {
    padding: 16px !important;
    gap: 12px !important;
}

/* =====================================================
   Toast Popup - Main Styling
   ===================================================== */
.toast-popup {
    background: var(--toast-bg) !important;
    border-radius: 14px !important;
    box-shadow: var(--toast-shadow) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
    border: 1px solid var(--toast-border) !important;
    padding: 14px 18px !important;
    min-width: 300px;
    max-width: 420px;
    margin-bottom: 8px !important;
    overflow: hidden;
}

/* Subtle glow effect on hover */
.toast-popup:hover {
    box-shadow: var(--toast-shadow),
                0 0 30px -10px rgba(255, 255, 255, 0.1) !important;
    border-color: rgba(255, 255, 255, 0.12) !important;
}

/* =====================================================
   Toast Title Styling
   ===================================================== */
.toast-popup .swal2-title {
    font-size: 0.9375rem !important;
    font-weight: 500 !important;
    color: var(--toast-text) !important;
    margin: 0 !important;
    padding: 0 12px 0 8px !important;
    line-height: 1.5;
    letter-spacing: -0.01em;
    text-align: left !important;
}

/* =====================================================
   Icon Styling - Refined & Compact
   ===================================================== */
.toast-popup .swal2-icon {
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    margin: 0 4px 0 0 !important;
    border-width: 2px !important;
    flex-shrink: 0;
}

.toast-popup .swal2-icon .swal2-icon-content {
    font-size: 0.9rem !important;
}

/* Success Icon - Mint/Teal */
.toast-popup .swal2-icon.swal2-success {
    border-color: var(--toast-success) !important;
    color: var(--toast-success) !important;
    background: var(--toast-success-bg) !important;
}

.toast-popup .swal2-icon.swal2-success [class^='swal2-success-line'] {
    background-color: var(--toast-success) !important;
}

.toast-popup .swal2-icon.swal2-success .swal2-success-ring {
    border-color: transparent !important;
}

/* Error Icon - Soft Rose */
.toast-popup .swal2-icon.swal2-error {
    border-color: var(--toast-error) !important;
    color: var(--toast-error) !important;
    background: var(--toast-error-bg) !important;
}

.toast-popup .swal2-icon.swal2-error [class^='swal2-x-mark-line'] {
    background-color: var(--toast-error) !important;
}

/* Warning Icon - Warm Amber */
.toast-popup .swal2-icon.swal2-warning {
    border-color: var(--toast-warning) !important;
    color: var(--toast-warning) !important;
    background: var(--toast-warning-bg) !important;
}

.toast-popup .swal2-icon.swal2-warning .swal2-icon-content {
    color: var(--toast-warning) !important;
}

/* Info Icon - Sky Blue */
.toast-popup .swal2-icon.swal2-info {
    border-color: var(--toast-info) !important;
    color: var(--toast-info) !important;
    background: var(--toast-info-bg) !important;
}

.toast-popup .swal2-icon.swal2-info .swal2-icon-content {
    color: var(--toast-info) !important;
}

/* =====================================================
   Timer Progress Bar - Sleek Design
   ===================================================== */
.toast-popup .swal2-timer-progress-bar-container {
    background: rgba(255, 255, 255, 0.08) !important;
    height: 3px !important;
    border-radius: 0 0 14px 14px !important;
    overflow: hidden;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
}

.toast-popup .swal2-timer-progress-bar {
    background: linear-gradient(90deg, 
        rgba(255, 255, 255, 0.3) 0%, 
        rgba(255, 255, 255, 0.5) 100%) !important;
    height: 100% !important;
    border-radius: 3px !important;
}

/* Type-specific progress bar colors */
.toast-popup.toast-success .swal2-timer-progress-bar {
    background: linear-gradient(90deg, 
        var(--toast-success) 0%, 
        rgba(16, 185, 129, 0.6) 100%) !important;
}

.toast-popup.toast-error .swal2-timer-progress-bar {
    background: linear-gradient(90deg, 
        var(--toast-error) 0%, 
        rgba(244, 63, 94, 0.6) 100%) !important;
}

.toast-popup.toast-warning .swal2-timer-progress-bar {
    background: linear-gradient(90deg, 
        var(--toast-warning) 0%, 
        rgba(245, 158, 11, 0.6) 100%) !important;
}

.toast-popup.toast-info .swal2-timer-progress-bar {
    background: linear-gradient(90deg, 
        var(--toast-info) 0%, 
        rgba(14, 165, 233, 0.6) 100%) !important;
}

/* =====================================================
   Smooth Animations - Enter & Exit
   ===================================================== */

/* Custom Enter Animation - Slide + Fade from right */
@keyframes toastSlideIn {
    0% {
        transform: translateX(120%) translateY(-10px);
        opacity: 0;
    }
    60% {
        transform: translateX(-8px) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
}

/* Custom Exit Animation - Fade + Slide right */
@keyframes toastSlideOut {
    0% {
        transform: translateX(0) translateY(0);
        opacity: 1;
    }
    100% {
        transform: translateX(120%) translateY(-5px);
        opacity: 0;
    }
}

/* Subtle bounce entrance */
@keyframes toastBounceIn {
    0% {
        transform: translateX(100%) scale(0.9);
        opacity: 0;
    }
    50% {
        transform: translateX(-5px) scale(1.02);
        opacity: 1;
    }
    70% {
        transform: translateX(3px) scale(0.99);
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* Gentle fade out */
@keyframes toastFadeOut {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translateX(30px) scale(0.95);
        opacity: 0;
    }
}

/* Animation Classes */
.toast-show {
    animation: toastBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards !important;
}

.toast-hide {
    animation: toastFadeOut 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
}

/* =====================================================
   Close Button (if shown)
   ===================================================== */
.toast-popup .swal2-close {
    color: rgba(255, 255, 255, 0.4) !important;
    font-size: 1.5rem !important;
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 24px !important;
    height: 24px !important;
    transition: all 0.2s ease !important;
}

.toast-popup .swal2-close:hover {
    color: rgba(255, 255, 255, 0.8) !important;
    transform: scale(1.1) !important;
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 640px) {
    .swal2-container.swal2-top-end {
        padding: 12px !important;
    }
    
    .toast-popup {
        min-width: 260px;
        max-width: calc(100vw - 24px);
        padding: 12px 14px !important;
        border-radius: 12px !important;
    }
    
    .toast-popup .swal2-title {
        font-size: 0.875rem !important;
    }
    
    .toast-popup .swal2-icon {
        width: 22px !important;
        height: 22px !important;
        min-width: 22px !important;
    }
}

/* =====================================================
   Dark Mode Compatibility (if needed)
   ===================================================== */
@media (prefers-color-scheme: dark) {
    :root {
        --toast-bg: rgba(15, 23, 42, 0.98);
    }
}

/* =====================================================
   Modal Popup Styling (for confirmations)
   ===================================================== */
.modal-popup {
    border-radius: 20px !important;
    padding: 28px !important;
    background: #ffffff !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25),
                0 0 0 1px rgba(0, 0, 0, 0.05) !important;
}

.modal-popup .swal2-title {
    font-size: 1.375rem !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    letter-spacing: -0.02em;
}

.modal-popup .swal2-html-container {
    font-size: 0.9375rem !important;
    color: #64748b !important;
    line-height: 1.6;
}

.modal-popup .swal2-actions {
    gap: 12px !important;
}

.modal-popup .swal2-confirm,
.modal-popup .swal2-cancel {
    font-weight: 500 !important;
    padding: 10px 24px !important;
    border-radius: 10px !important;
    transition: all 0.2s ease !important;
}

.modal-popup .swal2-confirm:hover,
.modal-popup .swal2-cancel:hover {
    transform: translateY(-1px) !important;
}

/* =====================================================
   Loading Spinner Enhancement
   ===================================================== */
.toast-popup .swal2-loader {
    border-color: rgba(255, 255, 255, 0.2) !important;
    border-left-color: var(--toast-info) !important;
    width: 24px !important;
    height: 24px !important;
}

/* =====================================================
   Accessibility - Focus States
   ===================================================== */
.toast-popup:focus {
    outline: 2px solid rgba(255, 255, 255, 0.3) !important;
    outline-offset: 2px !important;
}

/* =====================================================
   Print styles - Hide toasts when printing
   ===================================================== */
@media print {
    .swal2-container {
        display: none !important;
    }
}

/* =====================================================
   Password Requirements Panel
   ===================================================== */

/* Panel Container */
.pwd-requirements-panel {
    transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}

.pwd-requirements-panel:hover {
    border-color: #cbd5e1;
}

/* Pulse animation for incomplete submit */
.pwd-requirements-panel.pulse {
    animation: pulse-border 0.6s ease;
}

@keyframes pulse-border {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
        border-color: #fca5a5;
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
        border-color: #ef4444;
    }
}

/* Badge States */
.pwd-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: 0.02em;
}

.pwd-badge.incomplete {
    background: linear-gradient(135deg, #fef2f2, #fee2e2);
    color: #dc2626;
    border: 1px solid #fecaca;
}

.pwd-badge.complete {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

/* Checklist Items */
.pwd-checklist li {
    transition: color 0.25s ease, transform 0.2s ease;
}

.pwd-checklist li.pass {
    color: #16a34a;
}

/* Icon pop animation when rule passes */
.pwd-checklist li.pass .rule-icon i {
    animation: pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes pop {
    0%, 100% { 
        transform: scale(1);
    }
    50% { 
        transform: scale(1.4);
    }
}

/* Rule icon colors */
.pwd-checklist .rule-icon i {
    transition: color 0.2s ease;
}

.pwd-checklist li.pass .rule-icon i {
    color: #16a34a;
}

/* Password toggle button */
.pwd-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.pwd-toggle:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.pwd-toggle:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* =====================================================
   Reduced Motion Support
   ===================================================== */
@media (prefers-reduced-motion: reduce) {
    .pwd-checklist li.pass .rule-icon i,
    .pwd-badge,
    .pwd-requirements-panel {
        animation: none !important;
        transition: none !important;
    }
    
    .pwd-requirements-panel.pulse {
        animation: none !important;
        border-color: #ef4444 !important;
    }
}
