/* =========================================================
   ✦ NEXTEDU UNIVERSAL TOAST NOTIFICATION SYSTEM (iOS STUDIO EDITION)
   Fluid Frosted Glassmorphism, 120Hz Spring Easing, Light/Dark Modes
   Based on tost.php / tost.txt specification
   ========================================================= */

:root {
    --toast-font: "Poppins", -apple-system, BlinkMacSystemFont, "Plus Jakarta Sans", "Inter", sans-serif;
}

/* =========================================================
   TOAST CONTAINER (Fixed Overlay, Top-Right, Highest z-index)
   ========================================================= */
#toast-container,
#toastContainer,
#toast-cnt,
.toast-container {
    position: fixed !important;
    z-index: 99999999 !important;
    top: 18px !important;
    right: 18px !important;
    width: min(360px, calc(100vw - 28px)) !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    pointer-events: none !important;
}

/* Left & Bottom Position Modifiers if requested */
#toast-container.position-left,
#toastContainer.position-left {
    right: auto !important;
    left: 18px !important;
}

#toast-container.position-bottom,
#toastContainer.position-bottom {
    top: auto !important;
    bottom: 18px !important;
}

/* =========================================================
   TOAST CARD — Dark / Liquid Midnight (Default)
   ========================================================= */
.toast,
.premium-toast {
    --toast-accent: #9875ff;
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    overflow: hidden !important;
    padding: 13px 15px !important;
    border-radius: 18px !important;
    color: #f7f7fb !important;
    background: rgba(31, 31, 40, 0.94) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 14px 42px rgba(0, 0, 0, 0.32), 0 0 1px rgba(255, 255, 255, 0.12) !important;
    -webkit-backdrop-filter: blur(24px) saturate(160%) !important;
    backdrop-filter: blur(24px) saturate(160%) !important;
    pointer-events: auto !important;
    box-sizing: border-box !important;
    font-family: var(--toast-font) !important;
    animation: toast-enter 0.42s cubic-bezier(0.2, 0.9, 0.25, 1.15) both !important;
    will-change: transform, opacity !important;
    user-select: none !important;
}

/* =========================================================
   LIGHT MODE OVERRIDES
   ========================================================= */
html[data-theme="light"] .toast,
html[data-theme="light"] .premium-toast,
[data-theme="light"] .toast,
[data-theme="light"] .premium-toast {
    color: #191922 !important;
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(0, 0, 0, 0.07) !important;
    box-shadow: 0 14px 42px rgba(35, 35, 65, 0.14), 0 0 1px rgba(0, 0, 0, 0.08) !important;
}

/* =========================================================
   TYPE ACCENT PALETTES (Exact from tost.php)
   ========================================================= */
