/* ============================================
   MODAL SYSTEM - EXTRACTED FROM UI CONSISTENCY
   All modal-related styles for consistent UI
   ============================================ */

/* ============================================
   MODAL WIDTH SYSTEM (ONE STANDARD)
   ============================================ */

/* Default modal - All modals use this base */
.modal,
.modal-premium {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2rem 1rem;
    box-sizing: border-box;
    flex-direction: column;
}

@media (min-width: 1024px) {
    .modal,
    .modal-premium {
        padding: 2rem;
    }
}

.modal.hidden,
.modal-premium.hidden {
    display: none !important;
}

/* Modal backdrop - consistent across all */
.modal-overlay,
.modal-premium::before {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9998;
    pointer-events: auto;
    cursor: pointer;
}

/* ============================================
   SIMPLIFIED MODAL STYLING - CLEAN APPROACH
   ============================================ */

/* Base: All modal containers */
.modal-container,
.modal-card-premium {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.16);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10000;
    animation: modalSlideUp 0.3s ease-out;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Mobile-first: 90vw with safe padding */
    width: calc(100vw - 32px) !important;
    max-width: 90vw !important;
}

/* Tablet: 95% width (641px - 1023px) */
@media (min-width: 641px) and (max-width: 1023px) {
    .modal-container,
    .modal-card-premium {
        width: 95vw !important;
        max-width: 95vw !important;
        max-height: 75vh !important; /* Reduced to avoid navbar overlap */
        top: 45% !important; /* Shift up slightly */
    }

    .modal .modal-container {
        top: 45% !important;
    }
}

/* Desktop: Fixed widths by size class (1024px+) */
@media (min-width: 1024px) {
    .modal-container,
    .modal-card-premium {
        width: 600px !important; /* Default medium modal */
        max-width: 600px !important;
        max-height: 80vh !important;
    }

    /* Size variants */
    .modal-container.modal-sm,
    .modal-card-premium.modal-sm {
        width: 400px !important;
        max-width: 400px !important;
    }

    .modal-container.modal-lg,
    .modal-card-premium.modal-lg {
        width: 800px !important;
        max-width: 800px !important;
    }

    .modal-container.modal-xl,
    .modal-card-premium.modal-xl {
        width: 1000px !important;
        max-width: 1000px !important;
    }

    .modal-container.modal-full,
    .modal-card-premium.modal-full {
        width: 90vw !important;
        max-width: 90vw !important;
    }
}

/* ============================================
   MODAL ANIMATIONS
   ============================================ */

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translate(-50%, -40%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* ============================================
   MODAL STRUCTURE COMPONENTS
   ============================================ */

/* Header section - consistent padding and styling */
.modal-header {
    padding: 1.5rem 2rem 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-header h2,
.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
}

.modal-header .modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
}

.modal-header .modal-close:hover {
    background-color: #f3f4f6;
    color: #374151;
}

/* Body section - scrollable content area */
.modal-body {
    padding: 1.5rem 2rem;
    overflow-y: auto;
    flex: 1;
    min-height: 0; /* Allow flex shrinking */
}

/* Footer section - action buttons */
.modal-footer {
    padding: 1rem 2rem 1.5rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-shrink: 0;
}

/* ============================================
   MODAL RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 640px) {
    .modal-header,
    .modal-body,
    .modal-footer {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }

    .modal-header {
        padding-top: 1.25rem;
        padding-bottom: 0.75rem;
    }

    .modal-body {
        padding-top: 1.25rem;
        padding-bottom: 1.25rem;
    }

    .modal-footer {
        padding-top: 0.75rem;
        padding-bottom: 1.25rem;
        flex-direction: column;
    }

    .modal-footer button {
        width: 100%;
    }
}

/* ============================================
   MODAL ACCESSIBILITY
   ============================================ */

.modal[aria-hidden="true"] {
    display: none !important;
}

.modal[aria-hidden="false"] {
    display: flex;
}

/* Focus management for modals */
.modal:focus-within .modal-container {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* ============================================
   SPECIAL MODAL VARIANTS
   ============================================ */

/* Confirmation modals - smaller and centered */
.modal-confirmation .modal-container {
    max-width: 400px !important;
}

.modal-confirmation .modal-body {
    text-align: center;
    padding: 2rem 1.5rem;
}

.modal-confirmation .modal-footer {
    justify-content: center;
}

/* Form modals - wider for form content */
.modal-form .modal-container {
    max-width: 700px !important;
}

/* Data table modals - full width for tables */
.modal-table .modal-container {
    max-width: 90vw !important;
}

@media (min-width: 1024px) {
    .modal-table .modal-container {
        max-width: 1200px !important;
    }
}