/* MHBO Booking Modal — Shell, Overlay, Drawer, Animations */

/* ── Overlay ─────────────────────────────────────────────── */
.mhbo-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.mhbo-modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

/* ── Drawer ──────────────────────────────────────────────── */
.mhbo-modal-drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 99999;
    box-sizing: border-box;
    width: min(560px, 100vw);
    height: 100dvh;
    background: var(--mhbo-bg, #ffffff);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    overflow: hidden;
}

.mhbo-modal-overlay.is-open .mhbo-modal-drawer {
    transform: translateX(0);
}

/* ── Header ──────────────────────────────────────────────── */
.mhbo-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--mhbo-border, rgba(26, 54, 93, 0.15));
    flex-shrink: 0;
    background: var(--mhbo-primary, #1a365d);
    color: #fff;
}

.mhbo-modal-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: #ffffff;
}

.mhbo-modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    cursor: pointer;
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    transition: background 0.15s ease;
    flex-shrink: 0;
}

.mhbo-modal-close:hover,
.mhbo-modal-close:focus-visible {
    background: rgba(255, 255, 255, 0.28);
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

/* ── Body (scrollable) ───────────────────────────────────── */
.mhbo-modal-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 24px 24px 70px 24px;
    box-sizing: border-box;
    scroll-padding-top: 16px;
}

.mhbo-modal-body::-webkit-scrollbar {
    width: 5px;
}

.mhbo-modal-body::-webkit-scrollbar-thumb {
    background: var(--mhbo-primary, #1a365d);
    border-radius: 4px;
}

/* Modal Booking Form & Container Optimization */
.mhbo-modal-body .mhbo-booking-wrapper {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 0 !important;
}

.mhbo-modal-body .mhbo-booking-summary {
    background: #f8fafc !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 16px !important;
    padding: 20px !important;
    margin-bottom: 24px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
}

.mhbo-modal-body .mhbo-form-heading {
    margin: 20px 0 16px 0 !important;
    font-size: 1.35rem !important;
}

.mhbo-modal-body .mhbo-tax-breakdown-container,
.mhbo-modal-body div.mhbo-tax-breakdown-container,
div.mhbo-tax-breakdown-container[style] {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 20px 0 !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
}

.mhbo-modal-body .mhbo-tax-breakdown {
    background: #f8fafc !important;
    border: 1.5px solid #e2e8f0 !important;
    border-radius: 14px !important;
    padding: 16px 14px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04) !important;
    overflow: hidden !important;
}

.mhbo-modal-body table#mhbo-tax-breakdown-table,
.mhbo-modal-body .mhbo-tax-breakdown-table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    border-collapse: collapse !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

.mhbo-modal-body table#mhbo-tax-breakdown-table th:first-child,
.mhbo-modal-body table#mhbo-tax-breakdown-table td:first-child,
.mhbo-modal-body .mhbo-tax-breakdown-table th:first-child,
.mhbo-modal-body .mhbo-tax-breakdown-table td:first-child {
    width: 52% !important;
    text-align: left !important;
    padding: 10px 4px 10px 0 !important;
    box-sizing: border-box !important;
}

.mhbo-modal-body table#mhbo-tax-breakdown-table th:last-child,
.mhbo-modal-body table#mhbo-tax-breakdown-table td:last-child,
.mhbo-modal-body .mhbo-tax-breakdown-table th:last-child,
.mhbo-modal-body .mhbo-tax-breakdown-table td:last-child {
    white-space: nowrap !important;
    width: 48% !important;
    text-align: right !important;
    padding: 10px 6px 10px 0 !important;
    box-sizing: border-box !important;
}

/* Modal Payment Options & Coupon Spacing Fix */
.mhbo-modal-body .mhbo-deposit-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 16px 0 24px;
}

.mhbo-modal-body .mhbo-payment-card {
    width: 100%;
    min-width: 100%;
    margin-bottom: 0 !important;
    box-sizing: border-box !important;
}

.mhbo-modal-body .mhbo-coupon-wrapper {
    margin-top: 24px !important;
    padding-top: 20px !important;
    border-top: 1px dashed var(--mhbo-border, #e2e8f0) !important;
    margin-bottom: 16px !important;
}

.mhbo-modal-body .mhbo-coupon-wrapper label {
    margin-bottom: 8px !important;
}

/* Chat bubble collision prevention while modal is active */
body.mhbo-modal-open .mhbo-chat-widget,
.mhbo-modal-overlay.is-open ~ .mhbo-chat-widget {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
    transform: translateY(16px) scale(0.9) !important;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s !important;
}

/* ── Loading state ───────────────────────────────────────── */
.mhbo-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 24px;
    color: var(--mhbo-text-light, #64748b);
    font-size: 0.9rem;
}

.mhbo-modal-close svg {
    width: 32px;
    height: 32px;
    stroke-width: 2.5;
}

.mhbo-modal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--mhbo-border, rgba(26, 54, 93, 0.15));
    border-top-color: var(--mhbo-primary, #1a365d);
    border-radius: 50%;
    animation: mhboSpin 0.7s linear infinite;
}

