/**
 * Unified Notification System Styles
 * Provides consistent notification styling across the entire application
 * Supports: Toast notifications, Modal dialogs, Loading indicators
 * Features: Smooth animations, Responsive design, Accessibility support
 */

/* ===== CSS Variables for Theme Consistency ===== */
:root {
    /* Colors */
    --notify-success-bg: #10b981;
    --notify-success-text: #ffffff;
    --notify-success-border: #059669;
    --notify-success-light: #d1fae5;
    --notify-success-dark: #065f46;
    
    --notify-error-bg: #ef4444;
    --notify-error-text: #ffffff;
    --notify-error-border: #dc2626;
    --notify-error-light: #fee2e2;
    --notify-error-dark: #991b1b;
    
    --notify-warning-bg: #f59e0b;
    --notify-warning-text: #ffffff;
    --notify-warning-border: #d97706;
    --notify-warning-light: #fef3c7;
    --notify-warning-dark: #92400e;
    
    --notify-info-bg: #3b82f6;
    --notify-info-text: #ffffff;
    --notify-info-border: #2563eb;
    --notify-info-light: #dbeafe;
    --notify-info-dark: #1e40af;
    
    --notify-loading-bg: #6b7280;
    --notify-loading-text: #ffffff;
    --notify-loading-border: #4b5563;
    --notify-loading-light: #f3f4f6;
    --notify-loading-dark: #374151;
    
    /* Shadows */
    --notify-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --notify-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --notify-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --notify-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    /* Timings */
    --notify-animation-duration: 0.3s;
    --notify-animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Z-index layers */
    --notify-z-toast: 10000;
    --notify-z-modal-backdrop: 100000;
    --notify-z-modal: 100001;
}

/* ===== Base Notification Styles ===== */
.notification-base {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: all var(--notify-animation-duration) var(--notify-animation-easing);
}

/* ===== Toast Notification Container ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 420px;
    pointer-events: none;
    z-index: var(--notify-z-toast);
}

/* Responsive positioning */
@media (max-width: 640px) {
    .toast-container {
        left: 20px;
        right: 20px;
        max-width: none;
    }
}

/* ===== Toast Notification ===== */
.toast-notification {
    composes: notification-base;
    position: relative;
    background: var(--tc-gray-50);
    border: 1px solid #e5e7eb;
    box-shadow: var(--notify-shadow-lg);
    pointer-events: auto;
    transform: translateX(0);
    opacity: 1;
}

/* Animation classes */
.toast-notification.toast-enter {
    animation: toastSlideIn var(--notify-animation-duration) var(--notify-animation-easing);
}

.toast-notification.toast-exit {
    animation: toastSlideOut var(--notify-animation-duration) var(--notify-animation-easing) forwards;
}

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

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

/* ===== Notification Types ===== */
.notification-success {
    background-color: var(--notify-success-bg);
    color: var(--notify-success-text);
    border-color: var(--notify-success-border);
}

.notification-success.notification-light {
    background-color: var(--notify-success-light);
    color: var(--notify-success-dark);
    border-color: var(--notify-success-bg);
}

.notification-error {
    background-color: var(--notify-error-bg);
    color: var(--notify-error-text);
    border-color: var(--notify-error-border);
}

.notification-error.notification-light {
    background-color: var(--notify-error-light);
    color: var(--notify-error-dark);
    border-color: var(--notify-error-bg);
}

.notification-warning {
    background-color: var(--notify-warning-bg);
    color: var(--notify-warning-text);
    border-color: var(--notify-warning-border);
}

.notification-warning.notification-light {
    background-color: var(--notify-warning-light);
    color: var(--notify-warning-dark);
    border-color: var(--notify-warning-bg);
}

.notification-info {
    background-color: var(--notify-info-bg);
    color: var(--notify-info-text);
    border-color: var(--notify-info-border);
}

.notification-info.notification-light {
    background-color: var(--notify-info-light);
    color: var(--notify-info-dark);
    border-color: var(--notify-info-bg);
}

.notification-loading {
    background-color: var(--notify-loading-bg);
    color: var(--notify-loading-text);
    border-color: var(--notify-loading-border);
}

.notification-loading.notification-light {
    background-color: var(--notify-loading-light);
    color: var(--notify-loading-dark);
    border-color: var(--notify-loading-bg);
}

/* ===== Notification Icons ===== */
.notification-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.notification-icon svg {
    width: 20px;
    height: 20px;
}

/* Default icon styles */
.notification-success .notification-icon svg {
    fill: currentColor;
}

.notification-error .notification-icon svg {
    fill: currentColor;
}

.notification-warning .notification-icon svg {
    fill: currentColor;
}

.notification-info .notification-icon svg {
    fill: currentColor;
}

