/* Unified Notification System - Proper Stacking & Sizing */
/* This CSS handles all notification types to ensure proper stacking and mobile responsiveness */

/* Notification Container - All notifications will stack inside this */
#notification-stack-container {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 100010;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    padding: 85px 16px 16px 16px; /* Default: 75px header + 10px padding */
    transition: padding-top 0.3s ease;
}

/* When notification bar is visible */
#notification-stack-container.has-notification-bar {
    padding-top: 120px; /* 75px header + 40px bar + 5px padding */
}

/* All notification types base styling - COMPACT */
/* CRITICAL: Override any conflicting styles from enhanced-undo-system.css */
.stacked-notification {
    pointer-events: auto;
    max-width: 400px !important; /* Reasonable max width */
    min-width: 200px; /* Minimum width to show content */
    width: auto !important; /* Auto-size to content */
    display: block !important;
    transform: translateX(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    /* Reset any fixed positioning from legacy CSS */
    position: relative !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    margin: 0 !important;
}

.stacked-notification.visible {
    transform: translateX(0);
    opacity: 1;
}

.stacked-notification.leaving {
    transform: translateX(120%);
    opacity: 0;
}

/* Compact glass card styling for all notifications */
.stacked-notification .notification-glass-card {
    padding: 10px 12px !important; /* Slightly more padding for readability */
    border-radius: 8px;
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 100% !important; /* Full width of container */
    display: block !important; /* Block to allow proper sizing */
    box-sizing: border-box;
}

/* Notification content layout - flexible for wrapping */
.stacked-notification .notification-content {
    display: flex !important;
    width: 100% !important;
    align-items: flex-start; /* Align to top for multi-line */
    gap: 8px;
    flex-wrap: wrap; /* Allow wrapping if needed */
}

.stacked-notification .notification-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 1px; /* Align with first line of text */
}

/* Text styling - allow wrapping but truncate only filenames */
.stacked-notification .notification-text {
    flex: 1 1 auto; /* Grow and shrink as needed */
    min-width: 0; /* Allow text to shrink below content size */
    font-size: 0.8rem; /* Slightly larger for readability */
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.95);
    word-wrap: break-word; /* Allow word breaking */
    overflow-wrap: break-word;
    /* NO white-space: nowrap - allow natural wrapping */
    /* NO max-width - let container control width */
    /* NO text-overflow: ellipsis - show full text */
}

/* Only truncate actual filename spans */
.stacked-notification .notification-text .filename,
.stacked-notification .notification-text.is-filename {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
    display: inline-block;
    vertical-align: bottom;
}

.stacked-notification .notification-close {
    flex-shrink: 0;
    padding: 2px;
    border-radius: 4px;
    transition: background 0.2s;
    cursor: pointer;
    background: transparent;
    border: none;
    margin-left: auto; /* Push to right */
}

.stacked-notification .notification-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.stacked-notification .notification-close svg {
    width: 14px;
    height: 14px;
}

/* Notification type colors */

/* Info (Blue) */
.stacked-notification.notification-info .notification-glass-card {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(37, 99, 235, 0.1) 100%);
    border: 1px solid rgba(59, 130, 246, 0.35);
}
.stacked-notification.notification-info .notification-icon {
    color: rgba(59, 130, 246, 0.9);
}

/* Success (Green) */
.stacked-notification.notification-success .notification-glass-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(5, 150, 105, 0.1) 100%);
    border: 1px solid rgba(16, 185, 129, 0.4);
}
.stacked-notification.notification-success .notification-icon {
    color: rgba(16, 185, 129, 0.9);
}

/* Warning (Yellow) */
.stacked-notification.notification-warning .notification-glass-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
}
.stacked-notification.notification-warning .notification-icon {
    color: rgba(245, 158, 11, 0.9);
}

/* Error (Red) */
.stacked-notification.notification-error .notification-glass-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.1) 100%);
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.stacked-notification.notification-error .notification-icon {
    color: rgba(239, 68, 68, 0.9);
}

/* Undo notification with countdown - slightly larger */
.stacked-notification.notification-undo .notification-glass-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(217, 119, 6, 0.1) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 8px !important; /* Consistent padding */
}
.stacked-notification.notification-undo .notification-icon {
    color: rgba(245, 158, 11, 0.9);
}

