/* ============================================================================
   RSL Modal Component
   ============================================================================
   Accessible dialog windows with focus trapping, keyboard navigation,
   and backdrop click-to-close functionality.

   Usage:
   <div class="modal-container default-modal-size">
       <div class="modal">
           <div class="modal-header">...</div>
           <div class="modal-body">...</div>
           <div class="modal-footer">...</div>
       </div>
   </div>
   ============================================================================ */

/* ──────────────────────────────────────────────
   Modal Container (Backdrop)
   ────────────────────────────────────────────── */

.modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
}

.modal-container.show-modal {
    display: flex;
}

/* ──────────────────────────────────────────────
   Modal Dialog
   ────────────────────────────────────────────── */

.modal {
    position: relative;
    background: #fff;
    max-width: 70%;
    max-height: 70%;
    overflow: auto;
    display: flex;
    flex-direction: column;
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Default modal size */
.default-modal-size .modal {
    min-width: 500px;
    min-height: 300px;
    padding: 10px;
}

/* ──────────────────────────────────────────────
   Modal Header
   ────────────────────────────────────────────── */

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #ddd;
}

.modal-header h2 {
    margin: 0;
}

.modal-header .close-modal {
    cursor: pointer;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    font-size: 24px;
    font-weight: 700;
    color: #333;
    background-color: transparent;
    border: none;
}

/* ──────────────────────────────────────────────
   Modal Body
   ────────────────────────────────────────────── */

.modal-body {
    padding: 20px;
    flex-grow: 1;
}

/* ──────────────────────────────────────────────
   Modal Footer
   ────────────────────────────────────────────── */

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ddd;
    text-align: right;
}

.modal-footer .btn:not(:last-child) {
    margin-right: 20px;
}

/* Footer button alignment variants */
.modal-buttons-left {
    text-align: left;
}

.modal-buttons-center {
    text-align: center;
}

.modal-buttons-right {
    text-align: right;
}

/* ──────────────────────────────────────────────
   Body Scroll Lock
   ────────────────────────────────────────────── */

body.modal-open {
    overflow: hidden;
    pointer-events: none;
}

body.modal-open .modal-container {
    pointer-events: auto;
}

/* ──────────────────────────────────────────────
   Dark Mode Support
   ────────────────────────────────────────────── */

[data-theme="dark"] .modal {
    background: #1e1e1e;
    color: #e0e0e0;
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #444;
}

[data-theme="dark"] .modal-header .close-modal {
    color: #e0e0e0;
}

[data-theme="dark"] .modal-body {
    color: #e0e0e0;
}

[data-theme="dark"] .modal-body p {
    color: #e0e0e0;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #444;
}

/* ──────────────────────────────────────────────
   Responsive Adjustments
   ────────────────────────────────────────────── */

@media (max-width: 768px) {
    .modal {
        max-width: 90%;
        max-height: 85%;
    }

    .default-modal-size .modal {
        min-width: auto;
        min-height: auto;
        width: 90%;
    }
}
