/*
 * Websly 5.1 — Toast Notification Primitive
 *
 * Styles for the global toast system. Controlled via:
 *   window.webslyToastConfig  (injected by header.php from Customizer)
 *
 * Usage: websly_show_toast('Message here', 'success' | 'error' | 'info' | 'warning')
 *
 * Architecture: Single #ws-toast-host container, position driven by data-position attr.
 * Individual toasts stack with gap; oldest is auto-dismissed on overflow.
 */

/* ── Container (position variants) ───────────────────────────────────────── */
#ws-toast-host {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    pointer-events: none;
    max-width: min(22rem, calc(100vw - 2rem));
}

#ws-toast-host[data-position="bottom-right"] {
    bottom: 1.5rem;
    right: 1.5rem;
    align-items: flex-end;
}
#ws-toast-host[data-position="bottom-left"] {
    bottom: 1.5rem;
    left: 1.5rem;
    align-items: flex-start;
}
#ws-toast-host[data-position="bottom-center"] {
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}
#ws-toast-host[data-position="top-right"] {
    top: 1.5rem;
    right: 1.5rem;
    align-items: flex-end;
    flex-direction: column-reverse;
}
#ws-toast-host[data-position="top-left"] {
    top: 1.5rem;
    left: 1.5rem;
    align-items: flex-start;
    flex-direction: column-reverse;
}
#ws-toast-host[data-position="top-center"] {
    top: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
    flex-direction: column-reverse;
}

/* ── Toast Base Card ──────────────────────────────────────────────────────── */
.ws-toast {
    pointer-events: all;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1.125rem;
    min-width: 16rem;
    max-width: 22rem;
    font-family: var(--font-body, 'Inter', system-ui, sans-serif);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
    position: relative;
    overflow: hidden;
    will-change: transform, opacity;
    cursor: pointer;
    user-select: none;
}

/* Progress bar (auto-dismiss indicator) */
.ws-toast::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: currentColor;
    opacity: 0.25;
    transform-origin: left center;
    animation: ws-toast-progress linear forwards;
    animation-duration: var(--ws-toast-duration, 4s);
}

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

/* Icon wrapper */
.ws-toast__icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.0625rem;
}

