/* ============================================================
   Mochello — WooCommerce
   Light / dark parity layer for the classic WooCommerce
   templates and for WooCommerce Blocks.

   WooCommerce paints a number of surfaces with hard-coded
   light colours — #fff panels, #2b2d2f text, white checkboxes
   — that never follow the theme. Everything that cannot be
   expressed with a design token is corrected here.

   Loaded after style.css so it can override both the theme
   and WooCommerce's own rules.

   Named mc-woocommerce.css so it is never confused with
   WooCommerce's own assets/css/woocommerce.css.
   ============================================================ */

/* ───────────────────────────────────────────────────────────
   1. Native form controls

   `color-scheme` (tokens.css) makes the browser paint
   checkboxes, radios and scrollbars with the dark palette
   instead of the OS default white; `accent-color` keeps the
   checked state in the brand colour.
   ─────────────────────────────────────────────────────────── */
.woocommerce input[type="checkbox"],
.woocommerce input[type="radio"],
.woocommerce .woocommerce-form__input-checkbox {
    accent-color: var(--accent);
}

/* ───────────────────────────────────────────────────────────
   2. Classic WooCommerce forms

   WooCommerce reads its field colours from the `--wc-form-*`
   variables (set in tokens.css) and falls back to #fff / #444
   when they are unset. These rules cover the fields that
   WooCommerce paints outside `.form-row`.
   ─────────────────────────────────────────────────────────── */
.woocommerce form .form-row .input-text,
.woocommerce form .form-row select,
.woocommerce .input-text,
.woocommerce input[type="text"],
.woocommerce input[type="email"],
.woocommerce input[type="tel"],
.woocommerce input[type="url"],
.woocommerce input[type="password"],
.woocommerce input[type="search"],
.woocommerce select,
.woocommerce textarea {
    color: var(--text-primary);
    background-color: var(--bg-base);
    border-color: var(--bg-muted);
}

.woocommerce form .form-row .input-text:focus,
.woocommerce form .form-row select:focus,
.woocommerce .input-text:focus,
.woocommerce select:focus,
.woocommerce textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

/* Account forms — the panel sits on a raised surface, so the
   fields use the page background to stay readable. */
.woocommerce form.woocommerce-form-login .input-text,
.woocommerce form.woocommerce-form-register .input-text,
.woocommerce form.woocommerce-form-lost-password .input-text {
    background-color: var(--bg-base);
    color: var(--text-primary);
    border-color: var(--bg-muted);
}

/* ───────────────────────────────────────────────────────────
   3. WooCommerce Blocks — select component

   WooCommerce 10.9 renamed the select component from
   `wc-block-components-select` to `wc-blocks-components-select`.
   Both namespaces are covered so the site keeps working on
   either WooCommerce version.

   WooCommerce paints the container #fff and the value text
   #2b2d2f, which is what left the country / state pickers
   white with an invisible label in dark mode.
   ─────────────────────────────────────────────────────────── */
.wc-blocks-components-select .wc-blocks-components-select__container,
.wc-block-components-select .wc-block-components-select__container {
    background: var(--bg-surface);
    border-radius: var(--radius-md);
}

.wc-blocks-components-select .wc-blocks-components-select__select,
.wc-block-components-select .wc-block-components-select__select {
    background: var(--bg-base) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--bg-muted) !important;
    border-radius: var(--radius-md) !important;
}

.wc-blocks-components-select .wc-blocks-components-select__label,
.wc-block-components-select .wc-block-components-select__label {
    color: var(--text-secondary) !important;
}

/* The chevron is an inline SVG that WooCommerce fills with
   #2b2d2f — invisible once the field turns dark. */
.wc-blocks-components-select .wc-blocks-components-select__container .wc-blocks-components-select__expand,
.wc-block-components-select .wc-block-components-select__container .wc-block-components-select__expand {
    fill: var(--text-secondary) !important;
}

/* ───────────────────────────────────────────────────────────
   4. WooCommerce Blocks — remaining hard-coded surfaces
   ─────────────────────────────────────────────────────────── */

/* Textarea — order notes and additional information */
.wc-block-components-textarea {
    background-color: var(--bg-base) !important;
    color: var(--text-primary) !important;
    border-color: var(--bg-muted) !important;
    border-radius: var(--radius-md) !important;
}
.wc-block-components-textarea:not(:placeholder-shown) {
    color: var(--text-primary) !important;
}
.wc-block-components-textarea:focus {
    background-color: var(--bg-base) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12) !important;
}

/* Checkbox — WooCommerce draws its own box, unchecked included */
.wc-block-components-checkbox .wc-block-components-checkbox__input[type="checkbox"] {
    background-color: var(--bg-surface) !important;
    border-color: var(--bg-muted) !important;
}
.wc-block-components-checkbox .wc-block-components-checkbox__input[type="checkbox"]:checked {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
}
.wc-block-components-checkbox .wc-block-components-checkbox__mark {
    fill: #ffffff;
}

/* Radio — same story, WooCommerce paints a white circle */
.wc-block-components-radio-control .wc-block-components-radio-control__input {
    background: var(--bg-surface) !important;
    border-color: var(--bg-muted) !important;
}
.wc-block-components-radio-control .wc-block-components-radio-control__input:checked {
    border-color: var(--accent) !important;
}
.wc-block-components-radio-control .wc-block-components-radio-control__input:checked::before {
    background: var(--accent) !important;
}

/* Error / success banner */
.wc-block-components-notice-banner {
    background-color: var(--bg-surface) !important;
    border-color: var(--bg-muted) !important;
    color: var(--text-primary) !important;
}
.wc-block-components-notice-banner__content {
    color: var(--text-primary) !important;
}

/* Address autocomplete dropdown */
.wc-block-components-address-autocomplete-suggestions {
    background: var(--bg-surface) !important;
    border-color: var(--bg-muted) !important;
}
.wc-block-components-address-autocomplete-suggestions .suggestions-list li {
    color: var(--text-primary) !important;
}

/* Payment gateway radio card */
.wc-block-gateway-container .wc-block-gateway-input {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary) !important;
}
.wc-block-gateway-container:focus {
    background-color: var(--bg-surface) !important;
}

/* Sale badges */
.wc-block-components-product-sale-badge,
.wc-block-grid__product-onsale {
    background: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--bg-muted) !important;
}

/* Removable chips (coupons, order notes) */
.wc-block-components-chip__remove {
    background: var(--bg-muted) !important;
}
.wc-block-components-chip__remove-icon {
    fill: var(--text-primary) !important;
}

/* Sticky "Proceed to checkout" bar on small screens */
.wc-block-cart__submit-container--sticky {
    background: var(--bg-surface) !important;
}

/* Skip link */
.screen-reader-text:focus {
    background-color: var(--bg-surface);
}

/* ───────────────────────────────────────────────────────────
   5. Shop sorting dropdown

   WooCommerce renders the sort control as
   `form.woocommerce-ordering` — the theme's own `.mc-ordering`
   wrapper is never used on the shop page. The arrow used to
   live on that unused wrapper, so the control had none.

   The arrow is drawn on the select itself (the form is a
   full-width block, so a pseudo-element would drift away
   from the control).
   ─────────────────────────────────────────────────────────── */
.woocommerce-ordering select,
form.woocommerce-ordering select.orderby {
    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='%236b6580' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 12px 12px;
    cursor: pointer;
}

[data-theme="dark"] .woocommerce-ordering select,
[data-theme="dark"] form.woocommerce-ordering select.orderby {
    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='%23a89fc0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
