/* ==========================================================================
   ui-controls.css — единый вид выпадашек и галочек. Шаблон из скилла ui-polish (эталон — IZI CRM, 15.11.2026).
   Подключать СРАЗУ ПОСЛЕ основного css проекта. В пару — templates/ui-select.js (рисованное меню).

   1. Закрытый <select>: без системного вида, шеврон Iconsax в 12px от правого края, padding-right 32px.
      Шеврон и отступ — с !important: свои классы селектов и shorthand `background:` иначе стирают шеврон.
   2. Открытое меню .uisel-* (рисует ui-select.js).
   3. Чекбоксы и радио — рисованные: галочка, точка, «частично», hover / focus / disabled.

   НАСТРОЙКА ПОД ПРОЕКТ:
   • Токены --ui-* ниже — подставить цвета проекта (var(--его-переменная), если есть).
   • Шеврон и галочка — data-URI: CSS-переменные внутри не работают. Открытый шеврон красится цветом
     акцента: заменить %233b64f4 на hex акцента проекта (# → %23). Серый закрытый трогать не нужно.
   • Тёмная тема: блок ниже срабатывает на [data-theme="dark"] и .dark — поправить под селектор проекта
     (или обернуть в @media (prefers-color-scheme: dark), если тема системная).
   • Скрытые input готовых тумблеров добавить в список исключений :where(...) — иначе они станут квадратиками.
   • Свой цвет галочки в разделе: --ui-accent на контейнере или элементе.
   ========================================================================== */

