/**
 * FAANG-Level Toast Notification Styles
 * Production-grade, accessible, and performant notification system
 */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    margin-bottom: 12px;
    pointer-events: auto;
    transform: translateX(400px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    border-left: 4px solid;
    min-height: 60px;
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

/* Toast Types */
.toast-info {
    border-left-color: #3b82f6;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.05) 0%, rgba(147, 197, 253, 0.05) 100%);
}

.toast-success {
    border-left-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(52, 211, 153, 0.05) 100%);
}

.toast-warning {
    border-left-color: #f59e0b;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.05) 0%, rgba(251, 191, 36, 0.05) 100%);
}

.toast-error {
    border-left-color: #ef4444;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.05) 0%, rgba(248, 113, 113, 0.05) 100%);
}

/* Toast States */
.toast-show {
    transform: translateX(0);
    opacity: 1;
}

.toast-dismiss {
    transform: translateX(400px);
    opacity: 0;
}

/* Toast Header */
.toast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.toast-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #374151;
}

.toast-close:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Toast Body */
.toast-body {
    padding: 0 20px 16px;
}

.toast-message {
    font-size: 14px;
    color: #4b5563;
    line-height: 1.5;
    margin-bottom: 12px;
}

/* Toast Progress Bar */
.toast-progress {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    height: 6px;
    margin: 12px 0;
    overflow: hidden;
}

.toast-progress-bar {
    background: linear-gradient(90deg, #3b82f6, #1d4ed8);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 4px;
}

/* Toast Actions */
.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.toast-action-btn {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toast-action-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.toast-action-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.toast-action-btn:first-child {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.toast-action-btn:first-child:hover {
    background: #2563eb;
    border-color: #2563eb;
}

/* Dark Mode Support */
[data-theme="dark"] .toast {
    background: #1f2937;
    color: #f9fafb;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

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

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

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

[data-theme="dark"] .toast-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f3f4f6;
}

[data-theme="dark"] .toast-action-btn {
    background: #374151;
    border-color: #4b5563;
    color: #d1d5db;
}

[data-theme="dark"] .toast-action-btn:hover {
    background: #4b5563;
    border-color: #6b7280;
}

[data-theme="dark"] .toast-action-btn:first-child {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Animation for progress bars */
@keyframes progress-fill {
    from {
        width: 0%;
    }
    to {
        width: var(--progress-width, 100%);
    }
}

.toast-progress-bar.animate {
    animation: progress-fill 0.3s ease;
}

/* Responsive Design */
@media (max-width: 768px) {
    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
    
    .toast {
        transform: translateY(-100px);
    }
    
    .toast-show {
        transform: translateY(0);
    }
    
    .toast-dismiss {
        transform: translateY(-100px);
    }
}

/* Accessibility Improvements */
.toast {
    role: alert;
    aria-live: polite;
}

.toast-error {
    aria-live: assertive;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .toast {
        border: 2px solid;
        border-color: currentColor;
    }
    
    .toast-action-btn {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.2s ease;
    }
    
    .toast-progress-bar {
        transition: none;
    }
    
    .toast-show {
        transform: none;
    }
    
    .toast-dismiss {
        transform: none;
    }
}

/* Loading state for toast actions */
.toast-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.toast-action-btn.loading {
    position: relative;
    color: transparent;
}

.toast-action-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 12px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Focus management for accessibility */
.toast:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Toast stacking animation */
.toast:nth-child(n+4) {
    transform: translateX(400px) scale(0.95);
    opacity: 0;
    pointer-events: none;
}

.toast-show:nth-child(n+4) {
    transform: translateX(0) scale(0.95);
    opacity: 0.8;
}

/* Performance optimizations */
.toast {
    will-change: transform, opacity;
    contain: layout style paint;
}

/* Success state animation */
.toast-success .toast-progress-bar {
    background: linear-gradient(90deg, #10b981, #059669);
}

.toast-error .toast-progress-bar {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.toast-warning .toast-progress-bar {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}
