/* ==========================================================
   MUZN - form controls (checkbox, radio, dropdown, file upload)
   Shared by the storefront and the admin panel.
   Everything is driven by the theme variables, so it follows
   data-theme="light" / "dark" automatically.
   ========================================================== */
:root {
    --ctl-field: var(--bg);
    --ctl-line: var(--line, var(--border));
    --ctl-ring: color-mix(in srgb, var(--muted) 55%, transparent);
    --ctl-tint: color-mix(in srgb, var(--primary) 10%, transparent);
    --ctl-tint-strong: color-mix(in srgb, var(--primary) 16%, transparent);
    --ctl-pop: #ffffff;
    --ctl-pop-shadow: 0 18px 44px rgba(10, 11, 16, .16), 0 2px 8px rgba(10, 11, 16, .06);
}

[data-theme="dark"] {
    --ctl-pop: #14151d;
    --ctl-pop-shadow: 0 18px 44px rgba(0, 0, 0, .6), 0 2px 8px rgba(0, 0, 0, .4);
}

/* ---------- checkbox + radio ---------- */
/* :where() keeps specificity at zero so page styles can still override */
:where(input:is([type="checkbox"], [type="radio"]):not(.rate-input input, .pay-opt input)) {
    -webkit-appearance: none;
    appearance: none;
    display: inline-grid;
    place-content: center;
    flex: none;
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
    vertical-align: middle;
    background-color: var(--ctl-field);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0;
    border: 2px solid var(--ctl-ring);
    cursor: pointer;
    transition: background-color .18s, border-color .18s, box-shadow .18s, background-size .18s, transform .12s;
}

:where(input[type="checkbox"]:not(.rate-input input, .pay-opt input)) {
    border-radius: 6px;
}

:where(input[type="radio"]:not(.rate-input input, .pay-opt input)) {
    border-radius: 50%;
}

:where(input:is([type="checkbox"], [type="radio"]):not(.rate-input input, .pay-opt input)):hover:not(:disabled) {
    border-color: var(--primary);
}

:where(input:is([type="checkbox"], [type="radio"]):not(.rate-input input, .pay-opt input)):active:not(:disabled) {
    transform: scale(.9);
}

:where(input:is([type="checkbox"], [type="radio"]):not(.rate-input input, .pay-opt input)):focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

:where(input:is([type="checkbox"], [type="radio"]):not(.rate-input input, .pay-opt input)):disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* checkbox: tick */
:where(input[type="checkbox"]:not(.rate-input input, .pay-opt input)):checked {
    background-color: var(--primary);
    border-color: var(--primary);
    background-size: 14px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}

/* checkbox: "select all" in a partial state */
:where(input[type="checkbox"]:not(.rate-input input, .pay-opt input)):indeterminate {
    background-color: var(--primary);
    border-color: var(--primary);
    background-size: 12px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.6' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
}

/* radio: ring + dot */
:where(input[type="radio"]:not(.rate-input input, .pay-opt input)):checked {
    background-color: var(--primary);
    border-color: var(--primary);
    box-shadow: inset 0 0 0 3.5px var(--ctl-field);
}

/* label wrapper used next to a checkbox / radio */
.check {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    -webkit-tap-highlight-color: transparent;
}

/* ---------- text fields: one focus outline for the whole site ----------
   Same look as the dropdown button (.dd-btn): primary border + soft ring,
   no browser default outline. !important is intentional so it wins over the
   per-page rules (".filters input", ".mp-rej input", ".field input" ...). */
:where(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), textarea, select:not(.dd-native)) {
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}

:is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), textarea, select:not(.dd-native)):hover:not(:focus):not(:disabled):not([readonly]) {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--ctl-line)) !important;
}

:is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), textarea, select:not(.dd-native)):focus,
:is(input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"], [type="color"], [type="hidden"], [type="submit"], [type="button"], [type="reset"], [type="image"]), textarea, select:not(.dd-native)):focus-visible {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent) !important;
}

/* quantity stepper: the input has no border of its own, so the pill gets the ring */
.qty input:focus,
.qty input:focus-visible {
    box-shadow: none !important;
    border-color: transparent !important;
}

.qty:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

/* ---------- dropdown (replaces <select>) ---------- */
.dd {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
    --dd-h: 44px;
}

/* the real <select> stays in the DOM (form value, validation, change events) but is invisible */
.dd>select.dd-native {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

.dd-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    height: var(--dd-h);
    padding: 0 14px;
    font: inherit;
    color: var(--text);
    text-align: start;
    background: var(--dd-bg, var(--ctl-field));
    border: 1px solid var(--ctl-line);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}

.dd-btn:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--ctl-line));
}

.dd-btn:focus-visible,
.dd.open .dd-btn {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.dd-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.dd.is-invalid .dd-btn {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .15);
}

.dd-val {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dd.is-placeholder .dd-val {
    color: var(--muted);
}

.dd-chev {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--muted);
    transition: transform .2s, color .15s;
}

.dd.open .dd-chev {
    transform: rotate(180deg);
    color: var(--primary);
}

/* list panel: moved to <body> while open so no parent can clip it */
.dd-list {
    position: fixed;
    z-index: 10000;
    margin: 0;
    padding: 6px;
    list-style: none;
    overflow-y: auto;
    overscroll-behavior: contain;
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.5;
    color: var(--text);
    background: var(--ctl-pop);
    border: 1px solid var(--ctl-line);
    border-radius: 12px;
    box-shadow: var(--ctl-pop-shadow);
    transform-origin: top center;
    animation: dd-in .14s ease-out;
    scrollbar-width: thin;
    scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent;
}

