/**
 * Toast Notification System
 *
 * A unified, accessible toast notification system following Azure Portal design principles.
 * Supports light and dark modes, with smooth animations and proper accessibility.
 *
 * Usage:
 *   Toast.show('Operation successful', 'success');
 *   Toast.show('Processing...', 'info', { action: { text: 'View', callback: () => {} } });
 */

/* Toast Container - Fixed positioning in bottom-right */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: 12px;
    max-width: 400px;
    pointer-events: none;
}

/* Individual Toast */
.toast-notification {
    pointer-events: all;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    min-height: 64px;
    max-width: 400px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: bottom right;
}

/* Toast Animation States */
.toast-notification.toast-entering {
    animation: toastSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.toast-notification.toast-exiting {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(400px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 200px;
        margin-bottom: 12px;
    }
    to {
        opacity: 0;
        transform: translateX(400px) scale(0.95);
        max-height: 0;
        margin-bottom: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
}

/* Toast Icon */
.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-top: 2px;
}

/* Toast Content */
.toast-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast-message {
    font-size: 14px;
    line-height: 1.5;
    font-weight: 500;
    word-wrap: break-word;
}

.toast-description {
    font-size: 13px;
    line-height: 1.4;
    opacity: 0.9;
}

/* Toast Actions */
.toast-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.toast-action-btn {
    background: none;
    border: none;
    padding: 4px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
}

.toast-action-btn:hover {
    opacity: 0.8;
}

/* Close Button */
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    border-radius: 3px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    margin-top: -2px;
}

.toast-close:hover {
    opacity: 1;
}

/* Progress Bar */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.3);
    transform-origin: left;
}

.toast-notification:not(.toast-paused) .toast-progress {
    animation: toastProgress linear forwards;
}

@keyframes toastProgress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Toast Types - Light Mode */
[data-bs-theme="light"] .toast-notification.toast-success {
    background-color: #f0f9f4;
    border-left: 4px solid #10b981;
}

[data-bs-theme="light"] .toast-notification.toast-success .toast-icon {
    color: #10b981;
}

[data-bs-theme="light"] .toast-notification.toast-success .toast-message {
    color: #065f46;
}

[data-bs-theme="light"] .toast-notification.toast-success .toast-description {
    color: #047857;
}

[data-bs-theme="light"] .toast-notification.toast-success .toast-progress {
    background: #10b981;
}

[data-bs-theme="light"] .toast-notification.toast-success .toast-action-btn {
    color: #059669;
}

[data-bs-theme="light"] .toast-notification.toast-success .toast-action-btn:hover {
    background: rgba(16, 185, 129, 0.1);
}

[data-bs-theme="light"] .toast-notification.toast-info {
    background-color: #eff6ff;
    border-left: 4px solid #3b82f6;
}

[data-bs-theme="light"] .toast-notification.toast-info .toast-icon {
    color: #3b82f6;
}

[data-bs-theme="light"] .toast-notification.toast-info .toast-message {
    color: #1e40af;
}

[data-bs-theme="light"] .toast-notification.toast-info .toast-description {
    color: #2563eb;
}

[data-bs-theme="light"] .toast-notification.toast-info .toast-progress {
    background: #3b82f6;
}

[data-bs-theme="light"] .toast-notification.toast-info .toast-action-btn {
    color: #2563eb;
}

[data-bs-theme="light"] .toast-notification.toast-info .toast-action-btn:hover {
    background: rgba(59, 130, 246, 0.1);
}

[data-bs-theme="light"] .toast-notification.toast-warning {
    background-color: #fffbeb;
    border-left: 4px solid #f59e0b;
}

[data-bs-theme="light"] .toast-notification.toast-warning .toast-icon {
    color: #f59e0b;
}

[data-bs-theme="light"] .toast-notification.toast-warning .toast-message {
    color: #92400e;
}

[data-bs-theme="light"] .toast-notification.toast-warning .toast-description {
    color: #b45309;
}

[data-bs-theme="light"] .toast-notification.toast-warning .toast-progress {
    background: #f59e0b;
}

[data-bs-theme="light"] .toast-notification.toast-warning .toast-action-btn {
    color: #d97706;
}

[data-bs-theme="light"] .toast-notification.toast-warning .toast-action-btn:hover {
    background: rgba(245, 158, 11, 0.1);
}

[data-bs-theme="light"] .toast-notification.toast-error {
    background-color: #fef2f2;
    border-left: 4px solid #ef4444;
}

[data-bs-theme="light"] .toast-notification.toast-error .toast-icon {
    color: #ef4444;
}

[data-bs-theme="light"] .toast-notification.toast-error .toast-message {
    color: #991b1b;
}

[data-bs-theme="light"] .toast-notification.toast-error .toast-description {
    color: #dc2626;
}

[data-bs-theme="light"] .toast-notification.toast-error .toast-progress {
    background: #ef4444;
}

[data-bs-theme="light"] .toast-notification.toast-error .toast-action-btn {
    color: #dc2626;
}

[data-bs-theme="light"] .toast-notification.toast-error .toast-action-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

