/* =========================================================
   Shared component styles: button, icon, title, tilt, select.
   Source: design/components/**/*.css
   ========================================================= */

/* ===== Icon ===== */
.icon {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  line-height: 0;
  color: currentColor;
  --icon-size: 20px;
  height: var(--icon-size);
  width: auto;
}

.icon svg {
  display: block;
  width: auto;
  height: 100%;
}

.icon--eye-show,
.icon--eye-hide,
.icon--close { color: var(--color-slate-400); }
.icon--eye-show { width: 12px; height: 12px; }
.icon--eye-hide,
.icon--close { width: 14px; height: 14px; }

.icon--chat { width: 20px; height: 20px; color: var(--color-slate-800); }

.icon--avatar {
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-xl);
  background: var(--color-overlay);
  backdrop-filter: var(--blur-glass);
  -webkit-backdrop-filter: var(--blur-glass);
}

.icon--avatar-ai { color: var(--color-primary); }
.icon--avatar-user { color: var(--color-secondary); }

.icon--book,
.icon--supervisor,
.icon--user,
.icon--setting { color: var(--color-slate-600); width: 20px; height: 20px; }

.icon--book-hover,
.icon--supervisor-hover,
.icon--user-hover,
.icon--setting-hover { color: var(--color-slate-900); width: 20px; height: 20px; }

.icon--doc,
.icon--copy,
.icon--export,
.icon--caret-down,
.icon--caret-up,
.icon--checkbox-checked,
.icon--checkbox-unchecked { color: var(--color-slate-400); }

.icon--caret-down,
.icon--caret-up { width: 18px; height: 16px; }
.icon--checkbox-checked,
.icon--checkbox-unchecked { width: 12px; height: 12px; }
.icon--caret-up svg { transform: rotate(180deg); }

/* ===== Button ===== */
.btn {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: var(--radius-xl);
  font-family: var(--font-heading);
  font-style: normal;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary-soft);
  outline-offset: 2px;
}

.btn__icon {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.btn__icon svg {
  display: block;
  width: auto;
  height: var(--icon-size, 20px);
  max-width: 100%;
}

.btn__label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Primary */
.btn--primary {
  padding: 13px 0;
  height: 46px;
  min-width: 226px;
  background: var(--color-primary);
  color: #ffffff;
}
.btn--primary:hover { background: var(--color-primary-hover); }
.btn--primary .btn__label { font-weight: 700; font-size: 14px; line-height: 20px; }

/* Secondary */
.btn--secondary {
  padding: 12px 0;
  width: 238px;
  height: 42px;
  background: var(--color-surface-muted);
  color: var(--color-primary);
  border: var(--border-width-strong) solid var(--color-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 16px;
}
.btn--secondary:hover { border-width: var(--border-width-2x); }
.btn--secondary.is-disabled,
.btn--secondary:disabled {
  color: var(--color-slate-400);
  border-color: var(--color-slate-400);
  border-width: var(--border-width-default);
  cursor: not-allowed;
  opacity: 1;
}
.btn--secondary .btn__label { font-family: var(--font-body); font-weight: 600; }
.btn--secondary.is-disabled .btn__label,
.btn--secondary:disabled .btn__label { font-weight: 400; }

/* Ghost */
.btn--ghost {
  padding: 0;
  width: 46px;
  height: 46px;
  border-radius: var(--radius-2xl);
  background: var(--color-primary-hover);
  color: #ffffff;
}
.btn--ghost:hover,
.btn--ghost.is-hover {
  background: linear-gradient(117.36deg, #0ea5e9 2.9%, #01ffe9 109.57%);
}
.btn--ghost .btn__icon svg { width: 48px; height: 41px; }
.btn--ghost.is-disabled,
.btn--ghost:disabled {
  background: var(--color-slate-400);
  color: #ffffff;
  opacity: 1;
  cursor: not-allowed;
}

/* Icon-only */
.btn--icon {
  padding: 6px;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--color-slate-400);
  box-sizing: border-box;
  overflow: visible;
}
.btn--icon:hover { color: var(--color-slate-800); }
.btn--icon .btn__icon { overflow: visible; }
.btn--icon .btn__icon svg { display: block; }

/* Chip */
.btn--chip {
  padding: 0;
  min-height: 32px;
  min-width: 152px;
  background: var(--color-primary);
  color: #ffffff;
  border: var(--border-width-default) solid rgba(255, 255, 255, 0.1);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
}
.btn--chip:hover { background: var(--color-primary-hover); }

.btn--chip-outline {
  padding: 0;
  min-height: 32px;
  min-width: 152px;
  background: var(--color-surface);
  color: var(--color-primary);
  border: var(--border-width-default) solid var(--color-primary);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 16px;
}
.btn--chip-outline:hover { border-width: var(--border-width-2x); }
.btn--chip-outline.is-disabled,
.btn--chip-outline:disabled {
  color: var(--color-slate-400);
  border-color: var(--color-slate-400);
}

/* ===== Title ===== */
.title {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-heading);
  font-style: normal;
  text-decoration: none;
}
.title__label { display: inline-flex; align-items: center; }

.title--primary   { color: var(--color-slate-900); font-weight: 800; font-size: 16px; line-height: 20px; }
.title--secondary { color: var(--color-slate-600); font-weight: 600; font-size: 12px; line-height: 16px; }
.title--active    { color: var(--color-slate-900); font-weight: 800; font-size: 12px; line-height: 16px; }
.title--inactive  { color: var(--color-slate-600); font-weight: 600; font-size: 12px; line-height: 16px; }

/* ===== Tilt (badge) ===== */
.tilt {
  display: inline-flex;
  gap: 12px;
  align-items: center;
  font-family: var(--font-body);
}
.tilt__badge {
  width: 72px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--color-overlay);
  -webkit-backdrop-filter: var(--blur-glass);
  backdrop-filter: var(--blur-glass);
  border: var(--border-width-default) solid var(--color-border-soft);
  color: var(--color-secondary);
  font-size: 12px;
  line-height: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ===== Select (custom DsSelect dropdown) =====
 * Used by <DsSelect TValue="..."> to render an on-brand replacement for the
 * native <select>. The panel is absolutely positioned so it floats over
 * surrounding content instead of pushing it down. Two size variants are
 * exposed via Class:
 *   - default / .ds-select--field — 45px / radius 24px (matches .kb-field)
 *   - .ds-select--compact — 36px / radius 16px (tight rows like the inline
 *     "Добавить базу" cell on the Users page).
 */
.select {
  position: relative;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  font-family: var(--font-heading);
}

.select__trigger {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 45px;
  padding: 12px 16px;
  border: 1px solid var(--color-border-soft);
  border-radius: 24px;
  background: var(--color-surface-muted);
  color: var(--color-slate-800);
  cursor: pointer;
  appearance: none;
  text-align: left;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  transition:
    border-color var(--transition-fast),
    box-shadow var(--transition-fast),
    background-color var(--transition-fast);
}

.select__trigger:hover {
  border-color: var(--color-primary-soft);
  background: var(--color-surface-soft);
}

.select__trigger:focus-visible {
  outline: 0;
  border-color: var(--color-primary);
  box-shadow:
    0 0 0 4px rgba(14, 165, 233, 0.18),
    var(--shadow-glass);
  background: var(--color-surface);
}

/* Empty (placeholder) state — value is muted, like a real placeholder. */
.select:not(.select--selected) .select__value {
  color: var(--color-slate-400);
  font-weight: 400;
}

.select--selected .select__value {
  color: var(--color-slate-800);
  font-weight: 500;
}

.select__value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 16px;
}

