/**
 * Toast Alert System – uses design tokens only (design-tokens.css must load first).
 */

.toast-container {
    position: fixed;
    top: var(--space-5);
    right: var(--space-5);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    max-width: 420px;
    pointer-events: none;
}

.toast-alert {
    display: flex;
    align-items: flex-start;
    gap: var(--alert-gap);
    padding: var(--alert-padding-y) var(--alert-padding-x);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-toast);
    border-left: 4px solid;
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    backdrop-filter: blur(10px);
    min-width: 320px;
    position: relative;
}

.toast-alert.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-alert.hide {
    transform: translateX(120%);
    opacity: 0;
}

.toast-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: var(--text-lg);
    font-weight: var(--font-weight-bold);
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: var(--font-weight-bold);
    font-size: var(--text-md);
    margin-bottom: var(--space-1);
    line-height: var(--text-line-height-tight);
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--alert-success-message);
    line-height: var(--text-line-height-normal);
    word-wrap: break-word;
}

.toast-close {
    width: 1.75rem;
    height: 1.75rem;
    border: none;
    background: var(--alert-close-bg);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: var(--text-sm);
    color: var(--alert-close-color);
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    background: var(--alert-close-hover-bg);
    color: var(--alert-close-hover-color);
    transform: scale(1.1);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: var(--space-1);
    right: 0;
    height: 3px;
    background: var(--alert-close-bg);
    border-radius: 0 0 var(--radius-lg) 0;
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background: currentColor;
    opacity: 0.4;
    width: 100%;
    animation: toast-progress-shrink linear forwards;
}

@keyframes toast-progress-shrink {
    from { width: 100%; }
    to { width: 0%; }
}

/* Toast variants – tokens only */
.toast-success {
    border-color: var(--alert-success-border);
}
.toast-success .toast-icon {
    background: var(--alert-success-icon-bg);
    color: var(--alert-success-icon-color);
}
.toast-success .toast-title {
    color: var(--alert-success-title);
}
.toast-success .toast-message {
    color: var(--alert-success-message);
}
.toast-success .toast-progress-bar {
    background: var(--color-success);
}

.toast-error {
    border-color: var(--alert-error-border);
}
.toast-error .toast-icon {
    background: var(--alert-error-icon-bg);
    color: var(--alert-error-icon-color);
}
.toast-error .toast-title {
    color: var(--alert-error-title);
}
.toast-error .toast-message {
    color: var(--alert-error-message);
}
.toast-error .toast-progress-bar {
    background: var(--color-danger);
}

.toast-warning {
    border-color: var(--alert-warning-border);
}
.toast-warning .toast-icon {
    background: var(--alert-warning-icon-bg);
    color: var(--alert-warning-icon-color);
}
.toast-warning .toast-title {
    color: var(--alert-warning-title);
}
.toast-warning .toast-message {
    color: var(--alert-warning-message);
}
.toast-warning .toast-progress-bar {
    background: var(--color-warning);
}

.toast-info {
    border-color: var(--alert-info-border);
}
.toast-info .toast-icon {
    background: var(--alert-info-icon-bg);
    color: var(--alert-info-icon-color);
}
.toast-info .toast-title {
    color: var(--alert-info-title);
}
.toast-info .toast-message {
    color: var(--alert-info-message);
}
.toast-info .toast-progress-bar {
    background: var(--color-info);
}

@keyframes toast-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.toast-alert.shake {
    animation: toast-shake 0.5s ease-in-out;
}

@keyframes toast-bounce-in {
    0% { transform: translateX(120%) scale(0.8); opacity: 0; }
    50% { transform: translateX(-10px) scale(1.02); opacity: 1; }
    70% { transform: translateX(5px) scale(0.98); }
    100% { transform: translateX(0) scale(1); opacity: 1; }
}

.toast-alert.bounce-in {
    animation: toast-bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes toast-pulse {
    0%, 100% { box-shadow: var(--shadow-toast); }
    50% { box-shadow: 0 10px 40px rgba(59, 130, 246, 0.3), 0 4px 12px rgba(59, 130, 246, 0.2); }
}

.toast-info.show {
    animation: toast-pulse 2s ease-in-out infinite;
}

@media (max-width: 480px) {
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        max-width: none;
    }
    .toast-alert {
        min-width: auto;
    }
    .toast-icon {
        width: 2.25rem;
        height: 2.25rem;
        font-size: var(--text-lg);
    }
    .toast-title {
        font-size: var(--text-sm);
    }
    .toast-message {
        font-size: var(--text-xs);
    }
}

[data-theme="dark"] .toast-alert,
.dark-mode .toast-alert {
    background: var(--color-surface);
    box-shadow: var(--shadow-toast);
}

[data-theme="dark"] .toast-message,
.dark-mode .toast-message {
    color: var(--color-text-secondary);
}

[data-theme="dark"] .toast-close,
.dark-mode .toast-close {
    background: var(--alert-close-bg);
    color: var(--alert-close-color);
}

[data-theme="dark"] .toast-close:hover,
.dark-mode .toast-close:hover {
    background: var(--alert-close-hover-bg);
    color: var(--alert-close-hover-color);
}
