/* Hand-rolled Blazor Bootstrap modals: .modal.fade.show.d-block
   Default: shrink to content; cap height at viewport and scroll body when needed.
   .modal-dialog-fit-content remains an alias for the same sizing rules. */

.modal.fade.show.d-block {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
    overflow-y: auto;
}

.modal.fade.show.d-block .modal-dialog {
    margin: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: min(100%, calc(100vw - 2rem));
    height: auto;
    max-height: min(90vh, calc(100vh - 2rem));
}

.modal.fade.show.d-block .modal-dialog.modal-dialog-fit-content {
    width: auto;
    max-width: min(100%, calc(100vw - 2rem));
    height: auto;
    max-height: min(90vh, calc(100vh - 2rem));
}

.modal.fade.show.d-block .modal-content {
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.fade.show.d-block .modal-dialog.modal-dialog-fit-content .modal-content {
    flex: 0 1 auto;
    overflow: hidden;
}

.modal.fade.show.d-block .modal-dialog.modal-dialog-fit-content .modal-body {
    flex: 0 1 auto;
    overflow-y: auto;
}

.modal.fade.show.d-block .modal-header,
.modal.fade.show.d-block .modal-footer {
    flex-shrink: 0;
}

.modal.fade.show.d-block .modal-body {
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Restore Bootstrap modal-lg / modal-xl widths (base rules above use near-full-width). */
@media (min-width: 576px) {
    .modal.fade.show.d-block .modal-dialog.modal-lg {
        max-width: min(500px, calc(100vw - 2rem));
    }
}

@media (min-width: 992px) {
    .modal.fade.show.d-block .modal-dialog.modal-lg,
    .modal.fade.show.d-block .modal-dialog.modal-xl {
        max-width: min(800px, calc(100vw - 2rem));
    }
}

@media (min-width: 1200px) {
    .modal.fade.show.d-block .modal-dialog.modal-xl {
        max-width: min(1140px, calc(100vw - 2rem));
    }
}

/* Short confirmations (edition sale recovery, etc.) — content height, not 90vh */
.modal.fade.show.d-block.modal-compact .modal-dialog,
.modal.fade.show.d-block.modal-compact .modal-dialog.modal-dialog-centered {
    display: block;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    max-width: min(420px, 100%);
}

.modal.fade.show.d-block.modal-compact .modal-content {
    flex: 0 0 auto !important;
    overflow: visible;
    display: block;
}

.modal.fade.show.d-block.modal-compact .modal-body {
    flex: 0 0 auto !important;
    overflow: visible;
}

/* Content-sized confirm — avoids Bootstrap modal + clubivate 90vh rules entirely */
.clubivate-confirm-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1060;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.5);
}

.clubivate-confirm-dialog {
    width: min(420px, 100%);
    background: var(--bs-body-bg, #fff);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    border: var(--bs-border-width, 1px) solid var(--bs-border-color-translucent, rgba(0, 0, 0, 0.175));
    box-shadow: var(--bs-box-shadow-sm, 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075));
}

.clubivate-confirm-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-bottom: var(--bs-border-width, 1px) solid var(--bs-border-color, #dee2e6);
}

.clubivate-confirm-header .modal-title {
    margin-bottom: 0;
    font-size: 1.25rem;
}

.clubivate-confirm-body {
    padding: 1rem;
}

.clubivate-confirm-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: var(--bs-border-width, 1px) solid var(--bs-border-color, #dee2e6);
}

/*
 * Edition organization flyer picker (EditionsWithOffers).
 * Enforces Bootstrap modal-lg width and viewport height with 25px top/bottom inset.
 * !important beats generic .modal.fade.show.d-block rules above.
 */
.modal.fade.show.d-block.edition-organization-flyer-modal {
    padding: 25px 0.5rem !important;
    overflow: hidden !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100dvh !important;
    box-sizing: border-box !important;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .modal-dialog.modal-lg.edition-organization-flyer-dialog {
    width: min(800px, calc(100vw - 1rem)) !important;
    max-width: min(800px, calc(100vw - 1rem)) !important;
    height: calc(100dvh - 50px) !important;
    max-height: calc(100dvh - 50px) !important;
    min-height: 0 !important;
    margin: 0 auto !important;
    flex: 0 0 auto !important;
}

@media (min-width: 576px) and (max-width: 991.98px) {
    .modal.fade.show.d-block.edition-organization-flyer-modal .modal-dialog.modal-lg.edition-organization-flyer-dialog {
        width: min(500px, calc(100vw - 1rem)) !important;
        max-width: min(500px, calc(100vw - 1rem)) !important;
    }
}

.modal.fade.show.d-block.edition-organization-flyer-modal .modal-content.edition-organization-flyer-content {
    height: 100% !important;
    max-height: 100% !important;
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .modal-header,
.modal.fade.show.d-block.edition-organization-flyer-modal .modal-footer {
    flex-shrink: 0 !important;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .edition-organization-flyer-modal-body {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .edition-organization-flyer-org-list {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-y: auto !important;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .edition-organization-flyer-org-list .list-group-item {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .edition-organization-flyer-org-logo {
    width: 2.5rem !important;
    height: 2.5rem !important;
    max-width: 2.5rem !important;
    max-height: 2.5rem !important;
    object-fit: contain;
    flex-shrink: 0;
}

.modal.fade.show.d-block.edition-organization-flyer-modal .edition-organization-flyer-org-logo-placeholder {
    display: inline-block;
    width: 2.5rem;
    height: 2.5rem;
    flex-shrink: 0;
}
