/* =====================================================
   MODULE: TOASTS & SNACKBARS
   Auto-dismissing notifications with stacking.
   Full per-theme overrides for all 4 themes.
   Toggle: modules.toasts in theme-config.json
   ===================================================== */

/* ============= TOAST CONTAINER ============= */
.toast-container {
    position: fixed;
    z-index: var(--z-toast, 1050);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
    max-width: 420px;
    width: calc(100% - 2rem);
}

/* Positions */
.toast-container.top-right    { top: 1rem; right: 1rem; }
.toast-container.top-left     { top: 1rem; left: 1rem; }
.toast-container.top-center   { top: 1rem; left: 50%; transform: translateX(-50%); }
.toast-container.bottom-right { bottom: 1rem; right: 1rem; }
.toast-container.bottom-left  { bottom: 1rem; left: 1rem; }
.toast-container.bottom-center{ bottom: 1rem; left: 50%; transform: translateX(-50%); }

/* ============= TOAST ============= */
.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg, 0.75rem);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    animation: toast-in var(--duration-normal, 250ms) var(--ease-bounce) forwards;
}

.toast.toast-exit {
    animation: toast-out var(--duration-fast, 150ms) var(--ease-in) forwards;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}

/* Left-side from top */
.toast-container.top-left .toast,
.toast-container.bottom-left .toast {
    animation-name: toast-in-left;
}
.toast-container.top-left .toast.toast-exit,
.toast-container.bottom-left .toast.toast-exit {
    animation-name: toast-out-left;
}
@keyframes toast-in-left {
    from { opacity: 0; transform: translateX(-100%); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes toast-out-left {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-100%); }
}

/* Center from top */
.toast-container.top-center .toast,
.toast-container.bottom-center .toast {
    animation-name: toast-in-center;
}
@keyframes toast-in-center {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ============= TOAST ICON ============= */
.toast-icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    margin-top: 0.1rem;
}

/* ============= TOAST CONTENT ============= */
.toast-content { flex: 1; min-width: 0; }
.toast-title {
    font-size: var(--font-size-sm, 0.875rem);
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
}
.toast-message {
    font-size: var(--font-size-xs, 0.75rem);
    color: var(--text-secondary);
    margin-top: 0.125rem;
    line-height: 1.4;
}

/* ============= TOAST CLOSE ============= */
.toast-close {
    flex-shrink: 0;
    width: 1.25rem; height: 1.25rem;
    display: flex; align-items: center; justify-content: center;
    background: none; border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: var(--radius-sm, 0.25rem);
    font-size: 1rem;
    line-height: 1;
    transition: color var(--duration-fast, 150ms), background var(--duration-fast, 150ms);
}
.toast-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ============= TOAST ACTION ============= */
.toast-action {
    font-size: var(--font-size-xs, 0.75rem);
    font-weight: 600;
    color: var(--accent);
    cursor: pointer;
    background: none; border: none;
    padding: 0;
    margin-top: 0.375rem;
    transition: color var(--duration-fast, 150ms);
}
.toast-action:hover { color: var(--accent-hover); }

