/* ============================================================
   SONIC STOREFRONT — Shopify-Style Premium Checkout Styles
   ============================================================ */

/* ── Prevent Horizontal Scroll / Mobile Overflow Lock ── */
html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
    width: 100% !important;
    background-color: #f8f9fa !important; /* Premium light grey page bg */
    color: #333333 !important;
}

.checkout-page {
    background-color: #f8f9fa !important;
    padding: 24px 0 60px !important;
}

.checkout-page .store-container {
    max-width: 1200px !important;
    width: 100% !important;
    padding: 0 16px !important;
    box-sizing: border-box !important;
    min-width: 0 !important;
}

/* ── Page Layout ── */
.checkout-layout {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 24px !important;
    align-items: start !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

@media (min-width: 992px) {
    .checkout-layout {
        grid-template-columns: minmax(0, 1fr) minmax(0, 420px) !important;
        gap: 32px !important;
    }
}

/* ── Card Containers ── */
.checkout-form-card,
.order-summary-card {
    padding: 30px !important;
    background: #ffffff !important;
    border: 1px solid #e6e6e6 !important;
    border-radius: 8px !important;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05) !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* ── Typography & Headers ── */
.checkout-section-title {
    font-size: 1.25rem !important;
    font-weight: 700 !important;
    color: #212529 !important;
    margin-bottom: 8px !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}

.checkout-section-head p {
    font-size: 0.88rem !important;
    color: #666666 !important;
    margin-bottom: 16px !important;
}

.checkout-head {
    display: flex !important;
    align-items: flex-start !important;
    justify-content: space-between !important;
    gap: 16px !important;
    margin: 10px 0 24px !important;
    flex-wrap: wrap !important;
}

.checkout-title {
    font-size: 1.8rem !important;
    font-weight: 800 !important;
    line-height: 1.25 !important;
    color: #212529 !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}

/* ── Breadcrumb swipeable on Mobile ── */
.store-breadcrumb {
    padding: 12px 0 !important;
    font-size: 0.82rem !important;
    margin-bottom: 8px !important;
    color: #666666 !important;
}

.store-breadcrumb a {
    color: #197bbd !important;
    transition: color 0.2s ease !important;
}

.store-breadcrumb a:hover {
    color: #15669e !important;
}

/* ── Form Fields Grid ── */
.checkout-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 16px !important;
    margin-bottom: 24px !important;
}

@media (min-width: 600px) {
    .checkout-grid {
        grid-template-columns: 1fr 1fr !important;
    }
    .checkout-field--full {
        grid-column: span 2 !important;
    }
}

.checkout-field {
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    min-width: 0 !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

.checkout-field .form-label {
    display: block !important;
    font-size: 0.85rem !important;
    font-weight: 600 !important;
    margin-bottom: 6px !important;
    color: #4a4a4a !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}

.checkout-field .form-label .text-danger {
    color: #e74c3c !important;
}

/* ── Shopify style inputs ── */
.checkout-field .store-input,
.checkout-field .store-select,
.checkout-field .store-textarea,
.lp-input,
.lp-select,
.lp-textarea {
    width: 100% !important;
    padding: 12px 14px !important;
    background-color: #ffffff !important;
    border: 1px solid #d9d9d9 !important;
    border-radius: 5px !important;
    color: #333333 !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
    font-size: 0.9rem !important;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out !important;
    outline: none !important;
    box-shadow: none !important;
}

.checkout-field .store-input {
    height: 46px !important;
}

.checkout-field .store-input::placeholder,
.checkout-field .store-textarea::placeholder,
.lp-input::placeholder,
.lp-textarea::placeholder {
    color: #a6a6a6 !important;
    opacity: 0.8 !important;
}

.checkout-field .store-input:focus,
.checkout-field .store-textarea:focus,
.checkout-field .store-select:focus,
.lp-input:focus,
.lp-textarea:focus,
.lp-select:focus {
    border-color: #197bbd !important;
    box-shadow: 0 0 0 1px #197bbd !important;
    background-color: #ffffff !important;
}

.checkout-field .store-textarea,
.lp-textarea {
    resize: vertical !important;
    min-height: 80px !important;
}

.checkout-help {
    font-size: 0.78rem !important;
    color: #666666 !important;
    margin-top: 4px !important;
}

/* ── Shopify Payment Box Group ── */
.shopify-payment-box {
    border: 1px solid #d9d9d9 !important;
    border-radius: 8px !important;
    background-color: #ffffff !important;
    overflow: hidden !important;
    margin: 16px 0 24px !important;
    display: flex !important;
    flex-direction: column !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05) !important;
}

.shopify-payment-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 16px 20px !important;
    border-bottom: 1px solid #e6e6e6 !important;
    transition: background-color 0.2s ease-in-out !important;
    background-color: #ffffff !important;
    cursor: pointer !important;
}

.shopify-payment-row:hover {
    background-color: #fbfbfb !important;
}

.shopify-payment-row:has(.shopify-payment-radio:checked) {
    background-color: #f4f8fa !important;
}

.shopify-payment-row.last-row {
    border-bottom: none !important;
}

.shopify-payment-label {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    cursor: pointer !important;
    margin: 0 !important;
    flex: 1 !important;
}

.shopify-payment-radio {
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
    accent-color: #197bbd !important;
    cursor: pointer !important;
}

.shopify-payment-name {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    color: #333333 !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}

.shopify-payment-icons {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

/* ── Coupon & Discount ── */
.coupon-input-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e6e6e6;
}

.coupon-input-row {
    display: flex;
    gap: 8px;
}

.coupon-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d9d9d9;
    border-radius: 5px;
    background-color: #ffffff;
    color: #333333;
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    outline: none;
    transition: border-color 0.2s;
}

.coupon-input:focus {
    border-color: #197bbd;
}

.coupon-apply-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    background: #197bbd;
    color: #ffffff;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.2s;
}

