/* ==========================================================================
   Homelli v2.0 - Checkout & Payment Stylesheet
   High-performance modular stylesheet (Desktop & Mobile Optimized)
   ========================================================================== */

/* ==========================================================================
   CHECKOUT PAGE LAYOUT (DESKTOP FIRST)
   ========================================================================== */
.hml-checkout-wrapper {
    padding: 40px 0 80px;
    background-color: #fcfcfc;
}

.hml-checkout-header {
    margin-bottom: 28px;
}

.hml-checkout-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--hml-dark);
    letter-spacing: -0.3px;
}

.hml-checkout-header p {
    color: var(--hml-gray-text);
    margin: 0;
    font-size: 14.5px;
}

/* 2-Column Grid with Desktop Sticky Support */
.hml-checkout-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 36px;
    align-items: start; /* CRITICAL: Enables sticky child within grid column */
}

/* Desktop Sticky Wrapper for Order Summary */
.hml-checkout-summary-wrap {
    position: sticky;
    top: 92px; /* Leaves breathing room below sticky header */
    align-self: start;
    z-index: 10;
}

/* Checkout Cards */
.hml-checkout-card {
    background: var(--hml-white);
    border: 1px solid var(--hml-gray-border);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03);
}

.hml-checkout-card h2 {
    font-size: 19px;
    font-weight: 700;
    margin-bottom: 22px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--hml-gray-border);
    color: var(--hml-dark);
    letter-spacing: -0.2px;
}

/* Form Groups & Inputs */
.hml-form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

.hml-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.hml-form-group label {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--hml-dark);
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.hml-form-control {
    padding: 12px 14px;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    background: #fafafa;
    font-size: 14.5px;
    color: var(--hml-dark);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
    font-family: inherit;
    width: 100%;
    box-sizing: border-box;
}

.hml-form-control:focus {
    border-color: var(--hml-dark);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
}

textarea.hml-form-control {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

select.hml-form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23333333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 12px;
    padding-right: 36px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Payment Methods */
.hml-payment-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.hml-payment-opt {
    border: 1.5px solid var(--hml-gray-border);
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    transition: all 0.2s ease;
}

.hml-payment-opt:hover {
    border-color: #bbb;
}

.hml-payment-opt:has(input:checked) {
    border-color: var(--hml-dark);
    background: #fbfbfb;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.hml-payment-opt input[type="radio"] {
    accent-color: var(--hml-dark);
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Invoice Type Selector */
.hml-invoice-type-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.hml-invoice-type-opt {
    border: 1.5px solid var(--hml-gray-border);
    border-radius: 8px;
    padding: 13px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--hml-dark);
    background: var(--hml-white);
    transition: all 0.2s ease;
    user-select: none;
}

.hml-invoice-type-opt input[type="radio"] {
    accent-color: var(--hml-dark);
    cursor: pointer;
}

.hml-invoice-type-opt:has(input:checked) {
    border-color: var(--hml-dark);
    background: var(--hml-dark);
    color: var(--hml-white);
}

.hml-invoice-type-opt:has(input:checked) span {
    color: var(--hml-white);
}

.hml-invoice-box {
    background: #fbfbfb;
    border: 1px solid var(--hml-gray-border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 24px;
}

.hml-checkbox-group {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--hml-dark);
    user-select: none;
}

.hml-checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--hml-dark);
    cursor: pointer;
}

/* Order Summary Details */
.hml-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 14px;
    color: var(--hml-gray-text);
}

.hml-summary-total {
    border-top: 2px solid var(--hml-dark);
    margin-top: 14px;
    padding-top: 16px;
    font-size: 19px;
    font-weight: 800;
    color: var(--hml-dark);
}

/* Checkout Trust Badges */
.hml-checkout-trust-badges {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
    padding-top: 18px;
    border-top: 1px solid #eeeeee;
}

.hml-trust-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
}

.hml-trust-item-icon {
    font-size: 18px;
    line-height: 1;
}

.hml-trust-item-text {
    font-size: 11px;
    font-weight: 600;
    color: #666666;
    line-height: 1.25;
}

/* Preorder Banner Responsive Styles */
.hml-checkout-preorder-banner {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 2px solid #f59e0b;
    border-radius: 12px;
    padding: 18px 22px;
    margin-bottom: 24px;
    box-shadow: 0 4px 18px rgba(217, 119, 6, 0.12);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.hml-preorder-banner-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 260px;
}

.hml-preorder-banner-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #d97706;
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.3);
}

.hml-preorder-banner-right {
    background: rgba(255, 255, 255, 0.85);
    border: 1px dashed #d97706;
    border-radius: 8px;
    padding: 8px 14px;
    font-size: 12.5px;
    color: #78350f;
    font-weight: 700;
    text-align: right;
    white-space: nowrap;
}

/* ==========================================================================
   MOBILE TOP SUMMARY ACCORDION (Hidden on Desktop)
   ========================================================================== */
.hml-mobile-summary-accordion {
    display: none;
    background: #ffffff;
    border: 1px solid var(--hml-gray-border);
    border-radius: 10px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
}

