/* ObjectModal dialog host: clubivate-modal-dialog-host (viewport-fixed via ui-stack-layer--viewport-host).
   Legacy inline modals: WebShop checkout only (out of four-host scope) — use ObjectModal elsewhere.
   Width: Bootstrap size classes + modal-dialog-full / modal-dialog-width-pct only.
   Height: cap at viewport and scroll body when needed.
   Portal host replaces Bootstrap .modal — define --bs-modal-* here so header/body/footer padding applies. */

.clubivate-modal-dialog-host {
    --bs-modal-padding: 1rem;
    --bs-modal-margin: 0.5rem;
    --bs-modal-color: ;
    --bs-modal-bg: var(--bs-body-bg);
    --bs-modal-border-color: var(--bs-border-color-translucent);
    --bs-modal-border-width: var(--bs-border-width);
    --bs-modal-border-radius: var(--bs-border-radius-lg);
    --bs-modal-box-shadow: var(--bs-box-shadow-sm);
    --bs-modal-inner-border-radius: calc(var(--bs-border-radius-lg) - (var(--bs-border-width)));
    --bs-modal-header-padding-x: 1rem;
    --bs-modal-header-padding-y: 1rem;
    --bs-modal-header-padding: 1rem 1rem;
    --bs-modal-header-border-color: var(--bs-border-color);
    --bs-modal-header-border-width: var(--bs-border-width);
    --bs-modal-title-line-height: 1.5;
    --bs-modal-footer-gap: 0.5rem;
    --bs-modal-footer-bg: ;
    --bs-modal-footer-border-color: var(--bs-border-color);
    --bs-modal-footer-border-width: var(--bs-border-width);
}

.modal.fade.show.d-block {
    --bs-modal-padding: 1rem;
    --clubivate-modal-viewport-height: calc(
        100dvh
        - var(--clubivate-topmenu-height, 0px)
        - var(--clubivate-footer-height, 0px)
        - (2 * var(--clubivate-modal-edge-gap, 10px))
    );
    --bs-modal-margin: 0.5rem;
    --bs-modal-color: ;
    --bs-modal-bg: var(--bs-body-bg);
    --bs-modal-border-color: var(--bs-border-color-translucent);
    --bs-modal-border-width: var(--bs-border-width);
    --bs-modal-border-radius: var(--bs-border-radius-lg);
    --bs-modal-box-shadow: var(--bs-box-shadow-sm);
    --bs-modal-inner-border-radius: calc(var(--bs-border-radius-lg) - (var(--bs-border-width)));
    --bs-modal-header-padding-x: 1rem;
    --bs-modal-header-padding-y: 1rem;
    --bs-modal-header-padding: 1rem 1rem;
    --bs-modal-header-border-color: var(--bs-border-color);
    --bs-modal-header-border-width: var(--bs-border-width);
    --bs-modal-title-line-height: 1.5;
    --bs-modal-footer-gap: 0.5rem;
    --bs-modal-footer-bg: ;
    --bs-modal-footer-border-color: var(--bs-border-color);
    --bs-modal-footer-border-width: var(--bs-border-width);
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100%;
    padding: var(--clubivate-modal-edge-gap, 10px);
    overflow-x: hidden;
    overflow-y: auto;
}

.clubivate-modal-dialog-host .modal-dialog,
.modal.fade.show.d-block .modal-dialog {
    position: relative;
    margin: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    height: auto;
    min-height: 0;
    max-height: none;
    pointer-events: none;
    width: 100%;
}

