/**
 * Organization modals — Lahomes admin/ui-modal.html
 * (centered, scrollable body, static backdrop via organization-modals.js)
 */

.modal {
    --bs-modal-zindex: 1055;
}

.modal-backdrop {
    --bs-backdrop-zindex: 1050;
}

.modal .modal-content {
    background-color: var(--bs-modal-bg, var(--bs-body-bg));
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
    box-shadow: var(--bs-modal-box-shadow, var(--bs-box-shadow));
}

.modal .modal-header {
    border-bottom-color: var(--bs-border-color);
    padding: 1rem 1.25rem;
}

.modal .modal-footer {
    border-top-color: var(--bs-border-color);
    padding: 0.75rem 1.25rem;
    gap: 0.5rem;
}

.modal .modal-title {
    font-weight: 600;
    color: var(--bs-body-color);
}

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

.modal .form-group {
    margin-bottom: 1rem;
}

.modal .form-group label {
    font-weight: 500;
    color: var(--bs-body-color);
    margin-bottom: 0.35rem;
}

.modal .form-control,
.modal .form-select {
    background-color: var(--bs-body-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-body-color);
}

.modal .form-control:focus,
.modal .form-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--bs-primary-rgb), 0.25);
}

/* Choices / jalali above backdrop */
.modal.show .choices__list--dropdown {
    z-index: 1060 !important;
}

.choices.is-open .choices__list--dropdown {
    z-index: 1060 !important;
}

.modal .jdp-container {
    z-index: 1070 !important;
}

/* Centered + scrollable — content-sized on short modals, body scrolls when tall */
.modal.org-standard-modal {
    --org-modal-viewport-height: min(calc(100dvh - 2rem), calc(100vh - 2rem));
}

.modal.org-standard-modal.show {
    overflow: hidden !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.org-standard-modal .modal-dialog {
    width: 100%;
    height: auto;
    max-height: var(--org-modal-viewport-height);
    margin: 0 auto;
    flex-shrink: 0;
    pointer-events: none;
}

.modal.org-standard-modal .modal-dialog.modal-dialog-scrollable {
    height: auto;
    max-height: var(--org-modal-viewport-height);
}

.modal.org-standard-modal .modal-dialog.modal-dialog-centered {
    min-height: 0;
}

.modal.org-standard-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: var(--org-modal-viewport-height);
    overflow: hidden;
    pointer-events: auto;
}

.modal.org-standard-modal .modal-dialog-scrollable .modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    flex: 1 1 auto;
    min-height: 0;
}

/* Form wraps body + footer (assign technician, cancel service, etc.) */
.modal.org-standard-modal .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.modal.org-standard-modal .modal-content > form .modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    flex: 1 1 auto;
    min-height: 0;
}

.modal.org-standard-modal .modal-content > form .modal-footer {
    flex-shrink: 0;
}

.modal.org-standard-modal .modal-header,
.modal.org-standard-modal .modal-footer {
    flex-shrink: 0;
}

.modal.org-standard-modal .modal-footer {
    background-color: var(--bs-modal-bg, var(--bs-body-bg));
}

/* PDF / iframe preview modals (90vh inline height) */
.modal.org-standard-modal .modal-dialog.org-modal-tall {
    height: min(90dvh, 90vh, var(--org-modal-viewport-height));
    max-height: var(--org-modal-viewport-height);
}

.modal.org-standard-modal .modal-dialog.org-modal-tall .modal-content {
    height: 100%;
    max-height: 100%;
}

.modal.org-standard-modal .modal-dialog.org-modal-tall .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.org-standard-modal .modal-dialog.org-modal-tall .modal-body iframe {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    border: 0;
}

/* Nested elevator form (opened from management modal) — scroll body, fixed footer */
#elevatorFormModal.org-standard-modal .modal-content,
.modal.org-standard-modal#elevatorFormModal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: var(--org-modal-viewport-height);
}

#elevatorFormModal.org-standard-modal .modal-body,
.modal.org-standard-modal#elevatorFormModal .modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
}

#elevatorFormModal .modal-body form {
    min-height: 0;
}

/* Management modal: scroll table area when many elevators */
#elevatorsManagementModal.org-standard-modal .modal-body {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    touch-action: pan-y;
    flex: 1 1 auto;
    min-height: 0;
}
