/* css/components/custom-select.css — Свой выпадающий список вместо системного <select>.
   Порядок подключения всех стилей задан в layout/head.php — он важен. */

/* =============================================================
   КАСТОМНЫЙ DROPDOWN ДЛЯ <select>
   Нативный select скрыт (display:none), но остаётся в DOM и
   полностью рабочим — value/change/input не трогали. Визуально
   вместо системного попапа показывается свой HTML-список, поэтому
   цвета/фон опций одинаковы во всех браузерах и панелях.
   ============================================================= */

.custom-select-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 360px;
}

.custom-select-native {
  display: none !important;
}

button.custom-select-trigger {width:230px;}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(124, 92, 255, 0.2);
  background: linear-gradient(180deg, rgba(20, 28, 45, 0.95), rgba(12, 18, 32, 0.98));
  color: #ffffff;
  font-size: 14px;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-select-trigger:hover {
  border-color: rgba(0, 229, 255, 0.35);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.08);
}

.custom-select-trigger:focus,
.custom-select-trigger.open {
  border-color: rgba(124, 92, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.15), 0 0 18px rgba(124, 92, 255, 0.2);
}

/* Отключённый select (например Platform, пока активна кастомная
   платформа, или Custom, пока не создано ни одного профиля) — :disabled
   работает, т.к. custom-select.js теперь ставит trigger.disabled = true
   в renderTrigger(); .is-disabled — на случай ручной простановки класса. */
.custom-select-trigger:disabled,
.custom-select-trigger.is-disabled {
  cursor: not-allowed;
  opacity: 0.5;
  border-color: rgba(124, 92, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
}

.custom-select-trigger:disabled:hover,
.custom-select-trigger.is-disabled:hover {
  border-color: rgba(124, 92, 255, 0.12);
  box-shadow: none;
}

.custom-select-trigger:disabled .custom-select-caret,
.custom-select-trigger.is-disabled .custom-select-caret {
  opacity: 0.5;
}

/* Фолбэк для нативного <select disabled> в контекстах без кастомного
   dropdown (на случай, если enhanceSelectDropdown() ещё не отработал). */
select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.custom-select-trigger-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-caret {
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text-dim);
  transition: transform 0.15s ease;
}

.custom-select-trigger.open .custom-select-caret {
  transform: rotate(180deg);
}

.custom-select-list {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  /* Список расширяется по содержимому (не только по ширине триггера) —
     right:0 здесь НЕ ставим специально, иначе width всегда равен ширине
     wrap'а, даже если реальный текст опций длиннее (см. #select-model,
     где триггеры узкие, а названия платформ/профилей — нет). */
  z-index: 50;
	height:auto;
  max-height: 500px;
	width: max-content;
	min-width: 100%;
	max-width: min(320px, 90vw);
  overflow-y: auto;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid rgba(124, 92, 255, 0.2);
  background: linear-gradient(180deg, rgba(20,28,45,0.98), rgba(10,16,28,0.98));
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px rgba(0,0,0,0.45), 0 0 20px rgba(124,92,255,0.1);
}

.custom-select-list.open { display: block; }

/* Недостаточно места снизу до края экрана (см. openList() в
   common/ui/custom-select.js) — открываем список вверх от триггера вместо
   вниз, тот же принцип, что у нативного <select>. Не действует в режиме
   .custom-select-list-fixed ниже — там top/bottom ставит inline JS. */
.custom-select-list.open-up:not(.custom-select-list-fixed) {
  top: auto;
  bottom: calc(100% + 6px);
}

/* Режим для селектов внутри попапов (.pstats-modal — Show Profiles/Custom
   Platforms / CSV Presets / Show Profiles): .pstats-modal{overflow:
   hidden}/.pstats-body{overflow-y:auto} обрезали бы position:absolute
   список независимо от z-index — position:fixed с координатами от
   viewport (openList() в custom-select.js вычисляет и ставит top/left/
   min-width/max-width inline через getBoundingClientRect(), эта CSS-
   позиция здесь не участвует) решает это. Обычные (не в модалке) селекты
   этот класс не получают — там absolute-позиционирование выше и так
   работает, трогать не нужно. */
.custom-select-list.custom-select-list-fixed {
  position: fixed;
  z-index: 3000; /* выше .pstats-overlay (z-index:2000) */
  /* НАЙДЕННЫЙ БАГ (отладка через javascript_tool на живом сервере): базовое
     правило .custom-select-list выше ставит top:calc(100% + 6px) — когда
     JS в openList() очищает inline top ("" — открытие вверх, top не нужен),
     браузер откатывается НЕ на "auto", а на этот calc(), который для
     position:fixed считается от высоты viewport (список в портале — прямой
     потомок body), а не от wrap — список схлопывался до считанных пикселей
     (top уезжал за нижний край экрана). Двойной класс-селектор (специфичность
     0,2,0) гарантированно перебивает базовый .custom-select-list (0,1,0)
     независимо от порядка правил в файле — top/left держим на auto здесь,
     конкретные значения только inline из openList(). */
  top: auto;
  left: auto;
}

.custom-select-option {
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #e6e6e6;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.custom-select-option:hover,
.custom-select-option.is-active {
  background: rgba(124, 92, 255, 0.18);
  color: #ffffff;
}

.custom-select-option.is-selected {
  color: #00e5ff;
  font-weight: 600;
}

.custom-select-option.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* В узких контейнерах (боковая панель, Keyword Rules) — без ограничения ширины */
.batch-tools-panel .custom-select-wrap,
.kr-field .custom-select-wrap {
  max-width: 100%;
}

/* #csvPresetSelect + кнопка "⚙ Manage" (custom-platform-select-wrap) внутри
   боковой панели "CSV Export" — вне .select-model, поэтому без этого
   правила триггер брал фиксированные 230px (см. button.custom-select-trigger
   выше) и вылезал за узкую панель, наезжая на кнопку-шестерёнку. */
.batch-tools-panel .custom-platform-select-wrap .custom-select-trigger {
  width: 100%;
}

/* Строка "Preset:" в CSV Export — сам .sel в базовом виде рассчитан на
   несколько колонок в ряд (Settings: Model/Platform/Custom Platform), отсюда
   max-width:220px/margin-left:5px. Здесь колонка одна — растягиваем на всю
   ширину панели, как остальные пункты (.csv-fields-list, .filename-pattern-field). */
.batch-tools-panel .sel {
  max-width: 100%;
  min-width: 0;
  width: 100%;
  margin-left: 0;
  flex: 1 1 auto;
}

.kr-field .custom-select-trigger {  
  font-size: 12px;
  border-radius: 8px;
}

