/* Checkout bottom sheet - premium visual layer only. Nothing in this file
   changes form field names/ids, submit targets, or any checkout logic -
   it only restyles the existing markup in includes/checkout_content.php.
   Colors reference styles/variables.css so this stays consistent with the
   rest of the site's light/dark theme (loaded before this file via
   includes/header.php). */

#roladel-checkout-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.55);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    z-index: 10500;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    /* Defensive: a stray touchmove on the dark backdrop area itself
       should never be able to scroll/bounce the page behind it either. */
    overscroll-behavior: contain;
}

#roladel-checkout-overlay.roladel-active {
    opacity: 1;
    visibility: visible;
}

#roladel-checkout-sheet {
    background: var(--light-bg, #fff);
    color: var(--light-text, #222);
    width: 100%;
    /* Shrinks to fit its content (header + scrollable body + footer) up
       to max-height, instead of always claiming 65% of the viewport -
       short content (e.g. just the order summary, no long payment list)
       no longer leaves a stretch of empty scroll area with the footer
       stranded below the viewport's 65vh mark. .roladel-sheet-body's own
       overflow-y:auto still takes over once real content exceeds
       max-height. */
    height: auto;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -8px 40px rgba(0, 0, 0, 0.25);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    overflow: hidden;
}

#roladel-checkout-overlay.roladel-active #roladel-checkout-sheet {
    transform: translateY(0);
}

.roladel-sheet-handle {
    width: 50px;
    height: 5px;
    border-radius: 999px;
    background: #d9d9dc;
    margin: 12px auto 0;
    flex: 0 0 auto;
}

.roladel-sheet-header {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 12px 0 12px;
    flex: 0 0 auto;
}

.roladel-sheet-close {
    background: var(--light-surface, #f5f5f5);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    color: var(--light-text-muted, #6c757d);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.1s ease;
}

.roladel-sheet-close:hover {
    background: #ebebeb;
}

.roladel-sheet-close:active {
    transform: scale(0.92);
}

.roladel-sheet-body {
    overflow-y: auto;
    flex: 1 1 auto;
    /* Without this, a flex item's default min-height:auto lets its
       content size win over max-height's intent to cap the sheet -
       min-height:0 is what actually lets this element shrink and hand
       off overflow to its own overflow-y:auto once #roladel-checkout-sheet
       hits max-height, instead of the sheet just growing past it. */
    min-height: 0;
    /* This is the actual fix for the shake/bounce/jitter while scrolling:
       without it, scrolling past the top or bottom edge of this element
       "chains" into the page behind the sheet, causing the whole
       underlying page to rubber-band. On mobile that page-level bounce
       also drags the browser's own address bar in and out, which
       recomputes every vh-based value on the sheet (its own
       max-height:85vh above) mid-scroll - the sheet visibly resizing
       while the user is trying to scroll it is what reads as "shaking".
       overscroll-behavior-y:contain stops the chain at this element's own
       boundary, so the page behind (and thus the address bar, and thus
       the sheet's own vh-based height) never moves at all. */
    overscroll-behavior-y: contain;
    padding: 8px 24px 24px 24px;
    /* .roladel-checkout-footer is a proper flex sibling of this element
       (not nested inside it), so the browser's own layout already keeps
       them from overlapping regardless of this padding's size - this is
       just the same breathing room used on the other 3 sides, not sized
       to the footer's height. A larger reserve here would inflate
       #roladel-checkout-sheet's height:auto for short content that
       doesn't need it, leaving empty space above the footer. */
    padding-left: max(24px, env(safe-area-inset-left));
    padding-right: max(24px, env(safe-area-inset-right));
}

/* ===== Section cards (Contact Information / Order Summary / Payment
   Options) - restyles the existing Bootstrap .card markup in place, no
   HTML changes needed. ===== */

#roladel-checkout-sheet .card {
    border: none;
    border-radius: 18px;
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.06);
    margin-bottom: 20px;
    background: var(--light-bg, #fff);
    animation: roladel-card-fade-in 0.35s ease both;
}