.toast.success, .premium-toast.success { --toast-accent: #35d69b; }
.toast.error, .premium-toast.error,
.toast.danger, .premium-toast.danger { --toast-accent: #ff637a; }
.toast.warning, .premium-toast.warning { --toast-accent: #ffbd52; }
.toast.info, .premium-toast.info { --toast-accent: #54baff; }
.toast.premium, .premium-toast.premium { --toast-accent: #bd91ff; }
.toast.loading, .premium-toast.loading { --toast-accent: #9875ff; }

/* =========================================================
   TOAST ICON / SYMBOL CAPSULE
   ========================================================= */
.toast-symbol,
.toast-icon {
    width: 38px !important;
    height: 38px !important;
    flex: 0 0 38px !important;
    display: grid !important;
    place-items: center !important;
    border-radius: 13px !important;
    color: var(--toast-accent) !important;
    background: color-mix(in srgb, var(--toast-accent) 18%, transparent) !important;
    border: 1px solid color-mix(in srgb, var(--toast-accent) 26%, transparent) !important;
    font-size: 18px !important;
    font-weight: 800 !important;
    line-height: 1 !important;
    box-shadow: 0 0 16px color-mix(in srgb, var(--toast-accent) 20%, transparent) !important;
    box-sizing: border-box !important;
    flex-shrink: 0 !important;
}

/* Fallback for older browsers without color-mix */
@supports not (background: color-mix(in srgb, red 10%, blue)) {
    .toast-symbol, .toast-icon {
        background: rgba(152, 117, 255, 0.18) !important;
        border-color: rgba(152, 117, 255, 0.28) !important;
    }
    .toast.success .toast-symbol, .toast.success .toast-icon { background: rgba(53, 214, 155, 0.18) !important; border-color: rgba(53, 214, 155, 0.28) !important; }
    .toast.error .toast-symbol, .toast.error .toast-icon { background: rgba(255, 99, 122, 0.18) !important; border-color: rgba(255, 99, 122, 0.28) !important; }
    .toast.warning .toast-symbol, .toast.warning .toast-icon { background: rgba(255, 189, 82, 0.18) !important; border-color: rgba(255, 189, 82, 0.28) !important; }
    .toast.info .toast-symbol, .toast.info .toast-icon { background: rgba(84, 186, 255, 0.18) !important; border-color: rgba(84, 186, 255, 0.28) !important; }
    .toast.premium .toast-symbol, .toast.premium .toast-icon { background: rgba(189, 145, 255, 0.18) !important; border-color: rgba(189, 145, 255, 0.28) !important; }
}

/* =========================================================
   TOAST CONTENT & COPY
   ========================================================= */
.toast-copy,
.toast-content {
    flex: 1 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

.toast-title {
    font-size: 12.5px !important;
    line-height: 1.4 !important;
    font-weight: 800 !important;
    letter-spacing: -0.2px !important;
    color: inherit !important;
}

.toast-message {
    margin-top: 2px !important;
    color: inherit !important;
    opacity: 0.72 !important;
    font-size: 11px !important;
    line-height: 1.5 !important;
    font-weight: 500 !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/* =========================================================
   DISMISS BUTTON
   ========================================================= */
.toast-dismiss,
.toast-close {
    padding: 3px 6px !important;
    color: inherit !important;
    background: transparent !important;
    border: none !important;
    opacity: 0.45 !important;
    font-size: 18px !important;
    line-height: 1 !important;
    cursor: pointer !important;
    border-radius: 8px !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.toast-dismiss:hover,
.toast-close:hover {
    opacity: 1 !important;
    transform: scale(1.1) !important;
}

/* =========================================================
   BOTTOM PROGRESS BAR
   ========================================================= */
.toast-progress {
    position: absolute !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 2px !important;
    background: var(--toast-accent) !important;
    transform-origin: left center !important;
    animation: toast-progress linear forwards !important;
    pointer-events: none !important;
}

/* =========================================================
   EXITING STATE
   ========================================================= */
.toast.is-leaving,
.premium-toast.is-leaving,
.toast.toast-hide,
.premium-toast.toast-hide {
    animation: toast-leave 0.24s cubic-bezier(0.4, 0, 0.2, 1) forwards !important;
    pointer-events: none !important;
}

/* =========================================================
   120Hz PROMOTION SPRING KEYFRAMES
   ========================================================= */
@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translate3d(24px, -8px, 0) scale(0.94);
        filter: blur(4px);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
        filter: blur(0);
    }
}

@keyframes toast-leave {
    to {
        opacity: 0;
        transform: translate3d(20px, -6px, 0) scale(0.96);
        filter: blur(4px);
    }
}

@keyframes toast-progress {
    to {
        transform: scaleX(0);
    }
}

@keyframes toast-spin {
    to {
        transform: rotate(360deg);
    }
}

.toast.loading .toast-symbol,
.toast.loading .toast-icon,
.premium-toast.loading .toast-symbol,
.premium-toast.loading .toast-icon {
    animation: toast-spin 1.1s linear infinite !important;
}

/* =========================================================
   MOBILE RESPONSIVENESS (< 650px)
   ========================================================= */
@media (max-width: 650px) {
    #toast-container,
    #toastContainer,
    #toast-cnt,
    .toast-container {
        top: 12px !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
    }
    .toast,
    .premium-toast {
        padding: 12px 14px !important;
        border-radius: 16px !important;
    }
    .toast-symbol,
    .toast-icon {
        width: 36px !important;
        height: 36px !important;
        flex: 0 0 36px !important;
        font-size: 16px !important;
    }
    .toast-title {
        font-size: 12px !important;
    }
    .toast-message {
        font-size: 10.5px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .premium-toast,
    .toast-symbol,
    .toast-progress {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* =========================================================
   🌊 3D LIQUID TOAST THEME INTEGRATION (Matches profile.html themes)
   ========================================================= */

/* 1. Gamify Neon Cyber Theme */
[data-ui-theme="gamify"] .toast,
[data-ui-theme="gamify"] .premium-toast {
    border-radius: 14px !important;
    background: linear-gradient(135deg, rgba(8, 12, 28, 0.95), rgba(4, 7, 17, 0.98)) !important;
    border: 1px solid rgba(0, 240, 255, 0.4) !important;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.7), 0 0 24px rgba(0, 240, 255, 0.25), inset 0 1px 2px rgba(0, 240, 255, 0.4) !important;
}
[data-theme="light"][data-ui-theme="gamify"] .toast,
[data-theme="light"][data-ui-theme="gamify"] .premium-toast {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(238, 242, 255, 0.95)) !important;
    border: 1.5px solid rgba(99, 102, 241, 0.4) !important;
    box-shadow: 0 16px 40px rgba(99, 102, 241, 0.2), inset 0 1px 1px #fff !important;
}

/* 2. Duolingo Tactile 3D Extrusion Theme */
[data-ui-theme="duolingo"] .toast,
[data-ui-theme="duolingo"] .premium-toast {
    border-radius: 20px !important;
    border: 2px solid #e5e7eb !important;
    border-bottom: 5px solid #cbd5e1 !important;
    background: #ffffff !important;
    color: #1e293b !important;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.1) !important;
}
[data-theme="dark"][data-ui-theme="duolingo"] .toast,
[data-theme="dark"][data-ui-theme="duolingo"] .premium-toast {
    background: #1e293b !important;
    color: #f8fafc !important;
    border: 2px solid #334155 !important;
    border-bottom: 5px solid #0f172a !important;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5) !important;
}

/* 3. iOS 18 / Liquid Specular Frosted Glass Theme */
[data-ui-theme="ios18"] .toast,
[data-ui-theme="ios18"] .premium-toast,
[data-ui-theme="liquid"] .toast,
[data-ui-theme="liquid"] .premium-toast {
    border-radius: 22px !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.04) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.28) !important;
    backdrop-filter: blur(32px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(32px) saturate(200%) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.45) !important;
}

/* 4. Zen / Minimalist Clean Theme */
[data-ui-theme="zen"] .toast,
[data-ui-theme="zen"] .premium-toast,
[data-ui-theme="minimalistic"] .toast,
[data-ui-theme="minimalistic"] .premium-toast {
    border-radius: 14px !important;
    background: rgba(30, 41, 59, 0.94) !important;
    border: 1px solid rgba(148, 163, 184, 0.2) !important;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22) !important;
}
[data-theme="light"][data-ui-theme="zen"] .toast,
[data-theme="light"][data-ui-theme="zen"] .premium-toast,
[data-theme="light"][data-ui-theme="minimalistic"] .toast,
[data-theme="light"][data-ui-theme="minimalistic"] .premium-toast {
    background: rgba(255, 255, 255, 0.96) !important;
    border: 1px solid rgba(203, 213, 225, 0.8) !important;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08) !important;
}

/* 5. Standard Nexus 3D Liquid Midnight Glow */
[data-ui-theme="standard"] .toast,
[data-ui-theme="standard"] .premium-toast,
:root:not([data-ui-theme]) .toast {
    border-radius: 20px !important;
    border: 1px solid rgba(139, 92, 246, 0.25) !important;
    box-shadow: 0 16px 45px rgba(0, 0, 0, 0.4), 0 0 28px rgba(139, 92, 246, 0.16), inset 0 1px 1px rgba(255, 255, 255, 0.18) !important;
}
