
/* The form box. Customizer → CASABLANCA - Checkout Form → Form Style sets the
   --casablanca-checkout-* properties (inc/customizer/checkout-style.php);
   unset, each falls back to the literal this rule always had, so an untouched
   store is unchanged. box-sizing keeps a thicker border or larger padding
   inside the column instead of widening the page. The popup's on-page
   preselect state (cod-form-popup.css) strips the box with a more specific
   rule, so none of this reaches it. */
.casablanca-modular-checkout-wrapper {
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: var(--casablanca-checkout-border-width, 1px) solid var(--casablanca-checkout-border-color, var(--casablanca-brand, #531628));
    border-radius: var(--casablanca-checkout-radius, var(--casablanca-radius));
    padding: var(--casablanca-checkout-padding, 15px 15px 8px 15px);
    background: var(--casablanca-checkout-bg, #fff);
    box-shadow: var(--casablanca-checkout-shadow, none);
}

.casablanca-modular-checkout-wrapper .casablanca-checkout-header {
    text-align: start;
    margin-bottom: 12px;
}

.casablanca-modular-checkout-wrapper .casablanca-checkout-header h2 {
    color: var(--casablanca-brand, #531628);
    font-size: 1rem;
    font-weight: 800;
    margin: 0 0 2px 0;
    text-transform: uppercase;
}

.casablanca-modular-checkout-wrapper .casablanca-checkout-header p {
    color: #6B7280;
    font-size: 0.8rem;
    margin: 0;
}

.casablanca-modular-checkout-wrapper .casablanca-quick-checkout-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Input group, icon section, input and the confirm button are NOT defined
   here any more. They are the shared COD form component and live in
   assets/css/modules/cod-form.css, which the checkout page loads too so the
   two forms cannot drift apart. This sheet is a declared dependent of it
   (see inc/woocommerce/checkout/init.php), so it always loads second and can
   still override for the product page only.
   Product-page-only additions to those elements go below, scoped to
   .casablanca-modular-checkout-wrapper as usual. */

/* Spacing between customer fields. The form's flex `gap` is 8px and is
   shared with the offer rows, the quantity box and the summary, so the small
   amount a labelled field needs on top of it is added here rather than by
   widening that gap for every block in the form. 8 + 2 = 10px between
   fields — enough to separate one field's input from the next field's
   label, and no more. */
.casablanca-modular-checkout-wrapper .casablanca-cod-field {
    margin-bottom: 2px;
}

.casablanca-modular-checkout-wrapper .casablanca-flag-section {
    width: 95px;
    gap: 6px;
    padding: 0 8px;
}

.casablanca-modular-checkout-wrapper .casablanca-flag-section svg {
    stroke: none;
    fill: #c1272d;
    width: 18px;
    height: 12px;
}

.casablanca-modular-checkout-wrapper .casablanca-country-code {
    font-weight: 800;
    font-size: 0.9rem;
    color: #111827;
}

.casablanca-modular-checkout-wrapper .casablanca-quantity-selector-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fdfdfd;
    border: 1px solid #f0f0f0;
    border-radius: var(--casablanca-radius);
    padding: 10px 15px;
    margin-top: 2px;
}

.casablanca-modular-checkout-wrapper .casablanca-qty-label {
    font-weight: 800;
    font-size: 0.8rem;
    color: #111827;
    text-transform: uppercase;
}

.casablanca-modular-checkout-wrapper .casablanca-quantity-control {
    /* Three fixed tracks, [ − ][ n ][ + ]: no track is sized by its content,
       so the digit stays centred between two equal buttons at any width. */
    --casablanca-qty-btn-w: 32px;
    --casablanca-qty-num-w: 40px;
    display: grid;
    grid-template-columns: var(--casablanca-qty-btn-w) var(--casablanca-qty-num-w) var(--casablanca-qty-btn-w);
    align-items: stretch;
    flex: 0 0 auto;
    box-sizing: border-box;
    border: 1px solid #e5e7eb;
    border-radius: var(--casablanca-radius);
    background: #fff;
    height: 32px;
    overflow: hidden;
}

.casablanca-modular-checkout-wrapper .casablanca-qty-btn {
    width: 100%;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    line-height: 1;
    color: #111827;
    font-weight: 700;
}



.casablanca-modular-checkout-wrapper .casablanca-qty-input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 100%;
    border: none !important;
    border-inline-start: 1px solid #e5e7eb !important;
    border-inline-end: 1px solid #e5e7eb !important;
    border-radius: 0;
    text-align: center;
    font-weight: 800;
    font-size: 0.9rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: #111827;
    -webkit-text-fill-color: #111827;
    opacity: 1;
    background: #fff;
    padding: 0;
    margin: 0;
    /* The native spinner reserves room on the right and pushes the digit left. */
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: textfield;
}

.casablanca-modular-checkout-wrapper .casablanca-qty-input::-webkit-inner-spin-button,
.casablanca-modular-checkout-wrapper .casablanca-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

@media (max-width: 767px) {
    .casablanca-modular-checkout-wrapper .casablanca-quantity-control {
        --casablanca-qty-btn-w: 40px;
        --casablanca-qty-num-w: 44px;
        height: 38px;
    }
}

.casablanca-modular-checkout-wrapper .casablanca-product-variations-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 5px 0;
}

.casablanca-modular-checkout-wrapper .casablanca-variation-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.casablanca-modular-checkout-wrapper .casablanca-variation-header {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.casablanca-modular-checkout-wrapper .casablanca-variation-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #4b5563;
    text-transform: uppercase;
}

.casablanca-modular-checkout-wrapper .casablanca-selected-variation-name {
    font-size: 0.75rem;
    font-weight: 700;
    color: #111827;
}

.casablanca-modular-checkout-wrapper .casablanca-swatches-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.casablanca-modular-checkout-wrapper .casablanca-swatch-item {
    min-width: 38px;
    height: 38px;
    border: 1.5px solid #e5e7eb;
    border-radius: var(--casablanca-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: #fff;
    padding: 2.5px;
    position: relative;
    user-select: none;
}



.casablanca-modular-checkout-wrapper .casablanca-swatch-item.active {
    border-color: var(--casablanca-brand, #531628);
    box-shadow: 0 0 0 1px var(--casablanca-brand, #531628);
    background: #fff;
}

.casablanca-modular-checkout-wrapper .casablanca-swatch-item img,
.casablanca-modular-checkout-wrapper .casablanca-swatch-color {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--casablanca-radius);
}



.casablanca-modular-checkout-wrapper .casablanca-swatch-text {
    font-size: 0.75rem;
    font-weight: 800;
    color: #111827;
    padding: 0 12px;
    white-space: nowrap;
    height: 100%;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border-radius: var(--casablanca-radius);

}

.casablanca-modular-checkout-wrapper .casablanca-swatch-item.active .casablanca-swatch-text {
    background: rgba(var(--casablanca-brand-rgb, 94, 85, 143), 0.1);
    color: var(--casablanca-brand, #531628);
}

/*
 * Availability states, written by checkout/js/variations.js on every selection
 * change. They are two different things and read differently on purpose:
 *
 *   .is-out-of-stock  — a real variation the customer simply cannot have right
 *                       now. Struck through, still visible, still tells them
 *                       the colour exists.
 *   .is-unavailable   — no variation combines this value with what is already
 *                       selected. Dimmed and inert, because clicking it could
 *                       only ever produce an invalid selection.
 *
 * The rule below used to be written for a class named `out-of-stock` that
 * nothing ever applied — the old selector never disabled a swatch, so every
 * value looked orderable regardless of stock.
 */
.casablanca-modular-checkout-wrapper .casablanca-swatch-item.is-out-of-stock {
    opacity: 0.4;
    cursor: not-allowed;
    background: #f1f5f9;
    border-style: solid;
    border-color: #e2e8f0;
}

.casablanca-modular-checkout-wrapper .casablanca-swatch-item.is-out-of-stock::after {
    content: "";
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to top right, transparent calc(50% - 1px), #94a3b8 50%, transparent calc(50% + 1px));
    pointer-events: none;
}

.casablanca-modular-checkout-wrapper .casablanca-swatch-item.is-unavailable {
    opacity: 0.25;
    cursor: not-allowed;
    pointer-events: none;
    border-color: #e2e8f0;
}

/* A bundle row whose dropdowns resolve to nothing orderable. */
.casablanca-quantity-offer-item .casablanca-bundle-item-row.is-unavailable {
    outline: 1.5px solid #ef4444;
    outline-offset: 2px;
}

.casablanca-modular-checkout-wrapper .casablanca-order-summary-box {
    background: rgba(var(--casablanca-brand-rgb, 94, 85, 143), 0.04);
    border: 1px solid rgba(var(--casablanca-brand-rgb, 94, 85, 143), 0.1);
    border-radius: var(--casablanca-radius);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 2px;
}

.casablanca-modular-checkout-wrapper .casablanca-summary-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #4b5563;
    font-weight: 500;
}

/* Coupon discount. Same row geometry as the others (inherited from
   .casablanca-summary-row above); only the colour marks it as money coming off.
   Rendered by Checkout\summary_rows() in inc/woocommerce/checkout/totals.php,
   and absent entirely when there is no discount. */
.casablanca-modular-checkout-wrapper .casablanca-discount-row,
.casablanca-modular-checkout-wrapper .casablanca-discount-row span:last-child {
    color: #15803d;
    font-weight: 600;
}

.casablanca-modular-checkout-wrapper .casablanca-total-row {
    margin-top: 2px;
    padding-top: 6px;
    border-top: 1px solid rgba(var(--casablanca-brand-rgb, 94, 85, 143), 0.1);
    font-size: 0.95rem;
    font-weight: 800;
    color: #111827;
}

.casablanca-modular-checkout-wrapper .casablanca-total-row span:last-child {
    color: var(--casablanca-brand, #531628);
}

/* Confirm Button — base style lives in assets/css/base.css (button contract);
   size, the two-line content block and the loading spinner live in the shared
   assets/css/modules/cod-form.css. Only the out-of-stock state, which exists
   on the product page alone, is left here. */
.casablanca-modular-checkout-wrapper .casablanca-confirm-checkout-btn.is-out-of-stock {
    background-color: #9ca3af !important;
    /* keeps the contract's brand-tinted border from showing on a grey button */
    border-color: color-mix(in srgb, #9ca3af 70%, transparent) !important;
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none;
}

.casablanca-modular-checkout-wrapper .casablanca-form-message {
    font-size: 0.8rem;
    text-align: center;
    font-weight: 600;
}
.casablanca-modular-checkout-wrapper .casablanca-form-message:empty {
    display: none;
}
.casablanca-modular-checkout-wrapper .casablanca-form-message:not(:empty) {
    margin-top: 5px;
}
/* Errors only: the success state was removed with the message that used to
   print above the submit button on a completed order. */
.casablanca-modular-checkout-wrapper .casablanca-form-message.error { color: #dc2626; }

@media (min-width: 992px) {
    .casablanca-modular-checkout-wrapper .casablanca-checkout-header {
        text-align: start;
    }
}

@media (max-width: 767px) {
    .casablanca-modular-checkout-wrapper {
        padding: var(--casablanca-checkout-padding, 12px 10px);
    }

    .casablanca-checkout-header {
        margin-bottom: 12px;
    }

    .casablanca-checkout-header h2 {
        font-size: 13.5px !important;
        font-weight: 600 !important;
        letter-spacing: 0.3px;
        margin-bottom: 2px;
    }

    .casablanca-checkout-header p {
        font-size: 11.5px !important;
        line-height: 1.4;
    }

    /* Field height, label and button proportions: shared component, see
       assets/css/modules/cod-form.css. This extra bottom margin is not part
       of it — it stacks on the form's 8px flex gap for this form's own
       mobile rhythm, which is not the checkout page's.

       It is on .casablanca-cod-field, the wrapper that now holds the label AND
       the input box; putting it back on .casablanca-checkout-input-group would
       open a gap between a field's input and its own error message.

       Two rules that used to sit here are gone with the icon column:
       .casablanca-checkout-input and .casablanca-field-icon are classes this form has
       never rendered — they described an earlier markup and styled nothing. */
    .casablanca-modular-checkout-wrapper .casablanca-cod-field {
        margin-bottom: 0;
    }

    .casablanca-modular-checkout-wrapper .casablanca-quantity-box {
        margin: 10px 0;
    }

    .casablanca-modular-checkout-wrapper .casablanca-quantity-label {
        font-size: 12px !important;
        font-weight: 500;
    }

    .casablanca-modular-checkout-wrapper .casablanca-quantity-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 14px !important;
    }

    .casablanca-modular-checkout-wrapper .casablanca-quantity-input {
        width: 36px !important;
        height: 32px !important;
        font-size: 12.5px !important;
    }

    .casablanca-modular-checkout-wrapper .casablanca-summary-table {
        margin: 10px 0;
        font-size: 12px;
    }
}

/* ── "Ajouter au panier" ──────────────────────────────────────────────
   Customizer → CASABLANCA - Checkout Form → Show Add to Cart Button.
   The outline twin of the COD button: same height and radius, brand border
   and text, so the COD order stays the primary action. Deliberately not in
   base.css's .casablanca-btn contract, whose !important fill would paint it solid.
   Inside the form (inline mode) or beside the popup trigger (popup mode).
   Customizer → Checkout Form → Buttons → Add to Cart Button Style sets the
   --casablanca-atc-button-* properties; unset, each falls back to the value
   written here before those controls existed. */

.casablanca-atc-wrap {
    width: 100%;
    margin-top: 8px;
}

.casablanca-atc-btn {
    width: 100%;
    min-height: var(--casablanca-atc-button-height, 48px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    position: relative;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
    color: var(--casablanca-atc-button-color, var(--casablanca-brand));
    background: var(--casablanca-atc-button-bg, #fff);
    border: 1.5px solid var(--casablanca-atc-button-border, var(--casablanca-brand));
    border-radius: var(--casablanca-atc-button-radius, var(--theme-radius, var(--radius-md)));
    box-shadow: var(--casablanca-atc-button-shadow, none);
    cursor: pointer;
}

.casablanca-atc-btn:hover:not(:disabled) {
    background: var(--casablanca-atc-button-bg-hover, color-mix(in srgb, var(--casablanca-brand) 6%, #fff));
}

.casablanca-atc-btn:focus-visible {
    outline: 2px solid var(--casablanca-brand);
    outline-offset: 2px;
}

.casablanca-atc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.casablanca-atc-btn.is-loading {
    opacity: 1;
    pointer-events: none;
}

.casablanca-atc-btn.is-loading > * {
    visibility: hidden;
}

.casablanca-atc-btn.is-loading::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    top: calc(50% - 9px);
    inset-inline-start: calc(50% - 9px);
    border: 2.5px solid color-mix(in srgb, var(--casablanca-brand) 25%, transparent);
    border-top-color: var(--casablanca-brand);
    border-radius: 50%;
    animation: casablanca-spin 0.6s linear infinite;
}

.casablanca-atc-message {
    font-size: 0.8rem;
    line-height: 1.35;
    margin-top: 6px;
    text-align: center;
}

.casablanca-atc-message:empty {
    display: none;
}

.casablanca-atc-message.is-error {
    color: #dc2626;
}

/* ── "Commander via WhatsApp" ─────────────────────────────────────────
   Customizer → CASABLANCA - Checkout Form → Show WhatsApp Button.
   Same geometry as "Ajouter au panier", in WhatsApp's green with its logo.
   Customizer → … → WhatsApp Button Style sets --casablanca-whatsapp-button-*;
   unset, the border follows the background, as it always did.
   Scoped under the wrapper, which the form always sits in (on the page or in
   the popup). */

.casablanca-modular-checkout-wrapper .casablanca-wa-btn {
    width: 100%;
    min-height: var(--casablanca-whatsapp-button-height, 48px);
    margin-top: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 18px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    text-transform: uppercase;
    line-height: 1;
    color: var(--casablanca-whatsapp-button-color, #fff);
    background: var(--casablanca-whatsapp-button-bg, #25d366);
    border: 1.5px solid var(--casablanca-whatsapp-button-border, var(--casablanca-whatsapp-button-bg, #25d366));
    border-radius: var(--casablanca-whatsapp-button-radius, var(--theme-radius, var(--radius-md)));
    box-shadow: var(--casablanca-whatsapp-button-shadow, none);
    cursor: pointer;
}

.casablanca-modular-checkout-wrapper .casablanca-wa-btn:hover:not(:disabled) {
    background: var(--casablanca-whatsapp-button-bg-hover, #1ebe5b);
    border-color: var(--casablanca-whatsapp-button-border, var(--casablanca-whatsapp-button-bg-hover, #1ebe5b));
}

.casablanca-modular-checkout-wrapper .casablanca-wa-btn:focus-visible {
    outline: 2px solid #1ebe5b;
    outline-offset: 2px;
}

.casablanca-modular-checkout-wrapper .casablanca-wa-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.casablanca-modular-checkout-wrapper .casablanca-wa-btn svg {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    fill: currentColor;
}