.select__caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--color-primary);
  transition: transform var(--transition-fast);
}

.select__caret svg {
  display: block;
  width: 12px;
  height: 12px;
}

.select--open .select__caret {
  transform: rotate(180deg);
}

.select--open .select__trigger {
  border-color: var(--color-primary);
  background: var(--color-surface);
  box-shadow: 0 0 0 4px rgba(14, 165, 233, 0.18);
}

/* Floating panel — absolutely positioned so it overlays neighbours instead
   of pushing the page down. Has its own scroll once it gets long. */
.select__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 50;
  display: none;
  flex-direction: column;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-2xl);
  box-shadow:
    0 18px 48px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(14, 165, 233, 0.06);
  scrollbar-width: thin;
  scrollbar-color: var(--color-primary-soft) transparent;
}

.select__panel::-webkit-scrollbar {
  width: 6px;
}

.select__panel::-webkit-scrollbar-thumb {
  background-color: var(--color-primary-soft);
  border-radius: 3px;
}

.select__panel::-webkit-scrollbar-track {
  background: transparent;
}

.select--open .select__panel {
  display: flex;
}

.select__option {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-slate-800);
  cursor: pointer;
  appearance: none;
  text-align: left;
  font-family: var(--font-heading);
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.select__option:hover,
.select__option:focus-visible {
  background: var(--color-surface-soft);
  outline: 0;
}

.select__option--active {
  background: linear-gradient(0deg, var(--color-primary-soft), var(--color-primary-soft));
}

.select__option--active .select__option-label {
  font-weight: 600;
  color: var(--color-slate-900);
}

.select__option-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 500;
  line-height: 16px;
  color: var(--color-slate-800);
}

.select__input {
  box-sizing: border-box;
  width: 100%;
  min-height: 32px;
  padding: 8px 14px;
  border: var(--border-width-default) solid var(--color-slate-400);
  border-radius: var(--radius-xl);
  background: var(--color-surface-muted);
  font-family: var(--font-heading);
  font-size: 12px;
  line-height: 16px;
  color: var(--color-slate-800);
}

.select__empty {
  padding: 12px;
  color: var(--color-slate-400);
  font-family: var(--font-body);
  font-size: 12px;
  line-height: 16px;
  text-align: center;
}

/* ─── Compact variant (.ds-select--compact) ───
 * For tight inline rows (e.g. "Добавить базу" on the Users page). Mirrors
 * the smaller .select-input__control geometry so the trigger sits flush
 * with the "Добавить" button next to it. */
.select.ds-select--compact .select__trigger {
  min-height: 36px;
  padding: 8px 14px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-slate-400);
}

.select.ds-select--compact .select__panel {
  border-radius: var(--radius-xl);
}

/* ─── Field variant (.ds-select--field) ───
 * Default size; alias kept so call sites can be explicit. */
.select.ds-select--field .select__trigger {
  min-height: 45px;
  border-radius: 24px;
}

.select.ds-select--field .select__panel {
  border-radius: var(--radius-2xl);
}
