/* css/components/_modals.css */

/* Modals */
/* Ensure modals are above everything else. The z-index values are high. */
/* The problem is likely a new stacking context created by a parent of the main content area. */
/* Investigate elements like `<div class="flex-1 flex flex-col min-h-screen">` in `header.php` for properties like `transform`, `filter`, `opacity < 1` which create new stacking contexts. */
.modal {
    display: none;
    position: fixed;
    z-index: 5000; /* High z-index for the backdrop. User confirmed increasing didn't fix, so it's a stacking context issue elsewhere. */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    overflow: hidden;
}
.modal.modal-is-open {
    display: flex !important;
    align-items: center;
    justify-content: center;
}
.modal-content {
    background-color: var(--bg-color-modal);
    padding: var(--spacing-lg);
    border: 1px solid var(--color-gray-300);
    width: 90%;
    max-width: 56rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 5001; /* Slightly higher than the backdrop. */
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    min-height: 300px;
    margin: auto;
}
.modal-content.max-w-md { max-width: 28rem; }
.modal-content.max-w-2xl { max-width: 42rem; } /* CORRECTED: Sets max-width for .modal-content with .max-w-2xl */

.modal-body-scrollable {
    flex-grow: 1;
    overflow-y: auto;
    padding-bottom: 1rem;
    padding-top: 1rem;
}


.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--border-color-light);
    flex-shrink: 0;
}
.modal-title {
    font-size: var(--font-size-xl);
    font-weight: var(--font-semibold);
    color: var(--color-gray-800);
}
.close-button {
    color: var(--color-gray-400);
    font-size: 28px;
    font-weight: var(--font-bold);
    cursor: pointer;
    line-height: 1;
    background: none;
    border: none;
}
.close-button:hover,
.close-button:focus {
    color: var(--color-gray-900);
    text-decoration: none;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem var(--spacing-lg);
    border-top: 1px solid var(--border-color-light);
    background-color: var(--color-gray-50);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    flex-shrink: 0;
}

/* General modal styles from old style.css */
/* These are redundant with the above, but including for completeness if there are subtle differences */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1000; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
    justify-content: center; /* Center horizontally */
    align-items: center; /* Center vertically */
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%; /* Could be responsive */
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 90vh; /* Limit height for scrollable content */
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #2c3e50;
}

.modal-body {
    flex-grow: 1; /* Allows body to take available space */
    overflow-y: auto; /* Enables scrolling for modal content */
    padding-right: 10px; /* Prevent scrollbar from overlapping content */
}

.modal-footer {
    border-top: 1px solid #eee;
    padding-top: 15px;
    margin-top: 15px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.close-button {
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover,
.close-button:focus {
    color: #333;
    text-decoration: none;
}
