/**
 * ModernAlerts & Toast System - SchoolMS NextGen UI
 * Sleek, Glassmorphic 2026 UI replacing bulky legacy SweetAlert popups.
 */

:root {
    --ma-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --ma-bg-glass: rgba(255, 255, 255, 0.94);
    --ma-border-glass: rgba(226, 232, 240, 0.85);
    --ma-shadow-ambient: 0 20px 45px -12px rgba(15, 23, 42, 0.16), 0 8px 16px -6px rgba(15, 23, 42, 0.08);
    --ma-primary: #4f46e5;
    --ma-success: #10b981;
    --ma-error: #f43f5e;
    --ma-warning: #f59e0b;
    --ma-info: #0ea5e9;
}

/* Toast Container */
#modern-toast-container {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
    top: 20px;
    right: 20px;
    max-width: 420px;
    width: calc(100% - 40px);
    transition: all 0.3s ease;
}

@media (max-width: 640px) {
    #modern-toast-container {
        top: 14px;
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 92%;
        width: 92%;
    }
}

/* Individual Toast Capsule */
.modern-toast {
    pointer-events: auto;
    background: var(--ma-bg-glass);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--ma-border-glass);
    border-radius: 18px;
    padding: 14px 16px 14px 14px;
    box-shadow: var(--ma-shadow-ambient);
    display: flex;
    align-items: flex-start;
    gap: 14px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    animation: modernToastSlideIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: transform 0.25s ease, opacity 0.25s ease, box-shadow 0.25s ease;
}

.modern-toast:hover {
    transform: translateY(-2px);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.22);
}

.modern-toast.toast-hiding {
    animation: modernToastSlideOut 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

@keyframes modernToastSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-24px) scale(0.94);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes modernToastSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) scale(0.92);
    }
}

/* Toast Icon Badge */
.modern-toast-icon {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.15rem;
    color: #ffffff;
    position: relative;
}

.modern-toast-icon::after {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 15px;
    opacity: 0.35;
    z-index: -1;
    filter: blur(6px);
}

.modern-toast.toast-success .modern-toast-icon {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}
.modern-toast.toast-success .modern-toast-icon::after {
    background: #10b981;
}

.modern-toast.toast-error .modern-toast-icon {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
}
.modern-toast.toast-error .modern-toast-icon::after {
    background: #f43f5e;
}

.modern-toast.toast-warning .modern-toast-icon {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.modern-toast.toast-warning .modern-toast-icon::after {
    background: #f59e0b;
}

.modern-toast.toast-info .modern-toast-icon {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
}
.modern-toast.toast-info .modern-toast-icon::after {
    background: #0ea5e9;
}

/* Toast Content */
.modern-toast-content {
    flex-grow: 1;
    min-width: 0;
    padding-top: 1px;
}

.modern-toast-title {
    font-family: var(--ma-font);
    font-size: 0.92rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
    margin-bottom: 3px;
}

.modern-toast-message {
    font-family: var(--ma-font);
    font-size: 0.81rem;
    color: #475569;
    line-height: 1.45;
    word-break: break-word;
}

/* Toast Close Button */
.modern-toast-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.modern-toast-close:hover {
    color: #334155;
    background: rgba(148, 163, 184, 0.15);
}

/* Toast Countdown Progress Bar */
.modern-toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left;
    border-radius: 0 0 18px 18px;
}

.modern-toast.toast-success .modern-toast-progress {
    background: linear-gradient(90deg, #10b981, #34d399);
}
.modern-toast.toast-error .modern-toast-progress {
    background: linear-gradient(90deg, #f43f5e, #fb7185);
}
.modern-toast.toast-warning .modern-toast-progress {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}
.modern-toast.toast-info .modern-toast-progress {
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
}

/* ==========================================================================
   Modern Modal & Bento Loading Overlay
   ========================================================================== */
#modern-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10001;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

#modern-modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modern-modal-card {
    background: #ffffff;
    border-radius: 24px;
    box-shadow: 0 25px 60px -15px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(226, 232, 240, 0.8);
    max-width: 440px;
    width: 100%;
    padding: 2.2rem 2rem;
    text-align: center;
    position: relative;
    transform: scale(0.92) translateY(12px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

#modern-modal-overlay.active .modern-modal-card {
    transform: scale(1) translateY(0);
}

/* Orbital Glowing Spinner */
.modern-spinner-wrapper {
    position: relative;
    width: 76px;
    height: 76px;
    margin: 0 auto 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modern-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3.5px solid transparent;
    border-top-color: #4f46e5;
    border-right-color: #06b6d4;
    animation: modernSpin 0.95s linear infinite;
    filter: drop-shadow(0 0 8px rgba(79, 70, 229, 0.4));
}

.modern-spinner-pulse {
    position: absolute;
    inset: 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.12), rgba(6, 182, 212, 0.15));
    animation: modernPulse 1.8s ease-in-out infinite;
}

.modern-spinner-core {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.4);
    z-index: 2;
}

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

@keyframes modernPulse {
    0%, 100% {
        transform: scale(0.88);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

.modern-modal-title {
    font-family: var(--ma-font);
    font-size: 1.25rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.modern-modal-text {
    font-family: var(--ma-font);
    font-size: 0.88rem;
    color: #64748b;
    line-height: 1.55;
    margin-bottom: 1.5rem;
}

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

.btn-modern-confirm {
    background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
    color: #ffffff;
    border: none;
    border-radius: 12px;
    padding: 10px 24px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-modern-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(79, 70, 229, 0.38);
}

.btn-modern-cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 20px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-modern-cancel:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Pulsing processing dots */
.modern-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    vertical-align: middle;
    margin-left: 4px;
}

.modern-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #4f46e5;
    animation: modernDotsBounce 1.4s infinite ease-in-out both;
}

.modern-dots span:nth-child(1) { animation-delay: -0.32s; }
.modern-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes modernDotsBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}