.coupon-apply-btn:hover {
    background-color: #15669e;
}

.coupon-message {
    font-size: 0.78rem;
    margin-top: 6px;
    font-weight: 600;
}

.coupon-message.success { color: #10b981; }
.coupon-message.error { color: #ef4444; }

.coupon-applied {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: #e8f8f2;
    border: 1px solid #b3e5d1;
    border-radius: 5px;
    color: #10b981;
}

.coupon-applied-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.88rem;
    font-weight: 700;
}

.coupon-remove-btn {
    background: none;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 0.9rem;
}

/* ── Wallet Deductions ── */
.wallet-checkout-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e6e6e6;
}

.wallet-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.wallet-toggle input { display: none; }

.wallet-toggle-slider {
    width: 44px;
    height: 24px;
    background-color: #d9d9d9;
    border-radius: 12px;
    position: relative;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.wallet-toggle-slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background-color: #ffffff;
    border-radius: 50%;
    top: 3px;
    right: 3px;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.wallet-toggle input:checked + .wallet-toggle-slider {
    background-color: #10b981;
}

.wallet-toggle input:checked + .wallet-toggle-slider::after {
    transform: translateX(-20px);
}

.wallet-toggle-text {
    font-size: 0.88rem;
    font-weight: 700;
    color: #4a4a4a;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wallet-toggle-text small {
    color: #888888;
}

/* ── Summary & Totals ── */
.cart-summary__rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cart-summary__row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem !important;
    padding: 10px 0 !important;
    border-bottom: 1px solid #f2f2f2 !important;
    color: #555555 !important;
}

.cart-summary__row strong {
    color: #212529 !important;
    font-family: 'Outfit', sans-serif !important;
}

.cart-summary__row:last-child {
    border-bottom: none !important;
    padding-top: 16px !important;
    margin-top: 4px !important;
    border-top: 1px solid #e6e6e6 !important;
}

.cart-line-total {
    font-size: 1.3rem !important;
    color: #197bbd !important;
    font-weight: 800 !important;
}

