/* ===== ALERT OVERLAYS STYLING ===== */

/* Alert Overlay Container */
.alert-overlay-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    max-width: 400px;
    width: 100%;
    pointer-events: none;
}

/* Individual Alert Overlay */
.alert-overlay {
    background: linear-gradient(135deg, var(--white) 0%, var(--gray-50) 100%);
    border: 2px solid var(--accent-blue);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--spacing-3);
    padding: var(--spacing-4);
    position: relative;
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
    max-width: 100%;
    word-wrap: break-word;
}

/* Alert Overlay Header */
.alert-overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-2);
}

.alert-overlay-title {
    font-weight: 600;
    font-size: var(--font-size-sm);
    color: var(--gray-800);
    margin: 0;
    flex: 1;
    margin-right: var(--spacing-2);
}

/* Alert Overlay Content */
.alert-overlay-content {
    font-size: var(--font-size-xs);
    color: var(--gray-600);
    line-height: 1.4;
    margin-bottom: var(--spacing-2);
}

/* Alert Overlay Actions */
.alert-overlay-actions {
    display: flex;
    gap: var(--spacing-2);
    justify-content: flex-end;
}

/* Close Button */
.alert-overlay-close {
    background: none;
    border: none;
    color: var(--gray-500);
    cursor: pointer;
    font-size: var(--font-size-lg);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.alert-overlay-close:hover {
    background-color: var(--gray-100);
    color: var(--gray-700);
}

.alert-overlay-close:focus {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Alert Type Variants */
.alert-overlay.alert-success {
    border-color: var(--success);
    background: linear-gradient(135deg, #d1e7dd 0%, #f8f9fa 100%);
}

.alert-overlay.alert-warning {
    border-color: var(--warning);
    background: linear-gradient(135deg, #fff3cd 0%, #f8f9fa 100%);
}

.alert-overlay.alert-danger {
    border-color: var(--danger);
    background: linear-gradient(135deg, #f8d7da 0%, #f8f9fa 100%);
}

.alert-overlay.alert-info {
    border-color: var(--info);
    background: linear-gradient(135deg, #cff4fc 0%, #f8f9fa 100%);
}

/* Alert Severity Icons */
.alert-overlay-icon {
    margin-right: var(--spacing-2);
    font-size: var(--font-size-base);
    flex-shrink: 0;
}

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

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

.alert-overlay.alert-danger .alert-overlay-icon {
    color: var(--danger);
}

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

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

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

.alert-overlay.removing {
    animation: slideOutRight 0.3s ease-in forwards;
}

/* Responsive Design */
@media (max-width: 768px) {
    .alert-overlay-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .alert-overlay {
        padding: var(--spacing-3);
    }
    
    .alert-overlay-title {
        font-size: var(--font-size-xs);
    }
    
    .alert-overlay-content {
        font-size: var(--font-size-xs);
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .alert-overlay {
        border-width: 3px;
    }
    
    .alert-overlay-close {
        border: 2px solid var(--gray-400);
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .alert-overlay {
        animation: none;
    }
    
    .alert-overlay.removing {
        animation: none;
        opacity: 0;
    }
    
    .alert-overlay-close {
        transition: none;
    }
}

/* Focus Management */
.alert-overlay:focus-within {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
}

/* Ensure overlays stay on screen */
.alert-overlay-container {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* Scrollbar styling for overlay container */
.alert-overlay-container::-webkit-scrollbar {
    width: 6px;
}

.alert-overlay-container::-webkit-scrollbar-track {
    background: transparent;
}

.alert-overlay-container::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

.alert-overlay-container::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* ===== MODAL OVERLAY FIXES ===== */

/* Fix for AlertsList modal - Based on user-tested settings */
#alertModal .modal-dialog {
    position: fixed !important;
    top: 10% !important;
    left: 20% !important;
    width: 60% !important;
    height: 50% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
}

#alertModal .modal-content {
    height: 100% !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

#alertModal .modal-body {
    overflow-y: auto !important;
    flex: 1 1 auto !important;
}

#alertModal .modal-header,
#alertModal .modal-footer {
    flex-shrink: 0 !important;
}

/* Fix for AlertsList modal and other large modals - Higher specificity */
#alertModal .modal-dialog,
.modal.fade.show .modal-dialog,
.modal-dialog.modal-lg {
    max-height: calc(100vh - 2rem) !important;
    margin: 1rem auto !important;
}

#alertModal .modal-dialog-scrollable,
.modal.fade.show .modal-dialog-scrollable,
.modal-dialog.modal-lg.modal-dialog-scrollable {
    max-height: calc(100vh - 2rem) !important;
}

#alertModal .modal-dialog-scrollable .modal-content,
.modal.fade.show .modal-dialog-scrollable .modal-content,
.modal-dialog.modal-lg.modal-dialog-scrollable .modal-content {
    max-height: calc(100vh - 2rem) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal-dialog-scrollable .modal-header {
    flex-shrink: 0;
}

.modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    flex: 1 1 auto;
    padding: 1rem;
}

.modal-dialog-scrollable .modal-footer {
    flex-shrink: 0;
}

/* Ensure close button is always visible */
.modal-header {
    position: sticky;
    top: 0;
    z-index: 1;
    background: white;
    border-bottom: 1px solid #dee2e6;
}

/* Custom scrollbar for modal body */
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Responsive modal sizing */
@media (max-width: 768px) {
    .modal-dialog {
        max-height: calc(100vh - 1rem);
        margin: 0.5rem;
    }
    
    .modal-dialog-scrollable {
        max-height: calc(100vh - 1rem);
    }
    
    .modal-dialog-scrollable .modal-content {
        max-height: calc(100vh - 1rem);
    }
}
