/**
 * Unified Notification System CSS
 * 
 * Exact replication of the OCR module's excellent notification styling
 * with enhancements for the unified system.
 * 
 * Based on: app/Views/modules/document-ocr/index.php (lines 404-487)
 * Requirements: docs/features/UNIFIED_NOTIFICATION_SYSTEM.md
 * 
 * @author CoreHive3 Team
 * @version 1.0.0
 * @since 2025-07-28
 */

/* ==========================================================================
   Notification Container
   ========================================================================== */

.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    max-width: 400px;
    pointer-events: none; /* Allow clicks to pass through container */
}

/* ==========================================================================
   Base Toast Notification Styles
   ========================================================================== */

.toast {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 1rem;
    margin-bottom: 0.75rem;
    transform: translateX(100%);
    transition: all 0.3s ease-in-out;
    opacity: 0;
    border-left: 4px solid #e5e7eb;
    pointer-events: auto; /* Re-enable pointer events for toast */
    max-width: 100%;
    word-wrap: break-word;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.hide {
    opacity: 0;
    transform: translateX(100%);
}

/* ==========================================================================
   Toast Type Specific Styling
   ========================================================================== */

.toast-success {
    border-left-color: #10b981;
}

.toast-success .toast-icon {
    color: #10b981;
}

.toast-success .toast-title {
    color: #065f46;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-error .toast-icon {
    color: #ef4444;
}

.toast-error .toast-title {
    color: #7f1d1d;
}

.toast-info {
    border-left-color: #3b82f6;
}

.toast-info .toast-icon {
    color: #3b82f6;
}

.toast-info .toast-title {
    color: #1e3a8a;
}

.toast-warning {
    border-left-color: #f59e0b;
}

.toast-warning .toast-icon {
    color: #f59e0b;
}

.toast-warning .toast-title {
    color: #78350f;
}

/* ==========================================================================
   Toast Content Layout
   ========================================================================== */

.toast-content {
    display: flex;
    align-items: flex-start;
}

.toast-icon {
    margin-right: 0.75rem;
    margin-top: 0.125rem;
    flex-shrink: 0;
    font-size: 1rem;
}

.toast-text {
    flex: 1;
    min-width: 0; /* Allows text to shrink properly */
}

.toast-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    line-height: 1.25;
}

.toast-message {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.4;
    margin: 0;
}

.toast-close {
    color: #9ca3af;
    cursor: pointer;
    margin-left: 0.75rem;
    flex-shrink: 0;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
}

.toast-close:hover {
    color: #6b7280;
    background-color: #f3f4f6;
}

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

/* ==========================================================================
   Progress Notification Specific Styles
   ========================================================================== */

.toast-progress {
    margin-top: 0.5rem;
    width: 100%;
    height: 0.25rem;
    background-color: #e5e7eb;
    border-radius: 0.125rem;
    overflow: hidden;
}

.toast-progress-bar {
    height: 100%;
    background-color: #3b82f6;
    border-radius: 0.125rem;
    transition: width 0.3s ease;
    min-width: 0;
}

.toast-success .toast-progress-bar {
    background-color: #10b981;
}

.toast-error .toast-progress-bar {
    background-color: #ef4444;
}

.toast-warning .toast-progress-bar {
    background-color: #f59e0b;
}

/* ==========================================================================
   Mobile Responsive Design
   ========================================================================== */

@media (max-width: 640px) {
    .notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        margin-bottom: 0.5rem;
        padding: 0.875rem;
    }
    
    .toast-title {
        font-size: 0.8125rem;
    }
    
    .toast-message {
        font-size: 0.8125rem;
    }
    
    .toast-close {
        width: 2rem;
        height: 2rem;
        margin-left: 0.5rem;
    }
    
    .toast-icon {
        margin-right: 0.5rem;
        font-size: 0.875rem;
    }
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
    .toast {
        border-width: 2px;
        border-left-width: 6px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    }
    
    .toast-title {
        font-weight: 700;
    }
    
    .toast-close {
        border: 1px solid #6b7280;
    }
    
    .toast-close:hover {
        border-color: #374151;
        background-color: #e5e7eb;
    }
}

