/* ===== TOAST NOTIFICATION SYSTEM ===== */

/* Toast Container */
.toast-container {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    z-index: var(--z-notification);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
    max-width: 400px;
    width: 100%;
}

@media (max-width: 640px) {
    .toast-container {
        top: var(--space-4);
        right: var(--space-4);
        left: var(--space-4);
        max-width: none;
    }
}

/* Toast Notification */
.toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    min-height: 80px;
    pointer-events: auto;
    opacity: 0;
    transform: translateX(100%);
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%);
}

/* Toast Types */
.toast.success {
    border-left: 4px solid var(--success);
    background: linear-gradient(135deg, #ffffff 0%, #f0fdf4 100%);
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
    background: linear-gradient(135deg, #ffffff 0%, #fef2f2 100%);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
    background: linear-gradient(135deg, #ffffff 0%, #fffbeb 100%);
}

.toast.warning .toast-icon {
    color: var(--warning);
}

.toast.info {
    border-left: 4px solid var(--info);
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 100%);
}

.toast.info .toast-icon {
    color: var(--info);
}

/* Toast Content */
.toast-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 var(--space-1) 0;
    line-height: 1.4;
}

.toast-message {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
    word-wrap: break-word;
}

.toast-close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.toast-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.toast-close:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Toast Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--success);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    transition: width linear;
}

.toast.success .toast-progress {
    background: var(--success);
}

.toast.error .toast-progress {
    background: var(--danger);
}

.toast.warning .toast-progress {
    background: var(--warning);
}

.toast.info .toast-progress {
    background: var(--info);
}

/* Animation Keyframes */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Hover pause functionality */
.toast:hover .toast-progress {
    animation-play-state: paused !important;
}

/* Multiple toast stacking */
.toast:nth-child(1) {
    z-index: 10;
}

.toast:nth-child(2) {
    z-index: 9;
    transform: translateY(-4px) scale(0.98);
}

.toast:nth-child(3) {
    z-index: 8;
    transform: translateY(-8px) scale(0.96);
    opacity: 0.8;
}

.toast:nth-child(n+4) {
    display: none;
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity var(--transition-fast);
        transform: none !important;
    }
    
    @keyframes toastSlideIn,
    @keyframes toastSlideOut {
        from, to {
            transform: none;
        }
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .toast {
        border: 2px solid currentColor;
    }
    
    .toast.success {
        border-color: var(--success);
    }
    
    .toast.error {
        border-color: var(--danger);
    }
    
    .toast.warning {
        border-color: var(--warning);
    }
    
    .toast.info {
        border-color: var(--info);
    }
}

/* ===== DARK MODE OVERRIDES ===== */

/* Explicit dark theme */
[data-theme="dark"] .toast {
    background: #1c1f2e;
    border-color: #2a2d3a;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .toast.success {
    background: linear-gradient(135deg, #1c1f2e 0%, #132218 100%);
}

[data-theme="dark"] .toast.error {
    background: linear-gradient(135deg, #1c1f2e 0%, #2a1515 100%);
}

[data-theme="dark"] .toast.warning {
    background: linear-gradient(135deg, #1c1f2e 0%, #2a2515 100%);
}

[data-theme="dark"] .toast.info {
    background: linear-gradient(135deg, #1c1f2e 0%, #152230 100%);
}

[data-theme="dark"] .toast-title {
    color: #e2e8f0;
}

[data-theme="dark"] .toast-message {
    color: #94a3b8;
}

[data-theme="dark"] .toast-close {
    color: #64748b;
}

[data-theme="dark"] .toast-close:hover {
    background: #2a2d3a;
    color: #e2e8f0;
}

/* Auto theme respecting system preference */
@media (prefers-color-scheme: dark) {
    [data-theme="auto"] .toast {
        background: #1c1f2e;
        border-color: #2a2d3a;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    }

    [data-theme="auto"] .toast.success {
        background: linear-gradient(135deg, #1c1f2e 0%, #132218 100%);
    }

    [data-theme="auto"] .toast.error {
        background: linear-gradient(135deg, #1c1f2e 0%, #2a1515 100%);
    }

    [data-theme="auto"] .toast.warning {
        background: linear-gradient(135deg, #1c1f2e 0%, #2a2515 100%);
    }

    [data-theme="auto"] .toast.info {
        background: linear-gradient(135deg, #1c1f2e 0%, #152230 100%);
    }

    [data-theme="auto"] .toast-title {
        color: #e2e8f0;
    }

    [data-theme="auto"] .toast-message {
        color: #94a3b8;
    }

    [data-theme="auto"] .toast-close {
        color: #64748b;
    }

    [data-theme="auto"] .toast-close:hover {
        background: #2a2d3a;
        color: #e2e8f0;
    }
}