.dd-list.dd-up {
    transform-origin: bottom center;
}

@keyframes dd-in {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(.98);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.dd-opt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color .1s;
}

.dd-opt+.dd-opt {
    margin-top: 2px;
}

.dd-opt.is-active {
    background: var(--ctl-tint);
}

.dd-opt[aria-selected="true"] {
    color: var(--primary);
    font-weight: 700;
    background: var(--ctl-tint-strong);
}

.dd-opt.is-placeholder {
    color: var(--muted);
}

.dd-opt[aria-disabled="true"] {
    opacity: .4;
    cursor: not-allowed;
}

.dd-opt .dd-tick {
    flex: none;
    width: 16px;
    height: 16px;
    opacity: 0;
    color: var(--primary);
}

.dd-opt[aria-selected="true"] .dd-tick {
    opacity: 1;
}

.dd-group {
    padding: 8px 12px 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}

.dd-group:not(:first-child) {
    margin-top: 4px;
    border-top: 1px solid var(--ctl-line);
}

@media (max-width: 640px) {
    .dd-opt {
        padding: 11px 12px;
    }
}

@media (prefers-reduced-motion: reduce) {

    .dd-list,
    .dd-chev,
    :where(input:is([type="checkbox"], [type="radio"])) {
        animation: none;
        transition: none;
    }
}

/* ==========================================================
   File upload (drop zone) - built by controls.js from <input type="file">
   ========================================================== */
.up {
    position: relative;
    display: block;
    width: 100%;
    min-width: 0;
}

/* the real input stays in the DOM (form value, `required`, events) but is invisible */
.up>input[type="file"].up-native {
    position: absolute;
    inset-inline: 50%;
    bottom: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.up .up-zone {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin: 0 !important;
    padding: 14px 16px;
    font-weight: 400 !important;
    color: var(--text);
    cursor: pointer;
    background: var(--ctl-field);
    border: 1px dashed var(--ctl-ring);
    border-radius: 12px;
    transition: border-color .15s, background-color .15s;
}

.up-zone:hover,
.up.is-drag .up-zone {
    border-color: var(--primary);
    background: var(--ctl-tint);
}

.up.is-focus .up-zone {
    border-style: solid;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}

.up.has-error .up-zone {
    border-color: #ef4444;
}

.up-ico {
    flex: none;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: var(--primary);
    background: var(--ctl-tint);
    border-radius: 10px;
}

.up-ico svg {
    width: 20px;
    height: 20px;
}

.up-txt {
    display: grid;
    min-width: 0;
    line-height: 1.45;
}

.up-txt b {
    font-size: 14.5px;
    font-weight: 600;
}

.up-txt span {
    color: var(--muted);
    font-size: 12.5px;
}

/* selected file */
.up-file {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--ctl-field);
    border: 1px solid var(--ctl-line);
    border-radius: 12px;
}

.up[data-state="filled"] .up-zone {
    display: none;
}

.up[data-state="filled"] .up-file {
    display: flex;
}

.up.is-drag .up-file {
    border-color: var(--primary);
}

.up-thumb {
    flex: none;
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    overflow: hidden;
    color: var(--primary);
    background: var(--ctl-tint);
    border-radius: 8px;
}

.up-thumb svg {
    width: 22px;
    height: 22px;
}

.up-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.up-info {
    display: grid;
    flex: 1;
    min-width: 0;
}

.up-name {
    overflow: hidden;
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.up-size {
    color: var(--muted);
    font-size: 12.5px;
    text-align: start;
}

.up-act {
    display: flex;
    flex: none;
}

.up-btn {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    transition: color .15s, background-color .15s;
}

.up-btn svg {
    width: 17px;
    height: 17px;
}

.up-btn:hover,
.up-btn:focus-visible {
    outline: none;
    color: #ef4444;
    background: rgba(239, 68, 68, .1);
}

.up-err {
    margin: 6px 2px 0;
    color: #ef4444;
    font-size: 13px;
}

@media (prefers-reduced-motion: reduce) {

    .up-zone,
    .up-btn {
        transition: none;
    }
}
/* ---------- browser autofill: keep the site's field look ----------
   Chrome / Edge / Safari paint autofilled fields blue-gray and ignore "background". The only reliable override is a huge inset
   shadow in the field's own colour (+ the text colour). Works in light and dark mode because it uses the theme variables.
   The focus ring is repeated here because the shadow below would otherwise replace it. */
:is(input, textarea, select):-webkit-autofill,
:is(input, textarea, select):-webkit-autofill:hover,
:is(input, textarea, select):-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px var(--card, var(--surface, var(--bg))) inset !important;
    box-shadow: 0 0 0 1000px var(--card, var(--surface, var(--bg))) inset !important;
    -webkit-text-fill-color: var(--text) !important;
    caret-color: var(--text);
    background-clip: padding-box;
    transition: background-color 600000s 0s, color 600000s 0s;   /* belt and braces for older Chrome */
}

:is(input, textarea, select):-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent), 0 0 0 1000px var(--card, var(--surface, var(--bg))) inset !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent), 0 0 0 1000px var(--card, var(--surface, var(--bg))) inset !important;
    -webkit-text-fill-color: var(--text) !important;
}

:is(input, textarea, select):autofill {
    box-shadow: 0 0 0 1000px var(--card, var(--surface, var(--bg))) inset !important;
    -webkit-text-fill-color: var(--text) !important;
}