.discount-row {
    background: #e8f8f2;
    border-radius: 5px;
    padding: 8px 12px !important;
    border-bottom: none !important;
}

.cashback-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #e8f8f2;
    border-radius: 5px;
    font-size: 0.78rem;
    color: #10b981;
    font-weight: 600;
    margin-top: 16px;
}

.cart-summary__hint {
    font-size: 0.8rem;
    color: #777777;
    margin-top: 12px;
}

/* ── Submit Row ── */
.checkout-submit-row {
    margin-top: 24px !important;
    padding-top: 20px !important;
    border-top: 1px dashed #e6e6e6 !important;
}

.checkout-submit-row .btn-store {
    padding: 14px 28px !important;
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    background-color: #197bbd !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 5px !important;
    transition: background-color 0.2s !important;
    box-shadow: 0 2px 4px rgba(25, 123, 189, 0.2) !important;
}

.checkout-submit-row .btn-store:hover {
    background-color: #15669e !important;
}

.checkout-submit-row .small {
    font-size: 0.78rem;
    color: #777777;
    margin-top: 8px;
}

/* Desktop/Mobile Submit Button Visibility */
.mobile-submit-btn { display: none; }

@media (max-width: 991.98px) {
    .desktop-submit-btn { display: none !important; }
    .mobile-submit-btn { display: block !important; }
}

/* Force Select2 width constraints globally on checkout */
.select2,
.select2-container,
.select2-container--bootstrap-5 {
    width: 100% !important;
    max-width: 100% !important;
}

/* ── Mobile Optimization Queries ── */
@media (max-width: 767.98px) {
    .checkout-page {
        padding: 12px 0 32px !important;
    }
    
    .checkout-layout {
        gap: 16px !important;
    }

    .checkout-form-card,
    .order-summary-card {
        padding: 20px !important;
        border-radius: 8px !important;
    }

    .checkout-head {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
        margin: 4px 0 12px !important;
        text-align: right !important;
    }

    .checkout-head-actions {
        order: -1 !important;
        display: flex !important;
        justify-content: flex-start !important;
    }
    
    .checkout-head-actions .btn-store {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }

    .checkout-title {
        font-size: 1.35rem !important;
        font-weight: 800 !important;
        line-height: 1.2 !important;
    }

    /* Swipeable Breadcrumbs for Mobile */
    .store-breadcrumb {
        font-size: 0.76rem !important;
        padding: 6px 0 !important;
        margin-bottom: 2px !important;
        white-space: nowrap !important;
        overflow-x: auto !important;
        scrollbar-width: none !important;
        display: flex !important;
        gap: 6px !important;
        align-items: center !important;
    }
    
    .store-breadcrumb::-webkit-scrollbar {
        display: none !important;
    }

    /* Reduce divider margin on mobile */
    .checkout-page .divider {
        margin: 12px 0 !important;
    }

    /* Reduce spacing around customer info headers */
    .checkout-section-head {
        margin-bottom: 12px !important;
    }
    
    .checkout-section-head p {
        margin-bottom: 8px !important;
    }

    .checkout-grid {
        gap: 12px !important;
        margin-bottom: 16px !important;
    }

    .shopify-payment-box {
        margin: 12px 0 16px !important;
    }

    .shopify-payment-row {
        padding: 14px 16px !important;
    }
    
    .shopify-payment-name {
        font-size: 0.88rem !important;
    }
}

/* Select2 Beautiful Overrides for Checkout Page - Styled like Premium Shopify Theme */
.checkout-field .select2-container--bootstrap-5 {
    margin-top: 4px;
    display: block;
}
.checkout-field .select2-container--bootstrap-5 .select2-selection {
    background-color: #ffffff !important;
    border: 1px solid #d9d9d9 !important;
    border-radius: 5px !important;
    height: 46px !important;
    padding: 6px 14px !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
    font-size: 0.9rem !important;
    display: flex;
    align-items: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}
