/* Lidera Vault UX v26: палитра, поиск сверху, отделы табами, фильтры в панели */

/* ========== Палитра: базовые шкалы (действуют во всём сервисе) ========== */
html:root {
  /* Графитовые нейтральные вместо синеватых */
  --color-gray-050: #f5f6f8;
  --color-gray-100: #e9ebef;
  --color-gray-200: #d3d6dd;
  --color-gray-300: #b0b5c0;
  --color-gray-400: #8a909d;
  --color-gray-500: #6b717e;
  --color-gray-600: #4f5562;
  --color-gray-700: #383d48;
  --color-gray-800: #262a33;
  --color-gray-900: #1a1d24;
  --color-gray-950: #111318;
  --color-gray-950-rgb: 17 19 24;
  --color-gray-400-rgb: 138 144 157;

  /* Акцент: спокойный индиго */
  --color-brand-050: #f0f1ff;
  --color-brand-100: #e2e4ff;
  --color-brand-200: #c9ccff;
  --color-brand-300: #a6abff;
  --color-brand-400: #8890ff;
  --color-brand-500: #6f77f7;
  --color-brand-600: #5b62e8;
  --color-brand-700: #4a4fc9;
  --color-brand-800: #3d41a2;
  --color-brand-900: #343880;
  --color-brand-950: #1f214a;
  --color-brand-950-rgb: 31 33 74;
}

/* ========== Тёмная тема: смысловые цвета ========== */
html.theme_dark {
  --color-bg-primary: #111318;
  --color-bg-secondary: #171a21;
  --color-bg-tertiary: #1c2029;
  --color-bg-quaternary: #232733;
  --color-bg-hover: rgba(255, 255, 255, 0.04);

  --color-fg-heading: #eceef3;
  --color-fg-body: #c9cdd6;
  --color-fg-body-subtle: #8f95a3;

  --color-border-base: #2a2f3a;
  --color-border-muted: #22262f;
  --color-border-light: #2a2f3a;
  --color-border-strong: #363c49;

  --color-bg-brand: #6f77f7;
  --color-bg-brand-strong: #8890ff;
  --color-fg-brand: #a6abff;
  --color-fg-brand-strong: #c9ccff;
  --color-border-brand: #6f77f7;
  --color-border-focus: #8890ff;

  --color-nav-bg-primary: #0e1015;
  --color-nav-bg-primary-hover: #1a1d24;

  /* Старые переменные (в формате R G B) для компонентов старого стиля */
  --color-background: 17 19 24;
  --color-background-alt: 23 26 33;
  --color-background-alt2: 28 32 41;
  --color-background-alt3: 14 16 21;
  --color-background-alt4: 14 16 21;
  --color-primary-100: 31 33 74;
  --color-primary-300: 61 65 162;
  --color-primary-600: 111 119 247;
  --color-primary-700: 136 144 255;
  --color-secondary-100: 34 38 47;
  --color-secondary-300: 42 47 58;
  --color-secondary-500: 79 85 98;
  --color-secondary-600: 107 113 126;
  --color-secondary-700: 176 181 192;
  --color-text-main: 236 238 243;
  --color-text-muted: 143 149 163;
  --color-text-alt2: 236 238 243;
}