/* Host flex-centers the dialog; do not stretch dialog to full viewport (breaks Bootstrap centered look). */
.clubivate-modal-dialog-host .modal-dialog.modal-dialog-centered,
.modal.fade.show.d-block .modal-dialog.modal-dialog-centered {
    min-height: 0;
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-scrollable,
.modal.fade.show.d-block .modal-dialog.modal-dialog-scrollable {
    height: auto;
    max-height: var(--clubivate-modal-viewport-height, calc(100dvh - 20px));
}

/* Sized dialogs: explicit width — flex dialog otherwise shrink-wraps to narrow content (~330px). */
.clubivate-modal-dialog-host .modal-dialog.modal-sm,
.modal.fade.show.d-block .modal-dialog.modal-sm {
    width: min(300px, calc(100vw - 2rem));
    max-width: min(300px, calc(100vw - 2rem));
}

/* TypedDateTimeInput picker — modal-sm + 50px so the 7-column calendar fits without clipping. */
.clubivate-modal-dialog-host.typed-datetime-picker-modal-host .modal-dialog.modal-sm {
    width: min(350px, calc(100vw - 2rem));
    max-width: min(350px, calc(100vw - 2rem));
}

.clubivate-modal-dialog-host.typed-datetime-picker-modal-host .modal-body {
    overflow-x: visible;
}

.clubivate-modal-dialog-host.typed-datetime-picker-modal-host .typed-datetime-date-section table {
    table-layout: fixed;
    width: 100%;
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-md,
.modal.fade.show.d-block .modal-dialog.modal-dialog-md {
    width: min(500px, calc(100vw - 2rem));
    max-width: min(500px, calc(100vw - 2rem));
}

.clubivate-modal-dialog-host .modal-dialog.modal-lg,
.modal.fade.show.d-block .modal-dialog.modal-lg {
    width: min(800px, calc(100vw - 2rem));
    max-width: min(800px, calc(100vw - 2rem));
}

.clubivate-modal-dialog-host .modal-dialog.modal-xl,
.modal.fade.show.d-block .modal-dialog.modal-xl {
    width: min(1140px, calc(100vw - 2rem));
    max-width: min(1140px, calc(100vw - 2rem));
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-full,
.modal.fade.show.d-block .modal-dialog.modal-dialog-full {
    width: 100%;
    max-width: calc(100vw - 2rem);
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-width-pct,
.modal.fade.show.d-block .modal-dialog.modal-dialog-width-pct {
    width: min(var(--object-modal-width), calc(100vw - 2rem));
    max-width: min(var(--object-modal-width), calc(100vw - 2rem));
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-fit-content,
.modal.fade.show.d-block .modal-dialog.modal-dialog-fit-content {
    width: auto;
    max-width: min(100%, calc(100vw - 2rem));
    height: auto;
    max-height: var(--clubivate-modal-viewport-height, calc(100dvh - 20px));
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-scrollable .modal-content,
.modal.fade.show.d-block .modal-dialog.modal-dialog-scrollable .modal-content {
    max-height: var(--clubivate-modal-viewport-height, calc(100dvh - 20px));
    overflow: hidden;
}

.clubivate-modal-dialog-host .modal-content,
.modal.fade.show.d-block .modal-content {
    position: relative;
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    width: 100%;
    pointer-events: auto;
    color: var(--bs-modal-color);
    background-color: var(--bs-modal-bg, var(--bs-body-bg, #fff));
    background-clip: padding-box;
    border: var(--bs-modal-border-width, var(--bs-border-width, 1px)) solid var(--bs-modal-border-color, var(--bs-border-color-translucent, rgba(0, 0, 0, 0.175)));
    border-radius: var(--bs-modal-border-radius, var(--bs-border-radius-lg, 0.5rem));
    box-shadow: var(--bs-modal-box-shadow, var(--bs-box-shadow, 0 0.5rem 1rem rgba(0, 0, 0, 0.15)));
    outline: 0;
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-fit-content .modal-content,
.modal.fade.show.d-block .modal-dialog.modal-dialog-fit-content .modal-content {
    flex: 0 1 auto;
    overflow: hidden;
}

.clubivate-modal-dialog-host .modal-dialog.modal-dialog-fit-content .modal-body,
.modal.fade.show.d-block .modal-dialog.modal-dialog-fit-content .modal-body {
    flex: 0 1 auto;
    overflow-y: auto;
}

.clubivate-modal-dialog-host .modal-header,
.clubivate-modal-dialog-host .modal-footer,
.modal.fade.show.d-block .modal-header,
.modal.fade.show.d-block .modal-footer {
    flex-shrink: 0;
}

.clubivate-modal-dialog-host .modal-header,
.modal.fade.show.d-block .modal-header {
    display: flex;
    align-items: center;
    padding: var(--bs-modal-header-padding);
    border-bottom: var(--bs-modal-header-border-width) solid var(--bs-modal-header-border-color);
    border-top-left-radius: var(--bs-modal-inner-border-radius);
    border-top-right-radius: var(--bs-modal-inner-border-radius);
}

.clubivate-modal-dialog-host .modal-header .btn-close,
.modal.fade.show.d-block .modal-header .btn-close {
    padding: calc(var(--bs-modal-header-padding-y) * 0.5) calc(var(--bs-modal-header-padding-x) * 0.5);
    margin: calc(-0.5 * var(--bs-modal-header-padding-y)) calc(-0.5 * var(--bs-modal-header-padding-x)) calc(-0.5 * var(--bs-modal-header-padding-y)) auto;
}

.clubivate-modal-dialog-host .modal-body,
.modal.fade.show.d-block .modal-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: var(--bs-modal-padding);
    overflow-x: hidden;
    overflow-y: auto;
}

.clubivate-modal-dialog-host .modal-body:has(.listview-fill-container),
.modal.fade.show.d-block .modal-body:has(.listview-fill-container) {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.clubivate-modal-dialog-host .modal-footer,
.modal.fade.show.d-block .modal-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    padding: calc(var(--bs-modal-padding) - var(--bs-modal-footer-gap) * 0.5);
    background-color: var(--bs-modal-footer-bg);
    border-top: var(--bs-modal-footer-border-width) solid var(--bs-modal-footer-border-color);
    border-bottom-right-radius: var(--bs-modal-inner-border-radius);
    border-bottom-left-radius: var(--bs-modal-inner-border-radius);
}

.clubivate-modal-dialog-host .modal-footer > *,
.modal.fade.show.d-block .modal-footer > * {
    margin: calc(var(--bs-modal-footer-gap) * 0.5);
}

/* Short confirmations (edition sale recovery, etc.) — content height, not 90vh */
.clubivate-modal-dialog-host.modal-compact .modal-dialog,
.clubivate-modal-dialog-host.modal-compact .modal-dialog.modal-dialog-centered,
.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%);
}

.clubivate-modal-dialog-host.modal-compact .modal-content,
.modal.fade.show.d-block.modal-compact .modal-content {
    flex: 0 0 auto !important;
    overflow: visible;
    display: block;
}

.clubivate-modal-dialog-host.modal-compact .modal-body,
.modal.fade.show.d-block.modal-compact .modal-body {
    flex: 0 0 auto !important;
    overflow: visible;
}

/* Clubivate pill buttons in modal footers */
.clubivate-modal-dialog-host .modal-footer .btn,
.modal.fade.show.d-block .modal-footer .btn {
    border-radius: 1.5rem;
    padding: 0.375rem 1.25rem;
    white-space: nowrap;
}

.clubivate-modal-dialog-host .modal-footer .btn.use-btn,
.clubivate-modal-dialog-host .modal-footer .btn.coupon-save-btn,
.modal.fade.show.d-block .modal-footer .btn.use-btn,
.modal.fade.show.d-block .modal-footer .btn.coupon-save-btn {
    font-weight: 700;
    color: #063A35;
    background-color: #F8DC96;
    border-color: #F8DC96;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.clubivate-modal-dialog-host .modal-footer .btn.use-btn:hover:not(:disabled),
.clubivate-modal-dialog-host .modal-footer .btn.use-btn:focus:not(:disabled),
.clubivate-modal-dialog-host .modal-footer .btn.coupon-save-btn:hover:not(:disabled),
.clubivate-modal-dialog-host .modal-footer .btn.coupon-save-btn:focus:not(:disabled),
.modal.fade.show.d-block .modal-footer .btn.use-btn:hover:not(:disabled),
.modal.fade.show.d-block .modal-footer .btn.use-btn:focus:not(:disabled),
.modal.fade.show.d-block .modal-footer .btn.coupon-save-btn:hover:not(:disabled),
.modal.fade.show.d-block .modal-footer .btn.coupon-save-btn:focus:not(:disabled) {
    color: #063A35;
    background-color: #FDE7AF;
    border-color: #FDE7AF;
}

.clubivate-modal-dialog-host .modal-footer .btn.coupon-cancel-btn,
.modal.fade.show.d-block .modal-footer .btn.coupon-cancel-btn {
    font-weight: 600;
}

/* Content-sized confirm — dialog chrome only; backdrop is UiStack-driven */
.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);
}

/* Club hierarchy member import — wide ObjectModal (OverlayCssClass on host page). */
.clubivate-modal-dialog-host.club-hierarchy-import-modal .modal-dialog.modal-lg,
.clubivate-modal-dialog-host.club-hierarchy-import-modal .modal-dialog.modal-dialog-full {
    width: min(900px, calc(100vw - 2rem));
    max-width: min(900px, calc(100vw - 2rem));
}

/* Admin EUG coupon preview — phone-frame ObjectModal (portaled; EndUserGroupDetails). */
.clubivate-modal-dialog-host.coupon-admin-preview-modal .modal-dialog {
    width: min(430px, 95vw);
    max-width: 430px;
}

.clubivate-modal-dialog-host.coupon-admin-preview-modal .modal-content {
    display: flex;
    flex-direction: column;
    max-height: var(--clubivate-modal-viewport-height, calc(100dvh - 20px));
}

.clubivate-modal-dialog-host.coupon-admin-preview-modal .modal-body {
    padding: 0.75rem;
    background: #f1f3f5;
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/*
 * Coupon usage fullscreen display — documented exception.
 * Uses viewport host geometry (top/bottom chrome insets); custom gradient on host.
 * Card chrome lives in CouponUsageModal.razor.css.
 */
.ui-stack-layer--viewport-host.coupon-usage-backdrop {
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/*
 * Location filter bottom sheet — alignment on viewport host.
 * Sheet chrome: offer-list-search-filter.css (linked by EUG/Admin offer lists).
 */
.ui-stack-layer--viewport-host.location-filter-viewport-host {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

@media (min-width: 768px) {
    .ui-stack-layer--viewport-host.location-filter-viewport-host {
        align-items: center;
        padding: 1rem;
    }
}