#roladel-checkout-sheet .card:last-child {
    margin-bottom: 0;
}

#roladel-checkout-sheet .card-header {
    background: transparent;
    border-bottom: 1px solid var(--light-border, #eee);
    padding: 18px 20px;
}

#roladel-checkout-sheet .card-header h5 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: var(--light-text, #222);
}

/* ===== Contact Information card header - replaced with the seller's own
   avatar + @username, same card/spacing otherwise unchanged. ===== */

.roladel-contact-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.roladel-contact-avatar {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.roladel-contact-username {
    margin: 0;
}

#roladel-checkout-sheet .card-body {
    padding: 20px;
}

/* Tightens the stock Bootstrap 1rem hr margins used throughout the Order
   Summary card (proposal price / qty / fees / coupon / total rows), so
   the card reads as compact rather than leaving visible gaps between
   each row. */
#roladel-checkout-sheet .card-body hr {
    margin: 10px 0;
}

/* ===== Order Summary header - proposal image beside title/seller/rating,
   side-by-side at every width (not a Bootstrap col-md- row, which used
   to stack the image above the title on mobile). ===== */

.roladel-order-summary-head {
    display: flex;
    align-items: center;
    gap: 14px;
}

.roladel-order-summary-img {
    flex: 0 0 auto;
    width: 72px;
    height: 72px;
    border-radius: 12px;
    object-fit: cover;
    display: block;
}

.roladel-order-summary-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light-surface, #f0f0f0);
    color: var(--light-text-muted, #adb5bd);
    font-size: 22px;
}

.roladel-order-summary-body {
    min-width: 0;
    flex: 1 1 auto;
}

.roladel-order-summary-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 2px 0;
    color: var(--light-text, #222);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.roladel-order-summary-seller {
    font-size: 13px;
    color: var(--light-text-muted, #6c757d);
    margin: 0 0 2px 0;
}

.roladel-order-summary-rating {
    margin: 0;
    line-height: 1;
}

.roladel-order-summary-star {
    width: 12px;
    height: 12px;
    margin-right: 1px;
}

@keyframes roladel-card-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Typography ===== */

#roladel-checkout-sheet label {
    font-size: 14px;
    color: var(--light-text-muted, #6c757d);
    font-weight: 500;
}

#roladel-checkout-sheet .form-control,
#roladel-checkout-sheet input[type="email"],
#roladel-checkout-sheet input[type="text"],
#roladel-checkout-sheet select {
    font-size: 16px;
    border-radius: 12px;
    border: 1px solid var(--light-border, #ddd);
    padding: 12px 14px;
    height: auto;
    background: var(--light-bg, #fff);
    color: var(--light-text, #222);
}

#roladel-checkout-sheet .form-control:focus {
    border-color: #000;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* ===== Buttons - tap feedback, no random Bootstrap-blue ===== */

#roladel-checkout-sheet .btn {
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.08s ease, box-shadow 0.15s ease;
}

#roladel-checkout-sheet .btn:active {
    transform: scale(0.97);
}

/* Every "Pay With ..." gateway button (and the coupon Apply button) is
   .btn-success, several with an inline background-color:#085812 style in
   includes/checkout_content.php - !important is required here to win
   over those inline styles without touching that markup. This is the
   sheet's one true "primary button" color per the black-and-white design
   system; the footer's moved-in payment button is this exact same
   element, so it's covered automatically. */
#roladel-checkout-sheet .btn-success {
    background-color: #000 !important;
    border-color: #000 !important;
    color: #fff !important;
}

#roladel-checkout-sheet .btn-success:hover,
#roladel-checkout-sheet .btn-success:focus {
    background-color: #1a1a1a !important;
    border-color: #1a1a1a !important;
}

/* ===== Payment method cards ===== */

.roladel-pay-card {
    display: block;
    margin: 0 0 12px 0;
    cursor: pointer;
}