/* ============= TOAST PROGRESS BAR ============= */
.toast-progress {
    position: absolute;
    bottom: 0; left: 0;
    height: 3px;
    border-radius: 0 0 var(--radius-lg, 0.75rem) var(--radius-lg, 0.75rem);
    animation: toast-progress-shrink linear forwards;
}
@keyframes toast-progress-shrink {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ============= SEVERITY VARIANTS ============= */
.toast-success { border-left: 3px solid var(--color-success); }
.toast-success .toast-icon { color: var(--color-success); }
.toast-success .toast-progress { background: var(--color-success); }

.toast-error { border-left: 3px solid var(--color-danger); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-error .toast-progress { background: var(--color-danger); }

.toast-warning { border-left: 3px solid var(--color-warning); }
.toast-warning .toast-icon { color: var(--color-warning); }
.toast-warning .toast-progress { background: var(--color-warning); }

.toast-info { border-left: 3px solid var(--color-info); }
.toast-info .toast-icon { color: var(--color-info); }
.toast-info .toast-progress { background: var(--color-info); }

/* ============= SNACKBAR (bottom bar variant) ============= */
.snackbar {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    z-index: var(--z-toast, 1050);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg, 0.75rem);
    box-shadow: var(--shadow-lg);
    font-size: var(--font-size-sm, 0.875rem);
    color: var(--text-primary);
    opacity: 0;
    transition: opacity var(--duration-normal, 250ms) var(--ease-out),
                transform var(--duration-normal, 250ms) var(--ease-bounce);
}
.snackbar.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
.snackbar-action {
    font-weight: 700;
    color: var(--accent);
    cursor: pointer;
    background: none; border: none;
    padding: 0;
    white-space: nowrap;
}

/* ============= BLACK GLASS ============= */
[data-theme="black-glass"] .toast {
    background: rgba(15, 18, 25, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-color: rgba(255, 255, 255, 0.06);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}
[data-theme="black-glass"] .toast-success { border-left-color: #22c55e; box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 8px rgba(34,197,94,0.15); }
[data-theme="black-glass"] .toast-error   { border-left-color: #ef4444; box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 8px rgba(239,68,68,0.15); }
[data-theme="black-glass"] .snackbar {
    background: rgba(15, 18, 25, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* ============= WHITE GLASS ============= */
[data-theme="white-glass"] .toast {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-color: rgba(0, 0, 0, 0.06);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}
[data-theme="white-glass"] .snackbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* ============= RETRO 95 ============= */
[data-theme="retro"] .toast {
    border-radius: 0;
    border: none;
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #ffffff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
    background: #c0c0c0;
    border-left: none;
}
[data-theme="retro"] .toast-success,
[data-theme="retro"] .toast-error,
[data-theme="retro"] .toast-warning,
[data-theme="retro"] .toast-info { border-left: 4px solid; }
[data-theme="retro"] .toast-title { font-family: "MS Sans Serif", Tahoma, sans-serif; }
[data-theme="retro"] .toast-close {
    font-family: "MS Sans Serif", Tahoma, sans-serif;
    font-weight: 700;
}
[data-theme="retro"] .toast-progress { border-radius: 0; }
[data-theme="retro"] .snackbar {
    border-radius: 0;
    border: none;
    box-shadow: inset -1px -1px #0a0a0a, inset 1px 1px #ffffff, inset -2px -2px #808080, inset 2px 2px #dfdfdf;
    background: #c0c0c0;
}

/* ============= HOMEBREW ============= */
[data-theme="homebrew"] .toast {
    background: #0a0e14;
    border: 1px solid rgba(0, 255, 0, 0.2);
    border-radius: 0;
    box-shadow: 0 0 8px rgba(0, 255, 0, 0.08);
}
[data-theme="homebrew"] .toast-title { color: #00ff00; }
[data-theme="homebrew"] .toast-message { color: #00cc00; }
[data-theme="homebrew"] .toast-close { color: #008800; }
[data-theme="homebrew"] .toast-close:hover { color: #00ff00; background: rgba(0, 255, 0, 0.06); }
[data-theme="homebrew"] .toast-success { border-left-color: #00ff00; }
[data-theme="homebrew"] .toast-error   { border-left-color: #ff4444; }
[data-theme="homebrew"] .toast-warning { border-left-color: #00cc00; }
[data-theme="homebrew"] .toast-info    { border-left-color: #00ff00; }
[data-theme="homebrew"] .toast-progress { border-radius: 0; }
[data-theme="homebrew"] .snackbar {
    background: #0a0e14;
    border: 1px solid rgba(0, 255, 0, 0.2);
    border-radius: 0;
    color: #00ff00;
}
[data-theme="homebrew"] .snackbar-action { color: #00ff00; }

/* ============= SKEUOMORPHIC THEME ============= */
[data-theme="skeuomorphic"] .toast {
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(0,0,0,0.15), inset 0 1px 0 rgba(255,255,255,0.8);
    backdrop-filter: none;
    border: 1px solid rgba(0,0,0,0.08);
}