.ws-toast__icon svg {
    width: 1.125rem;
    height: 1.125rem;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Message */
.ws-toast__msg {
    flex: 1;
}

/* Dismiss X */
.ws-toast__close {
    flex-shrink: 0;
    opacity: 0.45;
    line-height: 1;
    font-size: 1rem;
    margin-left: 0.25rem;
    cursor: pointer;
    transition: opacity 0.15s;
    background: none;
    border: none;
    color: inherit;
    padding: 0;
}
.ws-toast__close:hover { opacity: 0.85; }


/* ── Radius variants (data-radius on #ws-toast-host) ─────────────────────── */
#ws-toast-host[data-radius="none"]  .ws-toast { border-radius: 0; }
#ws-toast-host[data-radius="sm"]    .ws-toast { border-radius: 0.375rem; }
#ws-toast-host[data-radius="md"]    .ws-toast { border-radius: 0.625rem; }
#ws-toast-host[data-radius="lg"]    .ws-toast { border-radius: 0.875rem; }
#ws-toast-host[data-radius="xl"]    .ws-toast { border-radius: 1.25rem; }
#ws-toast-host[data-radius="pill"]  .ws-toast { border-radius: 9999px; padding-left: 1.375rem; padding-right: 1.375rem; }


/* ── Style Presets ────────────────────────────────────────────────────────── */

/* 1. Glass (default) */
.ws-toast--glass {
    background: color-mix(in srgb, var(--bg-surface, #fff) 72%, transparent);
    backdrop-filter: blur(20px) saturate(1.8);
    -webkit-backdrop-filter: blur(20px) saturate(1.8);
    border: 1px solid color-mix(in srgb, var(--text-base, #1e293b) 10%, transparent);
    box-shadow:
        0 4px 24px -4px rgba(0,0,0,0.12),
        inset 0 1px 0 rgba(255,255,255,0.3);
    color: var(--text-base, #1e293b);
}
.dark .ws-toast--glass {
    background: color-mix(in srgb, var(--bg-surface, #1e2535) 70%, transparent);
    border-color: rgba(255,255,255,0.08);
    box-shadow: 0 4px 24px -4px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.06);
    color: var(--text-base, #e2e8f0);
}

/* 2. Solid Dark */
.ws-toast--solid-dark {
    background: #0f172a;
    border: 1px solid rgba(255,255,255,0.08);
    box-shadow: 0 8px 32px -8px rgba(0,0,0,0.5);
    color: #f1f5f9;
}

/* 3. Solid Accent */
.ws-toast--solid-accent {
    background: var(--theme-accent, #3b82f6);
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 8px 32px -8px color-mix(in srgb, var(--theme-accent, #3b82f6) 40%, transparent);
    color: var(--text-on-accent, #fff);
}

/* 4. Solid Success */
.ws-toast--solid-success {
    background: #16a34a;
    border: 1px solid rgba(255,255,255,0.15);
    box-shadow: 0 8px 32px -8px rgba(22,163,74,0.4);
    color: #fff;
}
/* Override for error type on solid-success style */
.ws-toast--solid-success.ws-toast--error {
    background: #dc2626;
    box-shadow: 0 8px 32px -8px rgba(220,38,38,0.4);
}

/* 5. Frosted Glow */
.ws-toast--frosted-glow {
    background: color-mix(in srgb, var(--bg-surface, #fff) 65%, var(--theme-accent, #3b82f6) 8%);
    backdrop-filter: blur(24px) saturate(2);
    -webkit-backdrop-filter: blur(24px) saturate(2);
    border: 1px solid color-mix(in srgb, var(--theme-accent, #3b82f6) 30%, transparent);
    box-shadow:
        0 0 20px color-mix(in srgb, var(--theme-accent, #3b82f6) 20%, transparent),
        0 4px 24px -4px rgba(0,0,0,0.15),
        inset 0 1px 0 rgba(255,255,255,0.25);
    color: var(--text-base, #1e293b);
}
.dark .ws-toast--frosted-glow {
    background: color-mix(in srgb, var(--bg-surface, #1e2535) 60%, var(--theme-accent, #3b82f6) 10%);
    color: var(--text-base, #e2e8f0);
}

/* 6. Neumorphic */
.ws-toast--neumorphic {
    background: var(--bg-surface, #f0f4f8);
    border: none;
    box-shadow:
        8px 8px 20px rgba(0,0,0,0.1),
        -6px -6px 16px rgba(255,255,255,0.7),
        inset 1px 1px 0 rgba(255,255,255,0.5);
    color: var(--text-base, #1e293b);
}
.dark .ws-toast--neumorphic {
    background: var(--bg-surface, #1e2535);
    box-shadow:
        8px 8px 20px rgba(0,0,0,0.35),
        -6px -6px 16px rgba(255,255,255,0.04),
        inset 1px 1px 0 rgba(255,255,255,0.04);
    color: var(--text-base, #e2e8f0);
}

/* 7. Minimal Border */
.ws-toast--minimal-border {
    background: transparent;
    border: 2px solid var(--text-base, #1e293b);
    box-shadow: none;
    color: var(--text-base, #1e293b);
    backdrop-filter: none;
}
.dark .ws-toast--minimal-border {
    border-color: var(--text-base, #e2e8f0);
    color: var(--text-base, #e2e8f0);
}


/* ── Type-based Icon/Accent Colour ───────────────────────────────────────── */
/* Success */
.ws-toast--success .ws-toast__icon { color: #16a34a; }
.ws-toast--solid-dark.ws-toast--success .ws-toast__icon,
.ws-toast--solid-accent.ws-toast--success .ws-toast__icon,
.ws-toast--solid-success.ws-toast--success .ws-toast__icon { color: #bbf7d0; }

/* Error */
.ws-toast--error .ws-toast__icon { color: #dc2626; }
.ws-toast--solid-dark.ws-toast--error .ws-toast__icon,
.ws-toast--solid-accent.ws-toast--error .ws-toast__icon { color: #fca5a5; }

/* Warning */
.ws-toast--warning .ws-toast__icon { color: #d97706; }

/* Info */
.ws-toast--info .ws-toast__icon { color: var(--theme-accent, #3b82f6); }


/* ── Entry Animations ─────────────────────────────────────────────────────── */
.ws-toast[data-anim="slide-up"] {
    animation: ws-toast-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.ws-toast[data-anim="slide-down"] {
    animation: ws-toast-slide-down 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.ws-toast[data-anim="fade"] {
    animation: ws-toast-fade 0.35s ease forwards;
}
.ws-toast[data-anim="scale-in"] {
    animation: ws-toast-scale-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.ws-toast[data-anim="bounce"] {
    animation: ws-toast-bounce 0.55s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Exit (applied via JS by adding .ws-toast--exiting) */
.ws-toast--exiting {
    animation: ws-toast-exit 0.3s cubic-bezier(0.4, 0, 1, 1) forwards !important;
}

@keyframes ws-toast-slide-up {
    from { opacity: 0; transform: translateY(1.5rem) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes ws-toast-slide-down {
    from { opacity: 0; transform: translateY(-1.5rem) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes ws-toast-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes ws-toast-scale-in {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes ws-toast-bounce {
    from { opacity: 0; transform: scale(0.7) translateY(1rem); }
    60%  { transform: scale(1.04) translateY(-0.25rem); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes ws-toast-exit {
    from { opacity: 1; transform: scale(1) translateX(0); max-height: 5rem; margin-bottom: 0; }
    to   { opacity: 0; transform: scale(0.92) translateX(1rem); max-height: 0; margin-bottom: -0.625rem; }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    .ws-toast,
    .ws-toast--exiting,
    .ws-toast::after {
        animation: none !important;
        transition: opacity 0.2s ease !important;
    }
    .ws-toast--exiting { opacity: 0 !important; }
}