/* Undo button styling */
.stacked-notification .undo-action-btn {
    flex-shrink: 0;
    padding: 4px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 4px;
    background: rgba(245, 158, 11, 0.2);
    border: 1px solid rgba(245, 158, 11, 0.5);
    color: rgba(245, 158, 11, 1);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.stacked-notification .undo-action-btn:hover {
    background: rgba(245, 158, 11, 0.3);
    color: rgba(255, 255, 255, 1);
}

/* Countdown styling */
.stacked-notification .countdown-section {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}

.stacked-notification .countdown-text {
    font-family: monospace;
    font-weight: 600;
    font-size: 0.7rem;
    color: rgba(245, 158, 11, 1);
    min-width: 24px; /* Ensure consistent width */
}

.stacked-notification .countdown-bar-bg {
    height: 4px; /* Slightly taller for visibility */
    background: rgba(75, 85, 99, 0.4);
    border-radius: 2px;
    overflow: hidden;
    flex: 1 1 auto; /* Grow to fill available space */
    min-width: 80px; /* Minimum width */
    max-width: 150px; /* Maximum width */
}

.stacked-notification .countdown-bar {
    height: 100%;
    background: rgba(245, 158, 11, 0.9);
    border-radius: 2px;
    transition: width 1s linear;
}

/* Warning state (last 5 seconds) */
.stacked-notification.notification-undo.warning-state .notification-glass-card {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(220, 38, 38, 0.1) 100%);
    border-color: rgba(239, 68, 68, 0.4);
}
.stacked-notification.notification-undo.warning-state .notification-icon {
    color: rgba(239, 68, 68, 0.9);
}
.stacked-notification.notification-undo.warning-state .countdown-text {
    color: rgba(239, 68, 68, 1);
}
.stacked-notification.notification-undo.warning-state .countdown-bar {
    background: rgba(239, 68, 68, 0.8);
}

/* Mobile Responsiveness */
@media (max-width: 640px) {
    #notification-stack-container {
        padding: 170px 8px 8px 8px; /* 160px mobile header + 10px */
        align-items: stretch; /* Full width on mobile */
    }
    
    #notification-stack-container.has-notification-bar {
        padding-top: 200px; /* 160px header + 35px bar + 5px */
    }
    
    .stacked-notification {
        max-width: 100% !important;
        transform: translateY(-20px);
        /* Override any mobile positioning from enhanced-undo-system.css */
        position: relative !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        bottom: auto !important;
    }
    
    .stacked-notification.visible {
        transform: translateY(0);
    }
    
    .stacked-notification.leaving {
        transform: translateY(-30px);
    }
    
    .stacked-notification .notification-glass-card {
        padding: 8px !important;
    }
    
    .stacked-notification .notification-icon {
        width: 16px;
        height: 16px;
    }
    
    .stacked-notification .notification-text {
        font-size: 0.7rem;
        /* Allow text to wrap naturally on mobile screens */
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.3;
    }
    
    .stacked-notification .notification-close svg {
        width: 12px;
        height: 12px;
    }
    
    .stacked-notification .undo-action-btn {
        padding: 3px 8px;
        font-size: 0.65rem;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .stacked-notification .notification-glass-card {
        padding: 6px;
    }
    
    .stacked-notification .notification-content {
        gap: 4px;
    }
    
    .stacked-notification .notification-text {
        font-size: 0.65rem;
        /* Allow text to wrap naturally on very small screens */
        word-wrap: break-word;
        overflow-wrap: break-word;
        line-height: 1.3;
    }
}

/* Animation for new notifications */
@keyframes notificationSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes notificationSlideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

/* Mobile slide animations */
@media (max-width: 640px) {
    @keyframes notificationSlideIn {
        from {
            transform: translateY(-20px);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    @keyframes notificationSlideOut {
        from {
            transform: translateY(0);
            opacity: 1;
        }
        to {
            transform: translateY(-30px);
            opacity: 0;
        }
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .stacked-notification {
        transition: opacity 0.2s ease;
        transform: none !important;
    }
    
    .stacked-notification.visible {
        opacity: 1;
    }
    
    .stacked-notification.leaving {
        opacity: 0;
    }
}

/* Print - hide notifications */
@media print {
    #notification-stack-container {
        display: none !important;
    }
}
