/* =====================================================================
   modern-toast.css  -  Glossy, theme-aware popup (top-right) for SweetAlert2
   Path: ui/ui/styles/modern-toast.css
   Colors follow the active theme variables (--surface, --primary, ...)
   Only the page content blurs; sidebar + top bar stay sharp.
===================================================================== */

/* ---------- Blur ONLY the page area (not menu / top bar) ---------- */
.content-wrapper { transition: filter .3s ease, opacity .3s ease; }
body.swal2-shown .content-wrapper {
    filter: blur(var(--mt-blur, 9px)) saturate(115%);
    opacity: .82;
}
/* no full-screen backdrop (it would blur the menu too) */
.swal2-container.swal2-backdrop-show,
.swal2-container.swal2-noanimation { background: transparent !important; -webkit-backdrop-filter: none; backdrop-filter: none; }
.swal2-container.swal2-top-end { padding: 74px 18px 0 0 !important; align-items: flex-start; }
@media (max-width: 575px) {
    .swal2-container.swal2-top-end { padding: 66px 10px 0 10px !important; justify-content: center; }
}

/* ---------- Glossy popup ---------- */
.swal2-popup:not(.swal2-toast) {
    --mt-accent: var(--primary, #1d6fe8);
    --mt-accent-rgb: var(--primary-rgb, 29, 111, 232);
    position: relative;
    overflow: hidden;
    width: min(92vw, 400px) !important;
    padding: 30px 26px 28px !important;
    border-radius: 22px !important;
    border: 1px solid color-mix(in srgb, var(--mt-accent) 28%, rgba(255,255,255,.6)) !important;
    background:
        linear-gradient(160deg,
            color-mix(in srgb, var(--surface, #fff) 94%, #fff) 0%,
            color-mix(in srgb, var(--surface, #fff) 90%, var(--mt-accent)) 100%) !important;
    color: var(--text, #44536f);
    -webkit-backdrop-filter: blur(20px) saturate(170%);
    backdrop-filter: blur(20px) saturate(170%);
    box-shadow:
        0 28px 60px -16px rgba(var(--mt-accent-rgb), .45),
        0 6px 16px rgba(0, 0, 0, .14),
        inset 0 1px 0 rgba(255, 255, 255, .8),
        inset 0 -1px 0 rgba(0, 0, 0, .06) !important;
}
.swal2-popup:not(.swal2-toast)::before {          /* gloss sheen */
    content: "";
    position: absolute; left: -25%; right: -25%; top: -65%; height: 100%;
    background: linear-gradient(180deg, rgba(255,255,255,.7), rgba(255,255,255,0) 70%);
    border-radius: 50%; pointer-events: none; opacity: .5;
}
.swal2-popup:not(.swal2-toast) > * { position: relative; z-index: 1; }

/* success follows the theme color; error / warning keep their meaning */
.swal2-popup.mt-success { --mt-accent: var(--primary, #1d6fe8); --mt-accent-rgb: var(--primary-rgb, 29,111,232); }
.swal2-popup.mt-error   { --mt-accent: #ef4444; --mt-accent-rgb: 239, 68, 68; }
.swal2-popup.mt-warning { --mt-accent: #f59e0b; --mt-accent-rgb: 245, 158, 11; }
.swal2-popup.mt-info    { --mt-accent: #3b82f6; --mt-accent-rgb: 59, 130, 246; }

.swal2-popup:not(.swal2-toast) .swal2-title {
    margin: 4px 0 0 !important; padding: 0 !important;
    font-size: 20px !important; font-weight: 700 !important; line-height: 1.35;
    color: var(--text-strong, #0f1b3d) !important;
}
.swal2-popup:not(.swal2-toast) .swal2-html-container { color: var(--text, #44536f) !important; }

.swal2-popup:not(.swal2-toast) .swal2-icon {
    margin: 2px auto 12px !important;
    border-color: rgba(var(--mt-accent-rgb), .45) !important;
    color: var(--mt-accent) !important;
    background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.85), rgba(var(--mt-accent-rgb), .12) 70%);
    box-shadow: 0 8px 22px -8px rgba(var(--mt-accent-rgb), .7), inset 0 2px 4px rgba(255,255,255,.7);
}
.swal2-popup .swal2-icon.swal2-success [class^=swal2-success-line] { background-color: var(--mt-accent) !important; }
.swal2-popup .swal2-icon.swal2-success .swal2-success-ring { border-color: rgba(var(--mt-accent-rgb), .3) !important; }
.swal2-popup .swal2-icon.swal2-success [class^=swal2-success-circular-line],
.swal2-popup .swal2-icon.swal2-success .swal2-success-fix { background: transparent !important; }
.swal2-popup .swal2-icon.swal2-error [class^=swal2-x-mark-line] { background-color: var(--mt-accent) !important; }

/* seconds counter (top-right corner of the popup) */
.swal2-popup .mt-count {
    position: absolute !important; top: 12px; right: 12px; z-index: 3;
    min-width: 34px; height: 34px; padding: 0 8px; box-sizing: border-box;
    display: flex; align-items: baseline; justify-content: center; gap: 1px;
    padding-top: 7px;
    border-radius: 999px;
    font-size: 14px; line-height: 1; font-weight: 700;
    color: var(--mt-accent);
    background: rgba(var(--mt-accent-rgb), .12);
    border: 1px solid rgba(var(--mt-accent-rgb), .3);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}
.swal2-popup .mt-count i { font-style: normal; font-size: 10px; font-weight: 600; opacity: .8; }

/* progress bar */
.swal2-popup:not(.swal2-toast) .swal2-timer-progress-bar-container {
    bottom: 0; top: auto; height: 4px; background: rgba(var(--mt-accent-rgb), .12); border-radius: 0;
}
.swal2-popup:not(.swal2-toast) .swal2-timer-progress-bar {
    background: linear-gradient(90deg, var(--mt-accent), color-mix(in srgb, var(--mt-accent) 55%, #fff)) !important;
}

/* buttons for confirm / delete dialogs */
.swal2-popup:not(.swal2-toast) .swal2-styled {
    border-radius: 12px !important; padding: 10px 24px !important; font-weight: 600;
    box-shadow: 0 8px 18px -8px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35) !important;
    transition: transform .15s, filter .15s;
}
.swal2-popup:not(.swal2-toast) .swal2-styled:hover { transform: translateY(-1px); filter: brightness(1.07); }


/* ---------- Dark mode (surface/text variables switch automatically) ---------- */
body.dark-mode .swal2-popup:not(.swal2-toast) {
    border-color: rgba(var(--mt-accent-rgb), .35) !important;
    background:
        linear-gradient(160deg,
            color-mix(in srgb, var(--surface, #181c30) 92%, #fff) 0%,
            color-mix(in srgb, var(--surface, #181c30) 86%, var(--mt-accent)) 100%) !important;
    box-shadow:
        0 30px 70px -16px rgba(0,0,0,.85),
        0 0 28px -10px rgba(var(--mt-accent-rgb), .5),
        inset 0 1px 0 rgba(255,255,255,.2),
        inset 0 -1px 0 rgba(0,0,0,.4) !important;
}
body.dark-mode .swal2-popup:not(.swal2-toast)::before { opacity: .14; }
body.dark-mode .swal2-popup:not(.swal2-toast) .swal2-title { color: var(--text-strong, #f1f4ff) !important; }
body.dark-mode .swal2-popup:not(.swal2-toast) .swal2-icon {
    background: radial-gradient(circle at 30% 25%, rgba(255,255,255,.16), rgba(var(--mt-accent-rgb), .2) 70%);
    box-shadow: 0 8px 26px -8px rgba(var(--mt-accent-rgb), .8), inset 0 2px 4px rgba(255,255,255,.12);
}
body.dark-mode .swal2-popup .mt-count { box-shadow: none; background: rgba(var(--mt-accent-rgb), .2); }


/* =====================================================================
   ANIMATIONS
===================================================================== */
/* enter: slide in from the right with a soft spring + de-blur */
.swal2-popup.mt-in {
    animation: mtIn .6s cubic-bezier(.16, 1, .3, 1) both;
    will-change: transform, opacity, filter;
}
@keyframes mtIn {
    0%   { opacity: 0; transform: translateX(90px) scale(.88) rotate(2.5deg); filter: blur(10px); }
    55%  { opacity: 1; transform: translateX(-8px) scale(1.025) rotate(-.4deg); filter: blur(0); }
    80%  { transform: translateX(2px) scale(.995) rotate(0); }
    100% { opacity: 1; transform: translateX(0) scale(1) rotate(0); filter: blur(0); }
}
/* leave: smooth slide out + shrink + fade */
.swal2-popup.mt-out {
    animation: mtOut .42s cubic-bezier(.5, 0, .75, 0) both;
    pointer-events: none;
}
@keyframes mtOut {
    0%   { opacity: 1; transform: translateX(0) scale(1); filter: blur(0); }
    25%  { transform: translateX(-10px) scale(1.02); }
    100% { opacity: 0; transform: translateX(110px) scale(.86) rotate(2deg); filter: blur(8px); }
}

/* content staggers in */
.swal2-popup.mt-in .swal2-title { animation: mtUp .55s .22s cubic-bezier(.2, .9, .3, 1) both; }
.swal2-popup.mt-in .swal2-html-container { animation: mtUp .55s .3s cubic-bezier(.2, .9, .3, 1) both; }
@keyframes mtUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* icon: pop + breathing ring */
.swal2-popup.mt-in .swal2-icon {
    animation: mtIconPop .7s .12s cubic-bezier(.2, 1.4, .4, 1) both, mtRing 2.2s 0.9s ease-out infinite;
}
@keyframes mtIconPop {
    0%   { transform: scale(.2) rotate(-25deg); opacity: 0; }
    60%  { transform: scale(1.14) rotate(6deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes mtRing {
    0%   { box-shadow: 0 0 0 0 rgba(var(--mt-accent-rgb), .45), 0 8px 22px -8px rgba(var(--mt-accent-rgb), .7), inset 0 2px 4px rgba(255,255,255,.7); }
    80%, 100% { box-shadow: 0 0 0 18px rgba(var(--mt-accent-rgb), 0), 0 8px 22px -8px rgba(var(--mt-accent-rgb), .7), inset 0 2px 4px rgba(255,255,255,.7); }
}

/* gloss sweep running across the popup */
.swal2-popup:not(.swal2-toast)::after {
    content: "";
    position: absolute; top: -20%; bottom: -20%; left: 0; width: 38%;
    background: linear-gradient(100deg, rgba(255,255,255,0), rgba(255,255,255,.55), rgba(255,255,255,0));
    transform: translateX(-160%) skewX(-20deg);
    animation: mtSweep 3.4s .7s ease-in-out infinite;
    pointer-events: none; z-index: 2; opacity: .8;
}
@keyframes mtSweep {
    0%   { transform: translateX(-160%) skewX(-20deg); }
    45%, 100% { transform: translateX(360%) skewX(-20deg); }
}
body.dark-mode .swal2-popup:not(.swal2-toast)::after { opacity: .28; }

/* border glow breathing */
.swal2-popup.mt-in:not(.mt-out) { animation-name: mtIn, mtGlow; animation-duration: .6s, 2.6s; animation-delay: 0s, .7s;
    animation-iteration-count: 1, infinite; animation-timing-function: cubic-bezier(.16,1,.3,1), ease-in-out; animation-fill-mode: both, none; }
@keyframes mtGlow {
    0%, 100% { border-color: rgba(var(--mt-accent-rgb), .28); }
    50%      { border-color: rgba(var(--mt-accent-rgb), .7); }
}

/* counter badge: pops on each tick, pulses when time is almost up */
.swal2-popup.mt-in .mt-count { animation: mtBadgeIn .5s .35s cubic-bezier(.2, 1.5, .4, 1) both; }
@keyframes mtBadgeIn { from { transform: scale(0) rotate(-90deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }
.mt-count b { display: inline-block; }
.mt-count b.mt-tick { animation: mtTick .45s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes mtTick { 0% { transform: translateY(-8px) scale(.5); opacity: 0; } 100% { transform: translateY(0) scale(1); opacity: 1; } }
.mt-count.mt-hurry { animation: mtHurry .5s ease-in-out infinite alternate !important; }
@keyframes mtHurry { from { transform: scale(1); } to { transform: scale(1.14); box-shadow: 0 0 0 5px rgba(var(--mt-accent-rgb), .15); } }

/* progress bar glides */
.swal2-popup:not(.swal2-toast) .swal2-timer-progress-bar { border-radius: 0 4px 4px 0; box-shadow: 0 0 10px rgba(var(--mt-accent-rgb), .7); }

/* page content blur: eases in fast, then fades out linearly over the whole countdown */
.content-wrapper { transition: filter .35s ease, opacity .35s ease; }
body.swal2-shown.mt-blur-run .content-wrapper {
    transition: filter var(--mt-secs, 5s) linear, opacity var(--mt-secs, 5s) linear;
    opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
    .swal2-popup *, .swal2-popup, .swal2-popup::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}