:root {
    /* travma 24.11.2026: синий акцент и строгие углы — значения из токенов style.css */
    --ui-accent: var(--primary, #1b5fa6);          /* акцент проекта */
    --ui-accent-soft: var(--primary-soft, #e6eff9); /* фон выбранного пункта */
    --ui-surface: #ffffff;         /* фон меню и чекбокса */
    --ui-text: var(--text, #12263f);
    --ui-muted: var(--muted, #44566e);
    --ui-faint: var(--faint, #5b6d85);
    --ui-border: var(--line, #d3dfeb);          /* рамка меню и голого селекта */
    --ui-border-soft: var(--line-soft, #e4ebf3); /* разделители внутри меню */
    --ui-hover: var(--surface-3, #f1f5fa);       /* подсветка пункта */
    --ui-cb-border: #9fb1c6;       /* рамка пустого чекбокса */
    --ui-cb-border-hover: #7189a6;
    --ui-radius: 2px;              /* меню, поле, чекбокс */
    --ui-menu-shadow: 0 0 0 1px rgba(13, 42, 76, .06), 0 12px 32px rgba(13, 42, 76, .18);
    --uisel-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95' stroke='%236b7280' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' stroke-miterlimit='10'/%3E%3C/svg%3E");
    --uisel-chev-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M19.92 15.05l-6.52-6.52c-.77-.77-2.03-.77-2.8 0L4.08 15.05' stroke='%231b5fa6' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' stroke-miterlimit='10'/%3E%3C/svg%3E");
    --uicb-tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='5 5 14 14' fill='none'%3E%3Cpath d='m7.75 12 2.83 2.83 5.67-5.66' stroke='%23fff' stroke-width='2.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    --uicb-dash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='5 5 14 14' fill='none'%3E%3Cpath d='M8.25 12h7.5' stroke='%23fff' stroke-width='2.3' stroke-linecap='round'/%3E%3C/svg%3E");
}
:root[data-theme="dark"], body[data-theme="dark"], .dark {
    --ui-accent: #6d8dff;
    --ui-accent-soft: #1f2a4a;
    --ui-surface: #171d29;
    --ui-text: #e8ecf3;
    --ui-muted: #8b95a8;
    --ui-faint: #5d677a;
    --ui-border: #2a3344;
    --ui-border-soft: #222a38;
    --ui-hover: #1f2735;
    --ui-cb-border: #5b6576;
    --ui-cb-border-hover: #8792a4;
    --ui-menu-shadow: 0 14px 38px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
    --uisel-chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M19.92 8.95l-6.52 6.52c-.77.77-2.03.77-2.8 0L4.08 8.95' stroke='%239ca3af' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' stroke-miterlimit='10'/%3E%3C/svg%3E");
    --uisel-chev-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M19.92 15.05l-6.52-6.52c-.77-.77-2.03-.77-2.8 0L4.08 15.05' stroke='%236d8dff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' stroke-miterlimit='10'/%3E%3C/svg%3E");
}

/* ---------------------------------------------------------------- 1. select */
/* Голый <select> без своих стилей проекта: аккуратная рамка и отступы (у селектов со своими классами — их вид) */
:where(select:not([multiple]):not([size])) {
    padding: 6px 10px;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background-color: var(--ui-surface);
    color: var(--ui-text);
    font-family: inherit;
    font-size: inherit;
    line-height: 1.35;
}
select:not([multiple]):not([size]):not([data-native]):not(.flatpickr-monthDropdown-months),
select[size="1"]:not([multiple]):not([data-native]),
select[size="0"]:not([multiple]):not([data-native]) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: var(--uisel-chev) !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px 12px !important;
    padding-right: 32px !important;
    text-overflow: ellipsis;
    cursor: pointer;
}
select[data-uisel-open]:not([multiple]):not([size]):not([data-native]):not(.flatpickr-monthDropdown-months),
select[data-uisel-open][size="1"]:not([multiple]):not([data-native]) { background-image: var(--uisel-chev-open) !important; }
select:disabled { cursor: default; }
select::-ms-expand { display: none; }

/* -------------------------------------------------------- 2. меню ui-select.js */
.uisel-menu {
    position: fixed; top: 0; left: 0; z-index: 2147483000; box-sizing: border-box;
    padding: 4px; border: 1px solid var(--ui-border); border-radius: var(--ui-radius);
    background: var(--ui-surface); color: var(--ui-text);
    font-family: inherit; font-size: 13px; line-height: 1.35; text-align: left;
    box-shadow: var(--ui-menu-shadow);
    animation: uisel-pop .14s cubic-bezier(.22, .9, .35, 1.15); transform-origin: top left;
    -webkit-user-select: none; user-select: none;
}
.uisel-menu.up { transform-origin: bottom left; animation-name: uisel-pop-up; }
@keyframes uisel-pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes uisel-pop-up { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .uisel-menu { animation: none; } }
.uisel-list { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.uisel-item {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 7px 10px; border-radius: 0; cursor: pointer; white-space: nowrap; color: var(--ui-text);
}
.uisel-item + .uisel-item { margin-top: 1px; }
.uisel-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.uisel-text.empty { color: var(--ui-faint); }
.uisel-item.hl { background: var(--ui-hover); }
.uisel-item.sel { background: var(--ui-accent-soft); color: var(--ui-accent); font-weight: 600; }
.uisel-item.sel.hl { background: color-mix(in srgb, var(--ui-accent) 13%, var(--ui-surface)); }
.uisel-item.dis { opacity: .45; cursor: default; }
.uisel-item.dis.hl { background: none; }
.uisel-item.in-group { padding-left: 16px; }
.uisel-tick { display: inline-flex; flex: none; margin-right: -2px; color: var(--ui-accent); }
.uisel-group { padding: 8px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ui-faint); }
.uisel-group:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--ui-border-soft); padding-top: 10px; }
.uisel-empty { padding: 10px 12px; color: var(--ui-muted); }
.uisel-search {
    display: flex; align-items: center; gap: 8px; min-height: 30px; margin: 0 0 6px; padding: 2px 8px 7px;
    border-bottom: 1px solid var(--ui-border-soft); color: var(--ui-faint);
}
.uisel-field { display: flex; align-items: center; flex: 1; min-width: 0; overflow: hidden; white-space: pre; }
.uisel-q { color: var(--ui-text); overflow: hidden; text-overflow: ellipsis; }
.uisel-caret { flex: none; width: 1.5px; height: 15px; margin: 0 1px; background: var(--ui-accent); animation: uisel-blink 1.05s steps(1) infinite; }
.uisel-ph { color: var(--ui-faint); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
.uisel-menu.has-q .uisel-ph { display: none; }
@keyframes uisel-blink { 50% { opacity: 0; } }

/* ------------------------------------------------------- 3. чекбоксы и радио */
/* В :where(...) — исключения: data-native и скрытые input готовых тумблеров. Добавьте классы тумблеров проекта. */
input:is([type="checkbox"], [type="radio"]):not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)) {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    box-sizing: border-box !important;
    width: 16px;
    height: 16px;
    max-width: 20px !important;    /* защита от общих `input { width: 100% }` */
    max-height: 20px !important;   /* `width: auto` у чекбокса в правилах проекта с appearance:none даёт 0px — заменить на 16px */
    padding: 0 !important;
    border: 1.5px solid var(--ui-cb-border) !important;
    border-radius: var(--ui-radius) !important;
    background-color: var(--ui-surface) !important;
    background-image: none !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 100% 100% !important;
    box-shadow: none !important;
    outline: none;
    flex-shrink: 0;
    vertical-align: -3px;
    cursor: pointer;
    transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
input[type="radio"]:not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)) {
    border-radius: 50% !important;
}
input:is([type="checkbox"], [type="radio"]):not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)):hover:not(:disabled) {
    border-color: var(--ui-accent) !important;
}
input[type="checkbox"]:not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)):is(:checked, :indeterminate) {
    border-color: var(--ui-accent) !important;
    background-color: var(--ui-accent) !important;
    background-image: var(--uicb-tick) !important;
}
input[type="checkbox"]:not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)):indeterminate {
    background-image: var(--uicb-dash) !important;
}
input[type="radio"]:not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)):checked {
    border-color: var(--ui-accent) !important;
    background-image: radial-gradient(circle closest-side, var(--ui-accent) 0 54%, transparent 60%) !important;
}
input:is([type="checkbox"], [type="radio"]):not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)):focus-visible {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-accent) 22%, transparent) !important;
}
input:is([type="checkbox"], [type="radio"]):not(:where([data-native], [role="switch"], .switch input, .toggle input, .ios-toggle input, .kp-layout input, .sup-opt input)):disabled {
    cursor: not-allowed;
    opacity: .5;
}