.roladel-pay-radio {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.roladel-pay-card-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    border: 2px solid var(--light-border, #e5e5e5);
    border-radius: 18px;
    padding: 16px 18px;
    background: var(--light-surface, #f8f9fa);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
    position: relative;
}

.roladel-pay-card:active .roladel-pay-card-inner {
    transform: scale(0.985);
}

.roladel-pay-radio:checked ~ .roladel-pay-card-inner {
    border-color: #000;
    background: #f0f0f0;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, 0.08), 0 6px 18px rgba(0, 0, 0, 0.1);
    transform: scale(1.015);
}

.roladel-pay-logo-wrap {
    flex: 0 0 auto;
    width: 84px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.roladel-pay-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.roladel-pay-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--light-bg, #fff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #555555;
    border: 1px solid var(--light-border, #e5e5e5);
}

.roladel-pay-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.roladel-pay-caption {
    font-size: 13px;
    color: var(--light-text-muted, #6c757d);
}

.roladel-pay-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--light-text, #222);
}

.roladel-pay-check {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.roladel-pay-radio:checked ~ .roladel-pay-card-inner .roladel-pay-check {
    opacity: 1;
    transform: scale(1);
}

/* ===== "Order Now" button loading spinner - replaces the button's own
   text with just this, while js/checkout-sheet.js locks the button's
   width/height via inline styles first so nothing shifts. Sized for a
   small dark button (white ring on a black background, matching every
   "Order Now" button's own styling). ===== */

.roladel-btn-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: roladel-btn-spin 0.7s linear infinite;
}

@keyframes roladel-btn-spin {
    to {
        transform: rotate(360deg);
    }
}

.roladel-sheet-error {
    padding: 40px 24px;
    text-align: center;
    color: #b02a37;
}

/* ===== Checkout footer - ~118px tall. Contains ONLY the Terms checkbox,
   the real, moved-in gateway payment button, and a one-line purchase
   disclaimer beneath it; nothing else lives here. Built as a static
   sibling of .roladel-sheet-body in js/checkout-sheet.js's sheetMarkup()
   (not part of the AJAX-loaded includes/checkout_content.php content), so
   it stays a genuine fixed footer via flexbox below - never something
   that scrolls past mid-page or overlaps the last card/button/coupon
   field in the scroll area. ===== */

/* A genuine flex sibling of .roladel-sheet-body (both children of
   #roladel-checkout-sheet, already display:flex; flex-direction:column;)
   - not positioned on top of the scroll area, so it can never overlap or
   drift mid-scroll. flex-shrink:0 keeps it at its natural height while
   .roladel-sheet-body's flex:1/overflow-y:auto absorbs all remaining
   space and does all the scrolling. */
.roladel-checkout-footer {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    border-top: 1px solid var(--light-border, #eee);
    background: var(--light-bg, #fff);
}

.roladel-terms-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    color: var(--light-text-muted, #6c757d);
    cursor: pointer;
    margin: 0;
}

.roladel-terms-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #000;
    flex: 0 0 auto;
    cursor: pointer;
}

.roladel-terms-check a {
    color: inherit;
    text-decoration: underline;
}

/* Holds whichever gateway's own, unchanged "Pay With ..." button
   js/checkout-sheet.js has moved in for the currently-selected payment
   method (see syncFooterButton()) - no button is styled here, since the
   real button already brings its own existing classes/inline styles
   (btn btn-lg btn-success btn-block, background-color:#085812, etc.)
   exactly as it looks on the rest of this same checkout page. */
#roladel-pay-btn-slot:empty {
    display: none;
}

#roladel-pay-btn-slot .btn {
    margin: 0;
}

/* Compact one-line disclaimer under the payment button - text only, no
   layout weight beyond its own small margin/padding, so the footer stays
   close to its original height. */
.roladel-purchase-disclaimer {
    margin: 8px 0 0 0;
    padding-bottom: 8px;
    text-align: center;
    font-size: 12px;
    line-height: 1.35;
    color: var(--light-text-muted, #6c757d);
}

.roladel-purchase-disclaimer a {
    color: inherit;
    text-decoration: underline;
}

/* ===== Desktop: centered modal, not a bottom sheet ===== */

@media (min-width: 768px) {

    #roladel-checkout-overlay {
        align-items: center;
    }

    #roladel-checkout-sheet {
        max-width: 560px;
        height: auto;
        max-height: 85vh;
        border-radius: 24px;
        transform: translateY(24px);
        box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
    }

    #roladel-checkout-overlay.roladel-active #roladel-checkout-sheet {
        transform: translateY(0);
    }

    .roladel-sheet-handle {
        display: none;
    }
}

