/**
 * Global centered modal contract for THOKIN.
 * Existing feature APIs stay unchanged; this only standardizes overlay geometry.
 */
:root {
    --thk-modal-z: 20000;
    --thk-modal-pad-top: max(0.75rem, env(safe-area-inset-top, 0px));
    --thk-modal-pad-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
}

body.thk-modal-open,
body.tx-pin-open {
    overflow: hidden !important;
    overscroll-behavior: none;
}

body.thk-modal-open .bottom-nav,
body.thk-modal-open .flow-confirm-bar,
body.tx-pin-open .bottom-nav,
body.tx-pin-open .flow-confirm-bar {
    visibility: hidden !important;
    pointer-events: none !important;
}

.thk-modal {
    position: fixed;
    inset: 0;
    z-index: var(--thk-modal-z);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--thk-modal-pad-top) 1rem var(--thk-modal-pad-bottom);
    box-sizing: border-box;
}
.thk-modal.is-open {
    display: flex;
}
.thk-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
}
.thk-modal__dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 28rem);
    max-height: min(86dvh, 40rem);
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 1.25rem;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
    overflow: hidden;
}
.thk-modal__body {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 1.25rem 1.15rem 1.15rem;
}
.thk-modal__title {
    margin: 0 0 0.35rem;
    font-size: 1.2rem;
    font-weight: 800;
    color: #111827;
}
.thk-modal__text {
    margin: 0 0 0.9rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #64748b;
}
.thk-modal__actions {
    display: grid;
    gap: 0.55rem;
    margin-top: 1rem;
}
.thk-modal__btn {
    min-height: 2.85rem;
    border-radius: 0.9rem;
    font-weight: 800;
    border: 0;
    cursor: pointer;
}
.thk-modal__btn--primary {
    background: var(--brand, #16833b);
    color: #fff;
}
.thk-modal__btn--ghost {
    background: #f8fafc;
    color: #111827;
    border: 1px solid #e2e8f0;
}
.thk-modal__btn--text {
    background: transparent;
    color: #64748b;
}
.thk-guide-video {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    border-radius: 0.85rem;
    overflow: hidden;
    background: #0f172a;
}
.thk-guide-video iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

#txPinModal,
#txPinCreateModal {
    align-items: center !important;
    justify-content: center !important;
    padding: var(--thk-modal-pad-top) 1rem var(--thk-modal-pad-bottom) !important;
    box-sizing: border-box !important;
}
#txPinModal form,
#txPinCreateModal form {
    width: min(100%, 28rem) !important;
    max-height: min(86dvh, 40rem) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    border-radius: 1.25rem !important;
    margin: 0 !important;
}

.flow-confirm-bar {
    z-index: 1100 !important;
}

:where(
    .idv-sheet,
    .verify-sheet,
    .airtime-sheet,
    .tba-sheet,
    .delivery-sheet,
    .gc-modal,
    .cm-modal,
    .cm-state-modal,
    .pwa-install-modal,
    .profile-bvn-modal,
    .vcard-info-modal,
    .dboy-sheet,
    .thokin-map-overlay,
    .tc-sheet-backdrop,
    .jmp-sheet,
    .mps-sheet
) {
    align-items: center !important;
    justify-content: center !important;
    padding: var(--thk-modal-pad-top) 1rem var(--thk-modal-pad-bottom) !important;
    box-sizing: border-box !important;
    z-index: var(--thk-modal-z) !important;
}

:where(
    .idv-sheet__card,
    .verify-sheet__card,
    .airtime-sheet__card,
    .tba-sheet__card,
    .delivery-sheet__card,
    .gc-modal__sheet,
    .pwa-install-modal__sheet,
    .profile-bvn-modal__panel,
    .vcard-info-modal__sheet,
    .dboy-sheet__card,
    .jmp-sheet__card,
    .mps-sheet__card
) {
    width: min(100%, 28rem) !important;
    max-height: min(86dvh, 40rem) !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    border-radius: 1.25rem !important;
    margin: 0 auto !important;
}

.thk-modal__prompt,
.thk-modal__input {
    width: 100%;
    min-height: 6rem;
    margin: 0.75rem 0 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid #d7e3de;
    border-radius: 0.85rem;
    font: inherit;
    resize: vertical;
}
.pos-sheet__panel {
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: min(100% - 2rem, 28rem) !important;
    max-height: min(86dvh, 40rem) !important;
    border-radius: 1.25rem !important;
}
.pos-sheet.is-open .pos-sheet__panel {
    transform: translate(-50%, -50%) !important;
}

.txr-sheet-backdrop {
    z-index: var(--thk-modal-z) !important;
}
.txr-sheet,
.txr-sheet.is-open {
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: min(calc(100% - 2rem), 28rem) !important;
    max-width: 28rem !important;
    border-radius: 1.25rem !important;
    z-index: calc(var(--thk-modal-z) + 1) !important;
    max-height: min(86dvh, 40rem) !important;
}

.thokin-map-overlay .thokin-map-sheet {
    width: min(100%, 40rem) !important;
    max-height: min(86dvh, 40rem) !important;
    border-radius: 1.25rem !important;
    margin: 0 auto !important;
}

@media (max-width: 639px) {
    :where(.fixed.inset-0.flex.items-end):not(.bottom-nav):not(#splash) {
        align-items: center !important;
        justify-content: center !important;
        padding: var(--thk-modal-pad-top) 1rem var(--thk-modal-pad-bottom) !important;
    }
    :where(.fixed.inset-0.flex.items-end):not(.bottom-nav):not(#splash) > :first-child {
        max-height: min(86dvh, 40rem) !important;
        width: min(100%, 28rem) !important;
        border-radius: 1.25rem !important;
        margin: 0 auto !important;
    }
}

.thk-modal__prompt {
    width: 100%;
    margin: 0.75rem 0 0;
    border: 1px solid #d5e0dc;
    border-radius: 0.75rem;
    padding: 0.75rem 0.85rem;
    font: inherit;
    min-height: 6rem;
    resize: vertical;
}
