/* Checkboxes and switches: ONE shared style for every customer page (user layout and sign-in layout).
 *
 * Why this file exists: AppKit's style.css sets "-webkit-appearance: none !important" on input:hover, input:focus and input:active
 * (style.css, the "input:hover, input:focus, input:active ..." rule). A native checkbox that loses its appearance draws nothing, so
 * every click (which is hover + focus + active) made the box disappear. The box is drawn here, by us, so no state can remove it.
 * Also fixed: the "outline: 0 !important" on every input removed the keyboard focus ring, the dark theme's transparent !important
 * background removed the checked fill, and the AppKit switch is display:none, so the keyboard could not reach it.
 *
 * Colours: the accessible brand text colour (--brand-accent: 4.5:1 on the page, lightened in dark mode) for checked and for the focus
 * ring, --text-muted for the unchecked border (3:1 or more in light and dark). Fallbacks keep the sign-in page (no dashboard tokens) working.
 * Tap target: the box is 22px; an invisible ::before makes the pressable area 44px. A label around or next to it toggles it as before.
 */

/* ---------- Checkbox ---------- */
body input[type="checkbox"]:not(.ios-input) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    position: relative;
    display: inline-block;
    flex: none;
    float: none;
    width: 22px;
    height: 22px;
    margin: 0;
    padding: 0;
    border: 2px solid var(--text-muted, #5B6472) !important;
    border-radius: 6px;
    background-color: transparent !important;
    background-image: none !important;
    vertical-align: middle;
    cursor: pointer;
}

/* the pressable area, 44 x 44 */
body input[type="checkbox"]:not(.ios-input)::before {
    content: "";
    position: absolute;
    inset: -11px;
}

/* the tick */
body input[type="checkbox"]:not(.ios-input)::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid #FFFFFF;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
    opacity: 0;
}

body input[type="checkbox"]:not(.ios-input):checked {
    background-color: var(--brand-accent, var(--brand-primary, #314EDB)) !important;
    border-color: var(--brand-accent, var(--brand-primary, #314EDB)) !important;
}

body input[type="checkbox"]:not(.ios-input):checked::after {
    opacity: 1;
}

/* in dark mode the accent is a light colour: the tick turns dark */
.theme-dark input[type="checkbox"]:not(.ios-input):checked::after {
    border-color: #0F1117;
}

/* style.css:1038, :1046 and :6709 recolour the border of a FOCUSED input with !important (specificity 0,4,1): the box keeps its own border while focused */
html body input[type="checkbox"]:not(.ios-input):not(:disabled):focus {
    border-color: var(--text-muted, #5B6472) !important;
}

html body input[type="checkbox"]:not(.ios-input):not(:disabled):checked:focus {
    border-color: var(--brand-accent, var(--brand-primary, #314EDB)) !important;
}

body input[type="checkbox"]:focus-visible {
    outline: 3px solid var(--brand-accent, var(--brand-primary, #314EDB)) !important;
    outline-offset: 2px;
}

.theme-dark input[type="checkbox"]:focus-visible {
    outline-color: #FFFFFF !important;
}

body input[type="checkbox"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* sign-in "Remember me": the label is a 44px target too */
.auth-options .form-check-label {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    cursor: pointer;
}

/* ---------- AppKit switch (the same checkbox, drawn by the label) ---------- */
/* AppKit hides the input with display:none: it cannot take focus, so the keyboard could not use the switch.
   Keep it, invisible, over the switch. */
.ios-switch input.ios-input {
    display: block !important;
    position: absolute;
    left: 10px;
    top: 0;
    width: 58px;
    height: 32px;
    margin: 0;
    opacity: 0;
    z-index: 7;
    transform: none !important; /* style.css:4349 throws the input 15000px off screen */
    cursor: pointer;
}

/* an OFF switch has a clearly visible track in light and dark mode (AppKit dark: the page colour with a 5% border) */
.ios-switch .ios-input:not(:checked) ~ .custom-control-label::before {
    border-color: var(--text-muted, #5B6472) !important;
}

.ios-switch .ios-input:focus-visible ~ .custom-control-label::before {
    outline: 3px solid var(--brand-accent, var(--brand-primary, #314EDB));
    outline-offset: 2px;
}

.theme-dark .ios-switch .ios-input:focus-visible ~ .custom-control-label::before {
    outline-color: #FFFFFF;
}
