/* p237: shared UI fixes for the whole site.
   1. One checkbox / radio style everywhere (dark and light). Hidden "switch" checkboxes (sr-only / peer) are left alone.
   2. Option rows (label + checkbox) in dialogs look like tappable cards.
   3. Rows of chips / tabs that scroll sideways get arrows and edge fades on desktop (zk-ui.js adds the classes). */

/* 1. checkboxes and radios */
input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]) {
    -webkit-appearance: none; appearance: none;
    flex: none; display: inline-grid; place-content: center;
    width: 1.2rem; height: 1.2rem; margin: 0;
    border: 1.5px solid rgba(255, 255, 255, .32); border-radius: .4rem;
    background: rgba(255, 255, 255, .04); background-image: none;
    color: #fff; cursor: pointer; vertical-align: middle;
    box-shadow: none;
    transition: background-color .15s, border-color .15s, box-shadow .15s, transform .1s;
}
input[type="radio"]:not(.sr-only):not(.peer):not(.zk-raw):not([hidden]) { border-radius: 999px; }
input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):hover { border-color: #a78bfa; }
input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):active { transform: scale(.92); }
input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):focus { outline: none; box-shadow: none; }
input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
input[type="checkbox"]:not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):checked {
    border-color: transparent;
    background: linear-gradient(135deg, #7c5cff, #06b6d4) center / 100% 100% no-repeat;
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M3.5 8.5l3 3 6-7'/%3e%3c/svg%3e"), linear-gradient(135deg, #7c5cff, #06b6d4);
    background-size: 78% 78%, 100% 100%; background-position: center; background-repeat: no-repeat;
}
input[type="checkbox"]:not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):indeterminate {
    border-color: transparent;
    background: linear-gradient(135deg, #7c5cff, #06b6d4);
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M4 8h8' stroke='white' stroke-width='2.2' stroke-linecap='round'/%3e%3c/svg%3e"), linear-gradient(135deg, #7c5cff, #06b6d4);
    background-size: 78% 78%, 100% 100%; background-position: center; background-repeat: no-repeat;
}
input[type="radio"]:not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):checked {
    border-color: #7c5cff; background: radial-gradient(circle, #7c5cff 0 42%, transparent 46%);
}
input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):disabled { opacity: .45; cursor: not-allowed; }
label:has(> input:is([type="checkbox"], [type="radio"]):not(:disabled)) { cursor: pointer; }