.hml-mobile-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    background: #fbfbfb;
    -webkit-tap-highlight-color: transparent;
}

.hml-mobile-summary-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hml-mobile-summary-thumb {
    width: 38px;
    height: 38px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid #e0e0e0;
}

.hml-mobile-summary-title-text {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--hml-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.hml-mobile-summary-subtext {
    font-size: 11.5px;
    color: #0284c7;
    font-weight: 600;
    display: block;
    margin-top: 1px;
}

.hml-mobile-summary-chevron {
    font-size: 13px;
    transition: transform 0.25s ease;
    display: inline-block;
}

.hml-mobile-summary-accordion.open .hml-mobile-summary-chevron {
    transform: rotate(180deg);
}

.hml-mobile-summary-header-right {
    text-align: right;
}

.hml-mobile-summary-header-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--hml-dark);
}

.hml-mobile-summary-drawer {
    display: none;
    padding: 16px;
    border-top: 1px solid var(--hml-gray-border);
    background: #ffffff;
}

.hml-mobile-summary-accordion.open .hml-mobile-summary-drawer {
    display: block;
    animation: hmlFadeIn 0.2s ease-out;
}

@keyframes hmlFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Spinner & Button Submission State */
.hml-spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: hmlSpin 0.75s linear infinite;
    vertical-align: middle;
    margin-right: 8px;
}

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

.hml-btn-submitting {
    opacity: 0.75 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

/* ==========================================================================
   RESPONSIVE MEDIA QUERIES (FIXING MOBILE ISSUES)
   ========================================================================== */
@media (max-width: 991px) {
    .hml-checkout-wrapper {
        padding: 18px 0 60px;
    }

    .hml-checkout-header {
        margin-bottom: 18px;
    }

    .hml-checkout-header h1 {
        font-size: 22px;
        margin-bottom: 4px;
    }

    .hml-checkout-header p {
        font-size: 13.5px;
    }

    /* Single column layout on mobile */
    .hml-checkout-grid {
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    /* Order Summary becomes static on mobile (no awkward side sticky) */
    .hml-checkout-summary-wrap {
        position: static;
        top: auto;
        width: 100%;
    }

    .hml-checkout-card {
        padding: 22px 18px;
        border-radius: 12px;
    }

    .hml-checkout-card h2 {
        font-size: 17px;
        margin-bottom: 18px;
        padding-bottom: 10px;
    }

    /* All form rows stack cleanly on mobile */
    .hml-form-row {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 14px;
    }

    /* Minimum 16px font-size prevents iOS Safari auto-zoom on input focus */
    .hml-form-control {
        font-size: 16px !important;
        min-height: 48px;
        padding: 12px 14px;
        border-radius: 8px;
    }

    textarea.hml-form-control {
        min-height: 90px;
    }

    /* Show mobile top summary accordion */
    .hml-mobile-summary-accordion {
        display: block;
    }

    /* Preorder banner on mobile */
    .hml-checkout-preorder-banner {
        padding: 16px;
        gap: 14px;
        border-radius: 10px;
    }

    .hml-preorder-banner-left {
        gap: 12px;
    }

    .hml-preorder-banner-icon {
        width: 42px;
        height: 42px;
        font-size: 20px;
    }

    .hml-preorder-banner-right {
        width: 100%;
        text-align: left;
        white-space: normal;
        font-size: 12px;
    }

    /* Trust badges in 3 columns on mobile */
    .hml-checkout-trust-badges {
        gap: 6px;
    }

    .hml-trust-item-text {
        font-size: 10px;
    }
}

/* Checkout Quantity Selector */
.hml-co-mob-qty-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--hml-gray-border);
    background: #ffffff;
    font-size: 13px;
    font-weight: 600;
    color: var(--hml-dark);
}

.hml-co-qty-picker {
    display: inline-flex;
    align-items: center;
    border: 1.5px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.hml-co-qty-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: #f8fafc;
    color: var(--hml-dark);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s ease;
}

.hml-co-qty-btn:hover {
    background: #e2e8f0;
}

.hml-co-qty-input {
    width: 36px;
    height: 30px;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
    color: var(--hml-dark);
    background: #ffffff;
    padding: 0;
    -moz-appearance: textfield;
}

.hml-co-qty-input:focus {
    outline: none;
}

.hml-co-qty-input::-webkit-outer-spin-button,
.hml-co-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Distraction-free checkout: Hide floating reviews badge on checkout page */
.hml-google-floating-badge {
    display: none !important;
}

@media (max-width: 640px) {
    .hml-container {
        padding: 0 16px;
    }

    .hml-checkout-card {
        padding: 18px 14px;
    }

    .hml-invoice-type-toggle {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .hml-invoice-type-opt {
        min-height: 46px;
        font-size: 14px;
    }

    .hml-payment-opt {
        padding: 14px 12px;
    }

    /* Distraction-free mobile checkout: Hide floating WhatsApp button */
    .hml-floating-wa {
        display: none !important;
    }
}