.checkout-field .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: #333333 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    line-height: 1.5 !important;
    text-align: right;
}
.checkout-field .select2-container--bootstrap-5.select2-container--focus .select2-selection,
.checkout-field .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: #197bbd !important;
    box-shadow: 0 0 0 1px #197bbd !important;
}
.select2-dropdown {
    background-color: #ffffff !important;
    border: 1px solid #d9d9d9 !important;
    border-radius: 5px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1) !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
    font-size: 0.9rem !important;
    z-index: 9999;
}
.select2-search__field {
    background-color: #f8f9fa !important;
    color: #333333 !important;
    border: 1px solid #d9d9d9 !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
}
.select2-search__field:focus {
    border-color: #197bbd !important;
    outline: none !important;
    box-shadow: 0 0 0 1px #197bbd !important;
}
.select2-results__option--highlighted {
    background-color: #197bbd !important;
    color: #ffffff !important;
}
.select2-results__option {
    color: #333333 !important;
    padding: 8px 14px !important;
    text-align: right;
}

/* Hide Sidebar Cart and overlay completely on Checkout page to prevent mobile overflow */
.cart-sidebar,
.cart-overlay,
#cartSidebar,
#cartOverlay {
    display: none !important;
    visibility: hidden !important;
    width: 0 !important;
    height: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ── Shopify-Style Checkout Summary Products List ── */
.checkout-summary-products {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e6e6e6;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 240px;
    overflow-y: auto;
    padding-right: 2px;
}

/* Simple scrollbar styling */
.checkout-summary-products::-webkit-scrollbar {
    width: 6px;
}
.checkout-summary-products::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}
.checkout-summary-products::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}
.checkout-summary-products::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.summary-product-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.summary-product-media {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.summary-product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e6e6e6;
    background-color: #fafafa;
}

.summary-product-img--placeholder {
    width: 100%;
    height: 100%;
    border: 1px dashed #dcdcdc;
    border-radius: 8px;
    background-color: #f5f5f5;
}

.summary-product-qty-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 20px;
    height: 20px;
    background-color: rgba(114, 114, 114, 0.9);
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.summary-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    text-align: right; /* RTL align */
}

.summary-product-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: #333333;
    line-height: 1.3;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.summary-product-meta {
    font-size: 0.78rem;
    color: #777777;
}

.summary-product-total {
    font-size: 0.88rem;
    font-weight: 700;
    color: #333333;
    flex-shrink: 0;
    font-family: 'Outfit', 'Cairo', sans-serif;
}

/* ============================================================
   SONIC STOREFRONT — Form Validation Styles & Viewport Shift Fix
   ============================================================ */

/* Red validation borders on inputs/textareas/selects */
.checkout-field .store-input.is-invalid,
.checkout-field .store-textarea.is-invalid,
.checkout-field .lp-input.is-invalid,
.checkout-field .lp-textarea.is-invalid {
    border-color: #e74c3c !important;
    background-color: #fffcfc !important;
    box-shadow: 0 0 0 1px #e74c3c !important;
}

/* Color Select2 border red when invalid */
.checkout-field select.is-invalid + .select2-container--bootstrap-5 .select2-selection {
    border-color: #e74c3c !important;
    background-color: #fffcfc !important;
    box-shadow: 0 0 0 1px #e74c3c !important;
}

/* Beautiful custom validation error message */
.checkout-error-msg {
    color: #e74c3c !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    margin-top: 6px !important;
    display: none;
    align-items: center;
    gap: 6px;
    font-family: 'Tajawal', 'Cairo', sans-serif !important;
    animation: fieldReveal 0.25s ease-out forwards;
}

.checkout-error-msg.show {
    display: flex !important;
}

/* Double-shield: Force Select2 hidden select to center of its container to prevent horizontal shifting */
.select2-hidden-accessible {
    left: auto !important;
    right: 50% !important;
    top: 50% !important;
    transform: translate(50%, -50%) !important;
}