@keyframes mhboSpin {
    to { transform: rotate(360deg); }
}

/* ── Error state ─────────────────────────────────────────── */
.mhbo-modal-error {
    margin: 24px 0;
    padding: 16px 20px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-left: 4px solid #ef4444;
    border-radius: var(--mhbo-radius, 12px);
    color: #991b1b;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ── Mobile: bottom drawer ───────────────────────────────── */
@media (max-width: 768px) {
    .mhbo-modal-drawer {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 92dvh;
        border-radius: var(--mhbo-radius-lg, 24px) var(--mhbo-radius-lg, 24px) 0 0;
        transform: translateY(100%);
        box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.18);
    }

    .mhbo-modal-overlay.is-open .mhbo-modal-drawer {
        transform: translateY(0);
    }

    /* Drag handle indicator */
    .mhbo-modal-header::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.4);
        border-radius: 2px;
    }

    .mhbo-modal-header {
        position: relative;
        padding-top: 24px;
    }

    .mhbo-modal-body {
        padding: 18px 16px 60px 16px !important;
    }

    .mhbo-modal-body .mhbo-booking-summary {
        padding: 16px 14px !important;
        border-radius: 14px !important;
        margin-bottom: 20px !important;
    }

    .mhbo-modal-body .mhbo-tax-breakdown {
        padding: 14px 12px !important;
        border-radius: 12px !important;
    }

    .mhbo-modal-body .mhbo-form-heading {
        font-size: 1.25rem !important;
        margin: 18px 0 14px 0 !important;
    }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .mhbo-modal-overlay,
    .mhbo-modal-drawer {
        transition: none;
    }

    .mhbo-modal-spinner {
        animation-duration: 1.5s;
    }
}

/* Mobile Optimization for Coupon Section */
@media screen and (max-width: 480px) {
    div.mhbo-coupon-input-row {
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch !important;
        overflow: hidden !important;
    }

    input.mhbo-coupon-code-input {
        min-height: 44px !important;
        font-size: 15px !important;
        flex: 1 1 0% !important;
        min-width: 0 !important;
        width: auto !important;
    }

    button.mhbo-coupon-apply-btn,
    button.mhbo-coupon-remove-btn,
    .mhbo-coupon-input-row .mhbo-btn {
        min-height: 44px !important;
        padding: 0 16px !important;
        width: auto !important;
        max-width: none !important;
        flex: 0 0 auto !important;
        border-radius: 0 10px 10px 0 !important;
    }
}

/* Mobile Optimization for Booking/Tax Breakdown Table */
@media screen and (max-width: 480px) {
    /* 1. Eliminate heavy parent margins and padding that cause nested boxing */
    div.mhbo-tax-breakdown-container {
        margin: 14px 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .mhbo-modal-body .mhbo-tax-breakdown {
        padding: 14px 10px !important;
        border-radius: 14px !important;
        margin: 0 !important;
        background: #f8fafc !important;
        border: 1px solid #e2e8f0 !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
    }

    /* 2. Force the table to behave fluidly and consistently */
    table#mhbo-tax-breakdown-table {
        width: 100% !important;
        table-layout: fixed !important; /* Forces strict adherence to defined column widths */
    }

    /* 3. Divide columns cleanly: 52% for names, 48% for prices with zero edge clipping */
    table#mhbo-tax-breakdown-table th:first-child,
    table#mhbo-tax-breakdown-table td:first-child {
        width: 52% !important;
        text-align: left !important;
        font-size: 12px !important;
        padding: 6px 2px 6px 0 !important;
        box-sizing: border-box !important;
    }

    table#mhbo-tax-breakdown-table th:last-child,
    table#mhbo-tax-breakdown-table td:last-child {
        width: 48% !important;
        text-align: right !important;
        font-size: 12px !important;
        padding: 6px 4px 6px 0 !important;
        white-space: nowrap !important;
        box-sizing: border-box !important;
    }

    /* 5. Tweak header text spacing */
    table#mhbo-tax-breakdown-table th {
        font-size: 11px !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }
    
    /* 6. Clean up the bottom VAT registration line alignment */
    p.mhbo-tax-registration {
        font-size: 11px !important;
        margin-top: 8px !important;
        text-align: left !important;
    }
}

/* iOS Safari zoom fix for form fields */
@media screen and (max-width: 768px) {
    .mhbo-booking-modal input,
    .mhbo-booking-modal select,
    .mhbo-booking-modal textarea {
        font-size: 16px !important;
    }
}

/* Hide standalone mobile sticky bar inside modal drawer */
.mhbo-modal-drawer .mhbo-mobile-sticky-bar,
.mhbo-modal-form .mhbo-mobile-sticky-bar {
    display: none !important;
}