[data-bs-theme="light"] .toast-close {
    color: #6b7280;
}

/* Toast Types - Dark Mode (Warm Dark Palette) */
[data-bs-theme="dark"] .toast-notification.toast-success {
    background-color: #1a2e1f;
    border-left: 4px solid #10b981;
}

[data-bs-theme="dark"] .toast-notification.toast-success .toast-icon {
    color: #34d399;
}

[data-bs-theme="dark"] .toast-notification.toast-success .toast-message {
    color: #d1fae5;
}

[data-bs-theme="dark"] .toast-notification.toast-success .toast-description {
    color: #a7f3d0;
}

[data-bs-theme="dark"] .toast-notification.toast-success .toast-progress {
    background: #10b981;
}

[data-bs-theme="dark"] .toast-notification.toast-success .toast-action-btn {
    color: #6ee7b7;
}

[data-bs-theme="dark"] .toast-notification.toast-success .toast-action-btn:hover {
    background: rgba(16, 185, 129, 0.2);
}

[data-bs-theme="dark"] .toast-notification.toast-info {
    background-color: #1e293b;
    border-left: 4px solid #3b82f6;
}

[data-bs-theme="dark"] .toast-notification.toast-info .toast-icon {
    color: #60a5fa;
}

[data-bs-theme="dark"] .toast-notification.toast-info .toast-message {
    color: #dbeafe;
}

[data-bs-theme="dark"] .toast-notification.toast-info .toast-description {
    color: #bfdbfe;
}

[data-bs-theme="dark"] .toast-notification.toast-info .toast-progress {
    background: #3b82f6;
}

[data-bs-theme="dark"] .toast-notification.toast-info .toast-action-btn {
    color: #93c5fd;
}

[data-bs-theme="dark"] .toast-notification.toast-info .toast-action-btn:hover {
    background: rgba(59, 130, 246, 0.2);
}

[data-bs-theme="dark"] .toast-notification.toast-warning {
    background-color: #2d2410;
    border-left: 4px solid #f59e0b;
}

[data-bs-theme="dark"] .toast-notification.toast-warning .toast-icon {
    color: #fbbf24;
}

[data-bs-theme="dark"] .toast-notification.toast-warning .toast-message {
    color: #fef3c7;
}

[data-bs-theme="dark"] .toast-notification.toast-warning .toast-description {
    color: #fde68a;
}

[data-bs-theme="dark"] .toast-notification.toast-warning .toast-progress {
    background: #f59e0b;
}

[data-bs-theme="dark"] .toast-notification.toast-warning .toast-action-btn {
    color: #fcd34d;
}

[data-bs-theme="dark"] .toast-notification.toast-warning .toast-action-btn:hover {
    background: rgba(245, 158, 11, 0.2);
}

[data-bs-theme="dark"] .toast-notification.toast-error {
    background-color: #2d1a1a;
    border-left: 4px solid #ef4444;
}

[data-bs-theme="dark"] .toast-notification.toast-error .toast-icon {
    color: #f87171;
}

[data-bs-theme="dark"] .toast-notification.toast-error .toast-message {
    color: #fee2e2;
}

[data-bs-theme="dark"] .toast-notification.toast-error .toast-description {
    color: #fecaca;
}

[data-bs-theme="dark"] .toast-notification.toast-error .toast-progress {
    background: #ef4444;
}

[data-bs-theme="dark"] .toast-notification.toast-error .toast-action-btn {
    color: #fca5a5;
}

[data-bs-theme="dark"] .toast-notification.toast-error .toast-action-btn:hover {
    background: rgba(239, 68, 68, 0.2);
}

[data-bs-theme="dark"] .toast-close {
    color: #9ca3af;
}

/* Responsive adjustments */
@media (max-width: 576px) {
    .toast-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }

    .toast-notification {
        max-width: none;
    }

    @keyframes toastSlideIn {
        from {
            opacity: 0;
            transform: translateY(100px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    @keyframes toastSlideOut {
        from {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
        to {
            opacity: 0;
            transform: translateY(100px) scale(0.95);
        }
    }
}

/* Accessibility - High Contrast Mode */
@media (prefers-contrast: high) {
    .toast-notification {
        border-width: 2px;
        border-style: solid;
    }

    .toast-notification.toast-success {
        border-color: #10b981;
    }

    .toast-notification.toast-info {
        border-color: #3b82f6;
    }

    .toast-notification.toast-warning {
        border-color: #f59e0b;
    }

    .toast-notification.toast-error {
        border-color: #ef4444;
    }
}

/* Accessibility - Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .toast-notification,
    .toast-notification.toast-entering,
    .toast-notification.toast-exiting {
        animation: none;
        transition: opacity 0.15s linear;
    }

    .toast-notification.toast-entering {
        opacity: 0;
    }

    .toast-notification.toast-exiting {
        opacity: 0;
    }

    .toast-progress {
        animation: none !important;
    }
}

/* Focus styles for accessibility */
.toast-action-btn:focus-visible,
.toast-close:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