body.roladel-sheet-open {
    overflow: hidden;
}

/* ===== Dark mode - reuses the site's existing dark-mode tokens ===== */

html.dark #roladel-checkout-overlay {
    background: rgba(0, 0, 0, 0.7);
}

html.dark #roladel-checkout-sheet {
    background: var(--dark-bg, #121212);
    color: var(--dark-text, #fff);
}

html.dark .roladel-sheet-handle {
    background: #4a4a4a;
}

html.dark .roladel-sheet-close {
    background: var(--dark-surface-alt, #2a2a2a);
    color: var(--dark-text-muted, #aaa);
}

html.dark .roladel-sheet-close:hover {
    background: #333;
}

html.dark #roladel-checkout-sheet .card {
    background: var(--dark-surface, #1e1e1e);
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}

html.dark #roladel-checkout-sheet .card-header {
    border-bottom-color: var(--dark-border, #333);
}

html.dark #roladel-checkout-sheet .card-header h5,
html.dark #roladel-checkout-sheet .roladel-pay-title,
html.dark .roladel-order-summary-title,
html.dark .roladel-contact-username {
    color: var(--dark-text, #fff);
}

html.dark .roladel-order-summary-img-placeholder {
    background: var(--dark-surface-alt, #2a2a2a);
    color: var(--dark-text-muted, #aaa);
}

html.dark #roladel-checkout-sheet label,
html.dark #roladel-checkout-sheet .roladel-pay-caption,
html.dark .roladel-terms-check,
html.dark .roladel-purchase-disclaimer,
html.dark .roladel-order-summary-seller {
    color: var(--dark-text-muted, #aaa);
}

html.dark #roladel-checkout-sheet .form-control,
html.dark #roladel-checkout-sheet input[type="email"],
html.dark #roladel-checkout-sheet select {
    background: var(--dark-surface-alt, #2a2a2a);
    border-color: var(--dark-border, #333);
    color: var(--dark-text, #fff);
}

html.dark .roladel-pay-card-inner {
    background: var(--dark-surface-alt, #2a2a2a);
    border-color: var(--dark-border, #333);
}

html.dark .roladel-pay-icon {
    background: var(--dark-surface, #1e1e1e);
    border-color: var(--dark-border, #333);
    color: #aaaaaa;
}

/* Dark mode's equivalent of the light-mode selected card being
   black-bordered: white takes over as the "primary" color here (a plain
   black border/glow would be invisible against this already-dark
   background), matching how every other dark-mode rule in this file
   already inverts black<->white (e.g. the terms checkbox's accent-color,
   the sheet handle). */
html.dark .roladel-pay-radio:checked ~ .roladel-pay-card-inner {
    border-color: #ffffff;
    background: var(--dark-surface-alt, #2a2a2a);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.12), 0 6px 18px rgba(0, 0, 0, 0.3);
}

html.dark .roladel-pay-check {
    background: #ffffff;
    color: #000000;
}

html.dark #roladel-checkout-sheet .btn-success {
    background-color: #ffffff !important;
    border-color: #ffffff !important;
    color: #000000 !important;
}

html.dark #roladel-checkout-sheet .btn-success:hover,
html.dark #roladel-checkout-sheet .btn-success:focus {
    background-color: #e6e6e6 !important;
    border-color: #e6e6e6 !important;
}

html.dark #roladel-checkout-sheet .form-control:focus {
    border-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.12);
}

html.dark .roladel-terms-check input[type="checkbox"] {
    accent-color: #fff;
}

html.dark .roladel-checkout-footer {
    background: #111111;
    border-top-color: var(--dark-border, #333);
}
