/**
 * HM Herbs / Business One — red (off) / green (on) choice controls.
 * Native checkboxes & radios are enhanced by js/hm-choice-toggles.js.
 */
:root {
    --hm-choice-off: #dc2626;
    --hm-choice-off-bg: rgba(220, 38, 38, 0.08);
    --hm-choice-on: #10b981;
    --hm-choice-on-dark: #059669;
    --hm-choice-on-bg: rgba(16, 185, 129, 0.12);
    --hm-choice-knob: #ffffff;
    --hm-choice-shadow: 0 2px 6px rgba(15, 23, 42, 0.18);
}

/* Checkbox rows — switch pill + label text */
.hm-choice-row {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    line-height: 1.45;
}

.hm-choice-row--sm { gap: 0.6rem; }
.hm-choice-row--lg { gap: 0.85rem; align-items: center; }

.hm-choice-toggle {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
}

.hm-choice-input {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.hm-choice-pill {
    position: relative;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--hm-choice-off) 0%, #b91c1c 100%);
    border: 2px solid #991b1b;
    box-shadow: var(--hm-choice-shadow);
    transition: background 0.2s ease, border-color 0.2s ease, width 0.2s ease;
    cursor: pointer;
    pointer-events: none;
}

.hm-choice-row--sm .hm-choice-pill {
    width: 2.85rem;
    height: 1.55rem;
    padding: 0 0.2rem;
}

.hm-choice-row--md .hm-choice-pill {
    width: 3.35rem;
    height: 1.75rem;
    padding: 0 0.22rem;
}

.hm-choice-row--lg .hm-choice-pill {
    width: 4.5rem;
    height: 2rem;
    padding: 0 0.35rem;
    justify-content: center;
    gap: 0.15rem;
}

.hm-choice-knob {
    position: absolute;
    top: 50%;
    left: 0.18rem;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 50%;
    background: var(--hm-choice-knob);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
    transform: translateY(-50%);
    transition: left 0.2s ease, width 0.2s ease, height 0.2s ease;
    pointer-events: none;
}

.hm-choice-row--md .hm-choice-knob {
    width: 1.2rem;
    height: 1.2rem;
    left: 0.2rem;
}

.hm-choice-row--lg .hm-choice-knob {
    width: 1.4rem;
    height: 1.4rem;
    left: 0.22rem;
}

.hm-choice-state {
    font-size: 0.62rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1;
    pointer-events: none;
    user-select: none;
}

.hm-choice-row--lg .hm-choice-state { font-size: 0.68rem; }

.hm-choice-state-on { display: none; margin-left: auto; padding-right: 0.15rem; }
.hm-choice-state-off { margin-left: auto; padding-right: 0.1rem; }

.hm-choice-row--sm .hm-choice-state,
.hm-choice-row--md .hm-choice-state {
    display: none;
}

.hm-choice-row:has(.hm-choice-input:checked) .hm-choice-pill {
    background: linear-gradient(180deg, var(--hm-choice-on) 0%, var(--hm-choice-on-dark) 100%);
    border-color: var(--hm-choice-on-dark);
    justify-content: flex-end;
}

.hm-choice-row--lg:has(.hm-choice-input:checked) .hm-choice-pill {
    justify-content: center;
}

.hm-choice-row:has(.hm-choice-input:checked) .hm-choice-knob {
    left: calc(100% - 1.23rem);
}

.hm-choice-row--md:has(.hm-choice-input:checked) .hm-choice-knob {
    left: calc(100% - 1.4rem);
}

.hm-choice-row--lg:has(.hm-choice-input:checked) .hm-choice-knob {
    left: calc(100% - 1.62rem);
}

.hm-choice-row:has(.hm-choice-input:checked) .hm-choice-state-off { display: none; }
.hm-choice-row--lg:has(.hm-choice-input:checked) .hm-choice-state-on { display: inline; }
.hm-choice-row--lg:has(.hm-choice-input:checked) .hm-choice-state-off { display: none; }

.hm-choice-row:has(.hm-choice-input:focus-visible) .hm-choice-pill {
    outline: 3px solid rgba(16, 185, 129, 0.35);
    outline-offset: 2px;
}

.hm-choice-row:has(.hm-choice-input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.hm-choice-text {
    flex: 1;
    min-width: 0;
    color: inherit;
}

.hm-choice-text strong { color: inherit; }

/* Radio groups — segmented option cards */
.hm-choice-segmented {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.hm-choice-segment {
    position: relative;
    flex: 1 1 14rem;
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: 0;
    padding: 0.8rem 1rem;
    border: 2px solid var(--hm-choice-off);
    border-radius: 10px;
    background: var(--hm-choice-off-bg);
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
    line-height: 1.45;
}

.hm-choice-segment--lg {
    padding: 0.95rem 1.1rem;
}

.hm-choice-segment:has(.hm-choice-input:checked) {
    border-color: var(--hm-choice-on);
    background: var(--hm-choice-on-bg);
    box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2);
}

.hm-choice-segment:has(.hm-choice-input:focus-visible) {
    outline: 3px solid rgba(16, 185, 129, 0.3);
    outline-offset: 2px;
}

.hm-choice-segment .hm-choice-input {
    left: 0.75rem;
    top: 0.85rem;
}

.hm-choice-segment > span,
.hm-choice-segment > .hm-choice-text {
    flex: 1;
    min-width: 0;
}

/* GDPR / legacy toggle-switch — match site colors */
.toggle-switch {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.toggle-switch .toggle-slider {
    background: linear-gradient(180deg, var(--hm-choice-off) 0%, #b91c1c 100%);
    border: 1px solid #991b1b;
}

.toggle-switch input {
    position: absolute;
    left: 0;
    top: 0;
    width: 1px;
    height: 1px;
    margin: 0;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
}

.toggle-switch input:checked + .toggle-slider {
    background: linear-gradient(180deg, var(--hm-choice-on) 0%, var(--hm-choice-on-dark) 100%);
    border-color: var(--hm-choice-on-dark);
}

/* POS tokens */
.capacitor-android .hm-choice-pill,
#register-screen .hm-choice-pill {
    --hm-choice-on: #16a34a;
    --hm-choice-on-dark: #15803d;
}