/* Loading spinner */
.notification-loading .notification-icon::before {
    content: '';
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: notificationSpinner 0.8s linear infinite;
}

@keyframes notificationSpinner {
    to {
        transform: rotate(360deg);
    }
}

/* ===== Notification Content ===== */
.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.notification-message {
    font-size: 14px;
    opacity: 0.9;
}

.notification-message p {
    margin: 0;
}

.notification-message a {
    color: inherit;
    text-decoration: underline;
    font-weight: 500;
}

/* ===== Close Button ===== */
.notification-close {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: all 0.2s ease;
    margin: -8px -8px -8px 0;
}

.notification-close:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.05);
}

.notification-close:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.notification-close svg {
    width: 16px;
    height: 16px;
}

/* ===== Modal Backdrop ===== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: var(--notify-z-modal-backdrop);
    opacity: 0;
    transition: opacity var(--notify-animation-duration) var(--notify-animation-easing);
}

.modal-backdrop.modal-show {
    opacity: 1;
}

/* ===== Modal Dialog ===== */
.modal-dialog {
    composes: notification-base;
    background: var(--tc-gray-50);
    border-radius: 12px;
    box-shadow: var(--notify-shadow-xl);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: scale(0.9);
    opacity: 0;
    transition: all var(--notify-animation-duration) var(--notify-animation-easing);
    z-index: var(--notify-z-modal);
    pointer-events: auto !important;
}

.modal-backdrop.modal-show .modal-dialog {
    transform: scale(1);
    opacity: 1;
}

/* Modal sizes */
.modal-dialog.modal-sm {
    max-width: 300px;
}

.modal-dialog.modal-lg {
    max-width: 800px;
}

.modal-dialog.modal-xl {
    max-width: 1200px;
}

/* ===== Modal Header ===== */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

/* ===== Modal Body ===== */
.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    color: #374151;
}

/* ===== Modal Footer ===== */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
    background-color: var(--tc-gray-100);
}

/* ===== Modal Buttons ===== */
.modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

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

.modal-btn-primary {
    background-color: #3b82f6;
    color: #ffffff;
    border-color: #3b82f6;
}

.modal-btn-primary:hover {
    background-color: #2563eb;
    border-color: #2563eb;
}

.modal-btn-secondary {
    background-color: var(--tc-gray-100);
    color: #374151;
    border-color: #d1d5db;
}

.modal-btn-secondary:hover {
    background-color: var(--tc-gray-100);
    border-color: #9ca3af;
}

.modal-btn-danger {
    background-color: #ef4444;
    color: #ffffff;
    border-color: #ef4444;
}

.modal-btn-danger:hover {
    background-color: #dc2626;
    border-color: #dc2626;
}

/* ===== Progress Bar ===== */
.notification-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.notification-progress-bar {
    height: 100%;
    background-color: currentColor;
    transition: width 0.1s linear;
}

/* ===== Accessibility ===== */
.notification-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ===== Dark Mode Support ===== */
@media (prefers-color-scheme: dark) {
    .toast-notification {
        background: #1f2937;
        border-color: #374151;
    }
    
    .modal-dialog {
        background: #1f2937;
    }
    
    .modal-header {
        border-bottom-color: #374151;
    }
    
    .modal-title {
        color: #f3f4f6;
    }
    
    .modal-body {
        color: #d1d5db;
    }
    
    .modal-footer {
        background-color: #111827;
        border-top-color: #374151;
    }
    
    .modal-btn-secondary {
        background-color: #374151;
        color: #f3f4f6;
        border-color: #4b5563;
    }
    
    .modal-btn-secondary:hover {
        background-color: #4b5563;
        border-color: #6b7280;
    }
    
    .notification-close:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
}

/* ===== Print Styles ===== */
@media print {
    .toast-container,
    .modal-backdrop {
        display: none !important;
    }
}

/* ===== Animation Utilities ===== */
.fade-in {
    animation: fadeIn var(--notify-animation-duration) var(--notify-animation-easing);
}

.fade-out {
    animation: fadeOut var(--notify-animation-duration) var(--notify-animation-easing);
}

.slide-up {
    animation: slideUp var(--notify-animation-duration) var(--notify-animation-easing);
}

.slide-down {
    animation: slideDown var(--notify-animation-duration) var(--notify-animation-easing);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
[data-theme="dark"] .notification {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.1);
    color: #f1f5f9;
}

[data-theme="dark"] .notification.success {
    background: rgba(74, 222, 128, 0.15);
    border-color: #4ade80;
}

[data-theme="dark"] .notification.error {
    background: rgba(248, 113, 113, 0.15);
    border-color: #f87171;
}

[data-theme="dark"] .notification.warning {
    background: rgba(251, 191, 36, 0.15);
    border-color: #fbbf24;
}