html.light input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]) { border-color: #a1a1aa; background-color: #fff; }
html.light input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):hover { border-color: #7c5cff; }
html.light input[type="checkbox"]:not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):is(:checked, :indeterminate) { border-color: transparent; }
html.light input[type="radio"]:not(.sr-only):not(.peer):not(.zk-raw):not([hidden]):checked { border-color: #7c5cff; background: radial-gradient(circle, #7c5cff 0 42%, #fff 46%); }

/* 2. option rows in dialogs and settings: a card you can tap anywhere */
:is(.cp-check, .zk-opt) {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; background: rgba(255, 255, 255, .03);
    font-size: 14px; line-height: 1.35; cursor: pointer; transition: border-color .15s, background-color .15s;
}
:is(.cp-check, .zk-opt):hover { border-color: rgba(167, 139, 250, .45); background: rgba(124, 92, 255, .06); }
:is(.cp-check, .zk-opt):has(input:checked) { border-color: rgba(124, 92, 255, .55); background: rgba(124, 92, 255, .1); }
:is(.cp-check, .zk-opt):has(input:focus-visible) { outline: 2px solid #22d3ee; outline-offset: 2px; }
:is(.cp-check, .zk-opt) > input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer):not(.zk-raw):not([hidden]) { order: 2; margin-left: auto; }
html.light :is(.cp-check, .zk-opt) { border-color: #e4e4e7; background: #fff; }
html.light :is(.cp-check, .zk-opt):hover { border-color: #c4b5fd; background: #faf8ff; }
html.light :is(.cp-check, .zk-opt):has(input:checked) { border-color: #a78bfa; background: #f5f3ff; }

/* 3. sideways rows: arrows with a fade (desktop only; zk-ui.js adds them only while the row overflows) */
.zk-hs { scroll-behavior: smooth; }
.zk-hs.is-drag { scroll-behavior: auto; cursor: grabbing; user-select: none; }
.zk-hs.is-drag * { pointer-events: none; }
.zk-hs-edge { position: sticky; z-index: 6; flex: none; display: none; align-self: stretch; width: 0; min-width: 0; padding: 0; overflow: visible; }
.zk-hs-edge.is-l { left: 0; order: -9999; }
.zk-hs-edge.is-r { right: 0; order: 9999; }
.zk-hs-edge.is-on { display: block; }
.zk-hs-edge > span { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; width: 56px; pointer-events: none; }
.zk-hs-edge.is-l > span { left: 0; justify-content: flex-start; background: linear-gradient(to right, var(--zk-hs-bg, #0b0b0f) 40%, transparent); }
.zk-hs-edge.is-r > span { right: 0; justify-content: flex-end; background: linear-gradient(to left, var(--zk-hs-bg, #0b0b0f) 40%, transparent); }
.zk-hs-btn {
    pointer-events: auto; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, .14); background: #1c1c22; color: #e4e4e7;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35); cursor: pointer; transition: background-color .15s, transform .1s;
}
.zk-hs-btn:hover { background: #2a2a33; }
.zk-hs-btn:active { transform: scale(.94); }
.zk-hs-btn:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }
.zk-hs-btn svg { width: 16px; height: 16px; }
html.light .zk-hs-btn { background: #fff; color: #27272a; border-color: #e4e4e7; box-shadow: 0 4px 14px rgba(15, 23, 42, .12); }
html.light .zk-hs-btn:hover { background: #f4f4f5; }

/* option rows inside dialogs and sheets get the same card look (chips and inline rows are left as they are) */
:is([role="dialog"], .cp-sheet, .zk-sheet, .zinkly-modal) label:has(> input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer)):not(.cp-check):not(.zk-opt):not(.inline-flex):not(.rounded-full):not([class*="rounded-full"]):not(.zk-ie-chip):not(.zk-raw) {
    display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; background: rgba(255, 255, 255, .03);
    transition: border-color .15s, background-color .15s;
}
:is([role="dialog"], .cp-sheet, .zk-sheet, .zinkly-modal) label:has(> input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer)):not(.cp-check):not(.zk-opt):not(.inline-flex):not(.rounded-full):not([class*="rounded-full"]):not(.zk-ie-chip):not(.zk-raw):hover { border-color: rgba(167, 139, 250, .45); background: rgba(124, 92, 255, .06); }
:is([role="dialog"], .cp-sheet, .zk-sheet, .zinkly-modal) label:has(> input:is([type="checkbox"], [type="radio"]):checked:not(.sr-only):not(.peer)):not(.cp-check):not(.zk-opt):not(.inline-flex):not(.rounded-full):not([class*="rounded-full"]):not(.zk-ie-chip):not(.zk-raw) { border-color: rgba(124, 92, 255, .55); background: rgba(124, 92, 255, .1); }
html.light :is([role="dialog"], .cp-sheet, .zk-sheet, .zinkly-modal) label:has(> input:is([type="checkbox"], [type="radio"]):not(.sr-only):not(.peer)):not(.cp-check):not(.zk-opt):not(.inline-flex):not(.rounded-full):not([class*="rounded-full"]):not(.zk-ie-chip):not(.zk-raw) { border-color: #e4e4e7; background: #fff; }
html.light :is([role="dialog"], .cp-sheet, .zk-sheet, .zinkly-modal) label:has(> input:is([type="checkbox"], [type="radio"]):checked:not(.sr-only):not(.peer)):not(.cp-check):not(.zk-opt):not(.inline-flex):not(.rounded-full):not([class*="rounded-full"]):not(.zk-ie-chip):not(.zk-raw) { border-color: #a78bfa; background: #f5f3ff; }

/* the floating bottom bar on phones covered the bottom of the Messages sheets (New channel, New space, ...) */
@media (max-width: 1023.98px) {
    html:has(.cp-modal:not([x-cloak]):not([style*="display: none"])) :is(.fixed.inset-x-0.bottom-0[class*="z-[60]"], nav.fixed.inset-x-0.z-40) { display: none !important; }
}

/* switch knobs: these Tailwind classes were missing from the prebuilt CSS, so knobs stayed on the left when ON */
.translate-x-1, .translate-x-5, .peer:checked ~ .peer-checked\:translate-x-5 {
    transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}
.translate-x-1 { --tw-translate-x: .25rem; }
.translate-x-5, .peer:checked ~ .peer-checked\:translate-x-5 { --tw-translate-x: 1.25rem; }
