/* Controles nativos mantem valores, eventos e navegacao por teclado. */
:root input:is([type="checkbox"], [type="radio"]):where(:not([hidden], .controle-segmentado-carga-material input)) {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    display: inline-grid;
    place-content: center;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    min-width: 18px;
    min-height: 18px;
    max-width: 18px;
    max-height: 18px;
    margin: 0;
    padding: 0;
    vertical-align: -3px;
    border: 1px solid var(--cor-texto-suave);
    border-radius: 5px;
    color: var(--cor-texto);
    background: var(--cor-superficie);
    box-shadow: inset 0 1px 2px rgba(var(--tom-sombra), .06);
    cursor: pointer;
    transition: background-color .14s ease, border-color .14s ease, box-shadow .14s ease;
}

:root input:is([type="checkbox"], [type="radio"])::before {
    content: "";
    width: 10px;
    height: 10px;
    background: var(--cor-acao-texto);
    clip-path: polygon(14% 44%, 0 59%, 41% 100%, 100% 18%, 84% 4%, 38% 66%);
    transform: scale(0);
    transition: transform .14s ease;
}

:root input[type="radio"] { border-radius: 50%; }
:root input[type="radio"]::before {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    clip-path: none;
}

:root input:is([type="checkbox"], [type="radio"]):checked,
:root input[type="checkbox"]:indeterminate {
    color: var(--cor-acao-texto);
    border-color: var(--cor-acao-fundo);
    background: var(--cor-acao-fundo);
    box-shadow: none;
}

:root input:is([type="checkbox"], [type="radio"]):checked::before,
:root input[type="checkbox"]:indeterminate::before { transform: scale(1); }

:root input[type="checkbox"]:indeterminate::before {
    height: 2px;
    border-radius: 1px;
    clip-path: none;
}

:root input:is([type="checkbox"], [type="radio"]):hover:not(:disabled) {
    border-color: var(--cor-acao-fundo);
    box-shadow: 0 0 0 3px var(--cor-destaque-suave);
}

:root input:is([type="checkbox"], [type="radio"], [type="range"], [type="file"]):focus-visible {
    outline: 2px solid var(--cor-acao-fundo);
    outline-offset: 3px;
}

:root input:is([type="checkbox"], [type="radio"], [type="range"], [type="file"]):disabled:where(:not(.controle-segmentado-carga-material input)) {
    opacity: .5;
    cursor: not-allowed;
}

:root input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    height: 24px;
    min-height: 24px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
}

/* Pseudo-elementos WebKit e Firefox precisam de regras separadas. */
:root input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: var(--cor-borda-ativa);
}
:root input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--cor-borda-ativa);
}
:root input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    margin-top: -7px;
    border: 2px solid var(--cor-superficie);
    border-radius: 50%;
    background: var(--cor-acao-fundo);
    box-shadow: 0 1px 4px rgba(var(--tom-sombra), .2);
}
:root input[type="range"]::-moz-range-thumb {
    box-sizing: border-box;
    width: 20px;
    height: 20px;
    border: 2px solid var(--cor-superficie);
    border-radius: 50%;
    background: var(--cor-acao-fundo);
    box-shadow: 0 1px 4px rgba(var(--tom-sombra), .2);
}

:root input[type="file"]::file-selector-button {
    min-height: 30px;
    margin-right: 10px;
    padding: 6px 10px;
    border: 1px solid var(--cor-borda-ativa);
    border-radius: 6px;
    color: var(--cor-texto);
    background: var(--cor-superficie-suave);
    font: inherit;
    cursor: pointer;
    transition: background-color .14s ease, border-color .14s ease;
}
:root input[type="file"]:not(:disabled)::file-selector-button:hover {
    border-color: var(--cor-acao-fundo);
    background: var(--cor-destaque-suave);
}
:root input[type="file"]:disabled::file-selector-button { cursor: not-allowed; }

:root input:is([type="date"], [type="datetime-local"], [type="time"])::-webkit-calendar-picker-indicator {
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
}
:root input:is([type="date"], [type="datetime-local"], [type="time"]):not(:disabled)::-webkit-calendar-picker-indicator:hover {
    background-color: var(--cor-destaque-suave);
}

@media (prefers-reduced-motion: reduce) {
    :root input:is([type="checkbox"], [type="radio"]),
    :root input:is([type="checkbox"], [type="radio"])::before,
    :root input[type="file"]::file-selector-button { transition: none; }
}

@media (forced-colors: active) {
    :root input:is([type="checkbox"], [type="radio"]) {
        appearance: auto;
        -webkit-appearance: auto;
        box-shadow: none;
    }
    :root input:is([type="checkbox"], [type="radio"])::before { content: none; }
    :root input:is([type="checkbox"], [type="radio"], [type="range"], [type="file"]):focus-visible { outline-color: Highlight; }
    :root input[type="range"]::-webkit-slider-thumb { background: ButtonText; border-color: Canvas; }
    :root input[type="range"]::-moz-range-thumb { background: ButtonText; border-color: Canvas; }
    :root input[type="range"]::-webkit-slider-runnable-track { background: GrayText; }
    :root input[type="range"]::-moz-range-track { background: GrayText; }
}