/* ==========================================================================
   Reduced Motion Support
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.15s ease;
        transform: none;
    }
    
    .toast.show {
        transform: none;
    }
    
    .toast.hide {
        transform: none;
    }
    
    .toast-progress-bar {
        transition: none;
    }
}

/* ==========================================================================
   Dark Mode Support (Future Enhancement)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .toast {
        background: #1f2937;
        color: #f9fafb;
        box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.2);
    }
    
    .toast-message {
        color: #d1d5db;
    }
    
    .toast-close {
        color: #9ca3af;
    }
    
    .toast-close:hover {
        color: #f3f4f6;
        background-color: #374151;
    }
    
    .toast-progress {
        background-color: #374151;
    }
}

/* ==========================================================================
   Focus and Accessibility Styles
   ========================================================================== */

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

/* Screen reader only text for better accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================================================
   Animation Keyframes
   ========================================================================== */

@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;
    }
}

/* Optional enhanced animations (can be enabled via JavaScript) */
.toast.animate-in {
    animation: slideInRight 0.3s ease-out;
}

.toast.animate-out {
    animation: slideOutRight 0.3s ease-in;
}

/* ==========================================================================
   Confirmation Dialog Styles
   ========================================================================== */

.notification-modal {
    position: fixed;
    inset: 0;
    background-color: rgba(75, 85, 99, 0.5);
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.notification-modal-content {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    max-width: 28rem;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.notification-modal-header {
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.notification-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.notification-modal-body {
    padding: 1.5rem;
}

.notification-modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.notification-modal-button {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.notification-modal-button-primary {
    background-color: #ef4444;
    color: white;
}

.notification-modal-button-primary:hover {
    background-color: #dc2626;
}

.notification-modal-button-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

.notification-modal-button-secondary:hover {
    background-color: #e5e7eb;
}

/* ==========================================================================
   Enhanced Modal Styles for Popup Stack System
   ========================================================================== */

/* Modal utilities */
.max-h-90vh {
    max-height: 90vh;
}

/* Form field styling enhancements */
.field-error {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

/* Selection dialog styling */
.selection-option {
    transition: background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
}

.selection-option:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.selection-option input:checked + .selection-content {
    background-color: #eff6ff;
    border-color: #3b82f6;
}

/* Enhanced focus styles for popup modals */
.notification-modal input:focus,
.notification-modal select:focus,
.notification-modal textarea:focus {
    outline: none;
    ring: 2px solid #3b82f6;
    ring-offset: 2px;
    border-color: transparent;
}

/* Form validation styling */
.field-error:not(.hidden) + input,
.field-error:not(.hidden) + select,
.field-error:not(.hidden) + textarea {
    border-color: #ef4444;
}

/* Progress in forms */
.form-progress {
    position: relative;
    background-color: #f3f4f6;
    border-radius: 0.25rem;
    height: 0.5rem;
    overflow: hidden;
}

.form-progress-bar {
    height: 100%;
    background-color: #3b82f6;
    border-radius: 0.25rem;
    transition: width 0.3s ease;
}

/* Enhanced button styling for forms */
.modal-button-group {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.modal-button {
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 4rem;
}

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

.modal-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.modal-button-primary {
    background-color: #3b82f6;
    color: white;
}

.modal-button-primary:hover:not(:disabled) {
    background-color: #2563eb;
}

.modal-button-secondary {
    background-color: #f3f4f6;
    color: #374151;
}

.modal-button-secondary:hover:not(:disabled) {
    background-color: #e5e7eb;
}

.modal-button-danger {
    background-color: #ef4444;
    color: white;
}

.modal-button-danger:hover:not(:disabled) {
    background-color: #dc2626;
}

/* Loading state for form buttons */
.modal-button-loading {
    position: relative;
    color: transparent;
}

.modal-button-loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    top: 50%;
    left: 50%;
    margin-left: -0.5rem;
    margin-top: -0.5rem;
    border: 2px solid #ffffff;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Enhanced accessibility for screen readers */
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Modal overlay animations */
.modal-overlay {
    animation: fadeIn 0.15s ease-out;
}

.modal-content {
    animation: slideIn 0.15s ease-out;
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-1rem) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Enhanced modal responsive design */
@media (max-width: 640px) {
    .notification-modal .bg-white {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    .modal-button-group {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .modal-button {
        width: 100%;
    }
    
    /* Stack buttons on mobile */
    .notification-modal .space-x-3 {
        flex-direction: column-reverse;
        gap: 0.5rem;
    }
    
    .notification-modal .space-x-3 > * {
        width: 100%;
        margin-left: 0;
    }
    
    /* Larger touch targets on mobile */
    .selection-option {
        padding: 1rem;
    }
    
    .selection-option input {
        width: 1.25rem;
        height: 1.25rem;
    }
}

/* Dark mode support for new popups */
@media (prefers-color-scheme: dark) {
    .notification-modal .bg-white {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .notification-modal .border-gray-200 {
        border-color: #374151;
    }
    
    .notification-modal .text-gray-900 {
        color: #f9fafb;
    }
    
    .notification-modal .text-gray-700 {
        color: #d1d5db;
    }
    
    .notification-modal .text-gray-500 {
        color: #9ca3af;
    }
    
    .notification-modal .bg-gray-50 {
        background-color: #374151;
    }
    
    .notification-modal .border-gray-300 {
        border-color: #4b5563;
    }
    
    .notification-modal input,
    .notification-modal select,
    .notification-modal textarea {
        background-color: #374151;
        border-color: #4b5563;
        color: #f9fafb;
    }
    
    .notification-modal input::placeholder,
    .notification-modal textarea::placeholder {
        color: #9ca3af;
    }
    
    .modal-button-secondary {
        background-color: #374151;
        color: #d1d5db;
    }
    
    .modal-button-secondary:hover:not(:disabled) {
        background-color: #4b5563;
    }
}

/* High contrast mode support for popups */
@media (prefers-contrast: high) {
    .notification-modal {
        border: 2px solid #000000;
    }
    
    .notification-modal .bg-white {
        border: 2px solid #000000;
    }
    
    .notification-modal input,
    .notification-modal select,
    .notification-modal textarea {
        border: 2px solid #000000;
    }
    
    .notification-modal button {
        border: 2px solid #000000;
        font-weight: 700;
    }
    
    .field-error:not(.hidden) + input,
    .field-error:not(.hidden) + select,
    .field-error:not(.hidden) + textarea {
        border-color: #dc2626;
        border-width: 3px;
    }
}

/* Reduced motion support for popups */
@media (prefers-reduced-motion: reduce) {
    .modal-overlay,
    .modal-content {
        animation: none;
    }
    
    .notification-modal * {
        transition: none;
    }
    
    .form-progress-bar {
        transition: none;
    }
    
    .modal-button {
        transition: none;
    }
}

/* Focus trap utilities for modals */
.modal-focus-trap {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

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

/* Enhanced selection styling */
.selection-option {
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.selection-option:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.selection-option:has(input:checked) {
    border-color: #3b82f6;
    background-color: #eff6ff;
    box-shadow: 0 0 0 1px #3b82f6;
}

/* Form field grouping */
.form-field-group {
    margin-bottom: 1.5rem;
}

.form-field-group:last-child {
    margin-bottom: 0;
}

/* Enhanced validation styling */
.validation-success {
    border-color: #10b981;
    background-color: #f0fdf4;
}

.validation-success:focus {
    ring-color: #10b981;
    border-color: #10b981;
}

.validation-error {
    border-color: #ef4444;
    background-color: #fef2f2;
}

.validation-error:focus {
    ring-color: #ef4444;
    border-color: #ef4444;
}

/* Print styles for popups */
@media print {
    .notification-container,
    .notification-modal,
    .fixed {
        display: none !important;
    }
}