/* ========== Наши токены ========== */
:root {
  --vw-ux-surface: var(--color-bg-secondary, #171a21);
  --vw-ux-surface-hover: var(--color-bg-quaternary, #232733);
  --vw-ux-border: var(--color-border-base, #2a2f3a);
  --vw-ux-text: var(--color-fg-heading, #eceef3);
  --vw-ux-muted: var(--color-fg-body-subtle, #8f95a3);
  --vw-ux-accent: var(--color-bg-brand, #6f77f7);
}

/* ========== Одна колонка: фильтры над списком (личное хранилище и админка) ========== */
:is(app-vault, app-org-vault) > div.tw-flex.tw-flex-row {
  flex-direction: column !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  gap: 12px;
}

:is(app-vault, app-org-vault) > div.tw-flex.tw-flex-row > div:is(.tw-basis-1\/4, .tw-max-w-1\/4, .tw-basis-3\/4, .tw-max-w-3\/4) {
  max-width: 100% !important;
  flex-basis: 100% !important;
  width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Оформление включается, только когда скрипт подготовил блок */
[data-testid="filters"].vw-ux-ready {
  position: relative;
  display: block;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
}

[data-testid="filters"].vw-ux-ready [data-testid="filters-header"] {
  display: none !important;
}

[data-testid="filters"].vw-ux-ready [data-testid="filters-body"] {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px 10px;
  padding: 0 !important;
}

[data-testid="filters"].vw-ux-ready [data-testid="filters-body"] > .tw-mb-4 {
  margin-bottom: 0 !important;
  min-width: 0;
}

/* ========== Табы отделов ========== */
.vw-ux-tabs {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--vw-ux-border);
}

.vw-ux-tablist {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.vw-ux-tablist::-webkit-scrollbar {
  display: none;
}

.vw-ux-tab {
  flex: none;
  position: relative;
  padding: 10px 14px 12px;
  border: 0;
  background: transparent;
  color: var(--vw-ux-muted);
  font: 500 14px/1 system-ui, -apple-system, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  border-radius: 8px 8px 0 0;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.vw-ux-tab:hover {
  color: var(--vw-ux-text);
  background: var(--color-bg-hover, rgba(255, 255, 255, 0.04));
}

.vw-ux-tab[aria-selected="true"] {
  color: var(--vw-ux-text);
  font-weight: 600;
}

.vw-ux-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--vw-ux-accent);
}

.vw-ux-tab:focus-visible,
.vw-ux-new-btn:focus-visible {
  outline: 2px solid var(--vw-ux-accent);
  outline-offset: -2px;
}

/* Разделитель перед «Личное» */
.vw-ux-tab-sep {
  flex: none;
  width: 1px;
  height: 18px;
  margin: 0 6px;
  background: var(--vw-ux-border);
}

/* Кнопка «+ Новый отдел» справа от табов */
.vw-ux-new-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  margin-bottom: 6px;
  padding: 0 12px;
  border: 1px dashed var(--vw-ux-border);
  border-radius: 8px;
  background: transparent;
  color: var(--vw-ux-muted);
  font: 500 13px/1 system-ui, -apple-system, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.vw-ux-new-btn:hover {
  color: var(--vw-ux-text);
  border-color: var(--vw-ux-accent);
  border-style: solid;
}

.vw-ux-new-btn span {
  font-size: 16px;
  line-height: 1;
}

/* Раздел отделов в панели не нужен — он стал табами */
.vw-ux-hidden-section {
  display: none !important;
}

/* ========== Выпадающая панель фильтров ==========
   Фон панели — наш пустой блок, разделы фильтров остаются на своих местах
   в DOM (их нельзя переносить), скрипт лишь задаёт им координаты */
[data-testid="filters"].vw-ux-ready [data-testid="filters-body"] > .filter {
  display: none;
}

body.vw-filters-open [data-testid="filters"].vw-ux-ready [data-testid="filters-body"] > .filter:not(.vw-ux-hidden-section) {
  display: block;
  position: absolute;
  z-index: 41;
  top: var(--vw-top, calc(100% + 30px));
  left: var(--vw-left, 22px);
  width: var(--vw-width, 240px);
  max-height: var(--vw-maxh, 60vh);
  overflow: auto;
  margin: 0 !important;
  padding: 0 !important;
  color: var(--vw-ux-text);
}

#vw-ux-filter-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 40;
  height: 240px;
  border: 1px solid var(--vw-ux-border);
  border-radius: 14px;
  background: var(--vw-ux-surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

body.vw-filters-open #vw-ux-filter-panel {
  display: block;
}

[data-testid="filters-body"] > .filter .filter-button {
  border-radius: 8px;
}

[data-testid="filters-body"] > .filter .filter-option.active > .filter-buttons .filter-button {
  color: var(--color-fg-brand, #a6abff);
}

/* ========== Кнопка «Фильтры» ========== */
.vw-ux-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  max-width: 280px;
  padding: 0 16px;
  border: 1px solid var(--vw-ux-border);
  border-radius: 12px;
  background: var(--vw-ux-surface);
  color: var(--vw-ux-text);
  font: 600 13px/1 system-ui, -apple-system, sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.vw-ux-filter-btn:hover {
  background: var(--vw-ux-surface-hover);
}

.vw-ux-filter-btn[aria-expanded="true"],
.vw-ux-filter-btn.vw-ux-active {
  border-color: var(--vw-ux-accent);
}

.vw-ux-filter-btn:focus {
  outline: none;
}

.vw-ux-filter-btn:focus-visible {
  outline: 2px solid var(--vw-ux-accent);
  outline-offset: 2px;
}

.vw-ux-filter-btn .vw-ux-current {
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  color: var(--vw-ux-muted);
}

.vw-ux-filter-btn svg {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

@media (prefers-reduced-motion: reduce) {
  .vw-ux-filter-btn,
  .vw-ux-tab,
  .vw-ux-new-btn {
    transition: none;
  }
}

@media (max-width: 768px) {
  [data-testid="filters"].vw-ux-ready [data-testid="filters-body"] {
    grid-template-columns: 1fr;
  }

  .vw-ux-filter-btn {
    width: 100%;
    max-width: none;
    justify-content: center;
  }
}


/* ========== Логотип LIDERA в боковом меню ==========
   Иконка — файл /custom/lidera-icon.png, надпись нарисована в CSS */
html body bit-nav-logo :is(bit-svg, bit-icon) > svg {
  display: none !important;
}

html body bit-nav-logo :is(bit-svg, bit-icon) {
  justify-content: flex-start !important;
  align-items: center !important;
  height: 100% !important;
}

html body bit-nav-logo :is(bit-svg, bit-icon)::before {
  content: "" !important;
  display: block !important;
  width: 210px !important;
  height: 44px !important;
  max-width: 100% !important;
  background-repeat: no-repeat, no-repeat !important;
  background-size: 40px 40px, 150px 45px !important;
  background-position: left center, 54px center !important;
  background-image: url("/custom/lidera-icon.png"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='48' viewBox='0 0 160 48'%3E%3Ctext x='0' y='26' font-family='-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif' font-size='20' font-weight='300' letter-spacing='2' fill='%23eceef3'%3ELIDERA%3C/text%3E%3Ctext x='0.5' y='42' font-family='-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif' font-size='12' fill='%238f95a3'%3EPassword Manager%3C/text%3E%3C/svg%3E") !important;
}

/* Админка: ссылка логотипа ведёт в /organizations/ */
html body bit-nav-logo a[href*="/organizations/"] :is(bit-svg, bit-icon)::before {
  background-image: url("/custom/lidera-icon.png"), url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='48' viewBox='0 0 160 48'%3E%3Ctext x='0' y='26' font-family='-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif' font-size='20' font-weight='300' letter-spacing='2' fill='%23eceef3'%3ELIDERA%3C/text%3E%3Ctext x='0.5' y='42' font-family='-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif' font-size='12' fill='%238f95a3'%3EAdmin Console%3C/text%3E%3C/svg%3E") !important;
}

/* ========== Брендинг на экранах входа и разблокировки ========== */
.vw-ux-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--color-fg-heading, #eceef3);
  font: 300 22px/1 system-ui, -apple-system, sans-serif;
  letter-spacing: 2px;
  text-decoration: none;
}

.vw-ux-brand img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
}

.vw-ux-hero {
  display: block;
  width: 96px;
  height: 96px;
  margin: 0 auto 12px;
  border-radius: 22px;
  box-shadow: 0 12px 40px rgba(111, 119, 247, 0.25);
}


/* Колонки страницы на всю ширину (и в админке тоже) */
div.tw-flex:has(> div [data-testid="filters"]) {
  flex-direction: column !important;
  gap: 12px;
}

div.tw-flex:has(> div [data-testid="filters"]) > div {
  max-width: 100% !important;
  flex-basis: auto !important;
  width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
