/*
 * My Work — Element Settings
 *
 * Единые настройки и стили компонентов интерфейса.
 *
 * Цвета: theme.css
 * Типографика: font.css
 * Компоненты: component.css
 */

:root {
  /* ========================================
       КНОПКИ
       ======================================== */

  /* Высота кнопок */
  --button-height-sm: 34px;
  --button-height-md: 40px;
  --button-height-lg: 46px;

  /* Горизонтальные внутренние отступы */
  --button-padding-x: 16px;

  /* Расстояние между иконкой и текстом */
  --button-gap: 8px;

  /* Скругление кнопок */
  --button-radius: 14px;

  /* ========================================
       ПОЛЯ ВВОДА
       ======================================== */

  /* Высота обычного поля */
  --input-height: 40px;

  /* Горизонтальные внутренние отступы */
  --input-padding-x: 14px;

  /* Скругление полей */
  --input-radius: 14px;

  /* ========================================
       КАРТОЧКИ
       ======================================== */

  /* Внутренний отступ карточки */
  --card-padding: 20px;

  /* Скругление карточки */
  --card-radius: 20px;

  /* ========================================
       МОДАЛЬНЫЕ ОКНА
       ======================================== */

  /* Скругление модального окна */
  --modal-radius: 20px;

  /* Внутренний отступ */
  --modal-padding: 24px;

  /* Максимальная ширина */
  --modal-max-width: 520px;

  /* ========================================
       ЧЕКБОКСЫ
       ======================================== */

  /* Размер чекбокса */
  --checkbox-size: 18px;

  /* Скругление чекбокса */
  --checkbox-radius: 5px;

  /* Расстояние между чекбоксом и подписью */
  --checkbox-gap: 10px;

  /* ========================================
       ПЕРЕКЛЮЧАТЕЛИ
       ======================================== */

  /* Ширина переключателя */
  --switch-width: 40px;

  /* Высота переключателя */
  --switch-height: 24px;

  /* Диаметр подвижного индикатора */
  --switch-thumb-size: 18px;

  /* ========================================
       ВЫПАДАЮЩИЕ СПИСКИ
       ======================================== */

  /* Высота Select */
  --select-height: 40px;

  /* Скругление Select */
  --select-radius: 14px;

  /* Высота строки меню */
  --select-option-height: 40px;

  /* Максимальная высота выпадающего меню */
  --select-menu-max-height: 200px;

  /* ========================================
       УВЕДОМЛЕНИЯ И TOAST
       ======================================== */

  /* Скругление уведомлений */
  --notification-radius: 14px;

  /* Внутренний отступ уведомления */
  --notification-padding: 14px;

  /* Скругление Toast */
  --toast-radius: 14px;

  /* Внутренний отступ Toast */
  --toast-padding: 14px;

  /* ========================================
       АНИМАЦИИ
       ======================================== */

  /* Быстрая анимация */
  --motion-fast: 150ms;
}

/* ========================================
   КНОПКИ
   ======================================== */

/* ========================================
   ПОЛЯ ВВОДА
   ======================================== */

/* ========================================
   КАРТОЧКИ
   ======================================== */

.comp-card {
  padding: var(--card-padding);

  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);

  background: var(--surface);
}

/* MY WORK — IMPORTED COMPONENTS */

.comp {
  /* Размеры Select из единой дизайн-системы */
  --select-option-gap: 4px;
}

/*
 * My Work Design System v1 — Inputs
 * Independent of legacy forms.css
 */

.comp .comp-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.comp .comp-label {
  display: block;
  color: var(--text-color);
  font-size: var(--font-body);
  font-weight: var(--weight-heading);
}

.comp .comp-input {
  display: block;
  box-sizing: border-box;
  width: 100%;
  height: var(--button-height-lg);
  min-width: 0;
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  background: var(--surface);
  color: var(--text-color);
  font-size: var(--font-body);
  font-weight: var(--weight-text);
  line-height: 1.3;
  outline: none;
  transition:
    border-color var(--motion-fast) ease,
    box-shadow var(--motion-fast) ease,
    background-color var(--motion-fast) ease;
}

.comp .comp-input::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.comp .comp-input:hover:not(:disabled):not(:read-only) {
  border-color: var(--accent);
}

.comp .comp-input:focus-visible {
  border-color: var(--accent);
  box-shadow: none;
}

.comp .comp-input--sm {
  height: var(--button-height-sm);
  padding-inline: 10px;
}

.comp .comp-input--md {
  height: var(--button-height-md);
  padding-inline: 12px;
}

.comp .comp-input--lg {
  height: var(--button-height-lg);
}

.comp .comp-input[aria-invalid='true'],
.comp .comp-input--error {
  border-color: var(--input-error-color);
}

.comp .comp-input[aria-invalid='true']:focus-visible,
.comp .comp-input--error:focus-visible {
  box-shadow: none;
}

.comp .comp-field-error {
  color: var(--input-error-color);
  font-size: var(--font-small);
}

.comp .comp-field-help {
  color: var(--text-muted);
  font-size: var(--font-small);
}

.comp .comp-input:disabled {
  background: var(--hover-bg);
  color: var(--text-muted);
  opacity: 0.65;
  cursor: not-allowed;
}

.comp .comp-input:read-only {
  background: var(--page-bg);
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .comp .comp-input {
    transition: none;
  }
}

/*
 * My Work Design System v1 — Extended Inputs
 * Textarea, input icons and input actions.
 */

/* Textarea */

.comp .comp-textarea {
  box-sizing: border-box;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 112px;
  padding: 12px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  background: var(--surface);
  color: var(--text-color);
  font-size: var(--font-body);
  line-height: 1.5;
  outline: none;
  resize: vertical;
  transition: border-color var(--motion-fast) ease;
}

.comp .comp-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.comp .comp-textarea:focus {
  border-color: var(--accent);
  box-shadow: none;
}

.comp .comp-textarea[aria-invalid='true'] {
  border-color: var(--input-error-color);
}

.comp .comp-textarea:disabled {
  background: var(--hover-bg);
  color: var(--text-muted);
  opacity: 0.65;
  cursor: not-allowed;
}

/* Input wrapper */

.comp .comp-input-wrap {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  height: var(--button-height-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  background: var(--surface);
  transition: border-color var(--motion-fast) ease;
}

.comp .comp-input-wrap:focus-within {
  border-color: var(--accent);
}

.comp .comp-input-wrap:has(.comp-input[aria-invalid='true']) {
  border-color: var(--input-error-color);
}

.comp .comp-input-wrap:has(.comp-input:disabled) {
  background: var(--hover-bg);
  opacity: 0.65;
}

.comp .comp-input-wrap .comp-input {
  flex: 1;
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  outline: none;
  box-shadow: none;
}

.comp .comp-input-wrap .comp-input:focus,
.comp .comp-input-wrap .comp-input:focus-visible,
.comp .comp-input-wrap .comp-input:hover,
.comp .comp-input-wrap .comp-input[aria-invalid='true'] {
  border: 0;
  box-shadow: none;
}

.comp .comp-input-wrap .comp-input:disabled {
  background: transparent;
}

.comp .comp-input-wrap .comp-input:read-only {
  background: transparent;
}

.comp .comp-input-wrap--sm {
  height: var(--button-height-sm);
}

.comp .comp-input-wrap--md {
  height: var(--button-height-md);
}

/* Icons */

.comp .comp-input-icon {
  display: inline-flex;
  flex: 0 0 18px;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.comp .comp-input-icon svg,
.comp .comp-input-action svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Action button inside input */

.comp .comp-input-action {
  display: inline-flex;
  flex: 0 0 36px;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-right: 5px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.comp .comp-input-action:hover:not(:disabled) {
  background: var(--hover-bg);
  color: var(--text-color);
}

.comp .comp-input-action:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -2px;
}

.comp .comp-input-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .comp .comp-textarea,
  .comp .comp-input-wrap {
    transition: none;
  }
}

/*
 * My Work Design System v1 — Buttons.
 * Isolated from legacy .btn.
 */

.comp .comp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--button-height-lg);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--input-radius);
  font-size: var(--font-body);
  font-weight: var(--weight-button);
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition:
    background-color var(--motion-fast) ease,
    border-color var(--motion-fast) ease,
    color var(--motion-fast) ease;
}

.comp .comp-btn--sm {
  min-height: var(--button-height-sm);
  padding-inline: 12px;
  font-size: var(--font-small);
}

.comp .comp-btn--md {
  min-height: var(--button-height-md);
  padding-inline: 16px;
}

.comp .comp-btn--lg {
  min-height: var(--button-height-lg);
}

.comp .comp-btn--primary {
  background: var(--accent);
  color: var(--button-primary-text);
}

.comp .comp-btn--primary:hover:not(:disabled) {
  background: var(--button-primary-hover);
}

.comp .comp-btn--secondary {
  background: var(--surface);
  border-color: var(--border-color);
  color: var(--text-color);
}

.comp .comp-btn--secondary:hover:not(:disabled) {
  background: var(--hover-bg);
}

.comp .comp-btn--ghost {
  background: transparent;
  color: var(--text-color);
}

.comp .comp-btn--ghost:hover:not(:disabled) {
  background: var(--hover-bg);
}

.comp .comp-btn--danger {
  background: transparent;
  border-color: var(--border-color);
  color: var(--input-error-color);
}

.comp .comp-btn--danger:hover:not(:disabled) {
  background: color-mix(in srgb, var(--input-error-color) 12%, transparent);
  border-color: var(--input-error-color);
}

.comp .comp-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.comp .comp-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.comp .comp-btn--full {
  width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  .comp .comp-btn {
    transition: none;
  }
}

/*
 * My Work Design System v1 — Select
 * Independent of legacy picker.js and forms.css
 */

.comp .comp-select {
  position: relative;
  width: 100%;
  min-width: 0;
}

.comp .comp-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  height: var(--select-height);
  padding: 0 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--input-radius);
  background: var(--surface);
  color: var(--text-color);
  font-size: var(--font-body);
  font-weight: var(--weight-text);
  text-align: left;
  cursor: pointer;
  outline: none;
  transition:
    border-color var(--motion-fast) ease,
    background-color var(--motion-fast) ease;
}

.comp .comp-select-trigger:hover:not(:disabled) {
  border-color: var(--border-color);
}

.comp .comp-select-trigger:focus-visible,
.comp .comp-select-trigger[aria-expanded='true'] {
  border-color: var(--accent);
  box-shadow: none;
}

.comp .comp-select-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comp .comp-select-placeholder {
  color: var(--text-muted);
}

.comp .comp-select-chevron {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transition: transform var(--motion-fast) ease;
}

.comp .comp-select-chevron::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.comp .comp-select-trigger[aria-expanded='true'] .comp-select-chevron {
  transform: rotate(180deg);
}

.comp .comp-select--sm .comp-select-trigger {
  height: var(--button-height-sm);
  padding-inline: 10px;
}

.comp .comp-select--md .comp-select-trigger {
  height: var(--button-height-md);
  padding-inline: 12px;
}

.comp .comp-select-trigger:disabled {
  background: var(--hover-bg);
  color: var(--text-muted);
  opacity: 0.65;
  cursor: not-allowed;
}

.comp[data-ds-select-portal] {
  position: fixed;
  inset: 0;
  z-index: 2000;
  width: 0;
  height: 0;
  pointer-events: none;
}

.comp[data-ds-select-portal] .comp-select-popover {
  pointer-events: auto;
}

/* Dropdown portal: rendered outside clipped containers */

.comp .comp-select-popover {
  position: fixed;
  z-index: 2000;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: var(--select-radius);
  background: var(--surface);
  color: var(--text-color);
  font-size: var(--font-body);
  box-shadow: var(--select-shadow);
  overflow: hidden;
}

.comp .comp-select-popover[hidden] {
  display: none;
}

.comp .comp-select-search {
  box-sizing: border-box;
  display: block;
  width: 100%;
  height: 36px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-color);
  font: inherit;
  outline: none;
}

.comp .comp-select-search:focus {
  border-color: var(--accent);
  box-shadow: none;
}

.comp .comp-select-options {
  display: flex;
  flex-direction: column;
  gap: var(--select-option-gap);
  max-height: var(--select-menu-max-height);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.comp .comp-select-option {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  width: 100%;
  height: var(--select-option-height);
  min-height: var(--select-option-height);
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-color);
  font: inherit;
  font-size: var(--font-body);
  font-weight: var(--weight-medium);
  text-align: left;
  cursor: pointer;
}

.comp .comp-select-option:hover,
.comp .comp-select-option[data-active='true'] {
  background: var(--hover-bg);
  color: var(--text-color);
}

.comp .comp-select-option[aria-selected='true'] {
  background: var(--hover-bg);
  color: var(--text-color);
}

/* При наведении на другой пункт убираем фоновую
   подсветку с ранее выбранного пункта. */
.comp .comp-select-options:hover .comp-select-option[aria-selected='true']:not(:hover) {
  background: transparent;
  color: var(--text-color);
}

.comp .comp-select-option[aria-selected='true']:hover,
.comp .comp-select-option[aria-selected='true'][data-active='true'] {
  background: var(--hover-bg);
}

.comp .comp-select-option:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.comp .comp-select-option:disabled {
  color: var(--text-muted);
  opacity: 0.55;
  cursor: not-allowed;
}

.comp .comp-select-empty,
.comp .comp-select-loading,
.comp .comp-select-error {
  padding: 12px;
  color: var(--text-muted);
  font-size: var(--font-body);
  text-align: center;
}

.comp .comp-select-error {
  color: var(--input-error-color);
}

@media (prefers-reduced-motion: reduce) {
  .comp .comp-select-trigger,
  .comp .comp-select-chevron {
    transition: none;
  }
}

/* ========================================
   INPUT AUTOFILL FIX
   ======================================== */

.comp .comp-input:-webkit-autofill,
.comp .comp-input:-webkit-autofill:hover,
.comp .comp-input:-webkit-autofill:focus,
.comp .comp-input:-webkit-autofill:active,
.comp .comp-textarea:-webkit-autofill,
.comp .comp-textarea:-webkit-autofill:hover,
.comp .comp-textarea:-webkit-autofill:focus,
.comp .comp-textarea:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text-color);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  transition: background-color 9999s ease-out 0s;
  caret-color: var(--text-color);
}

/* ========================================
   COMPONENT SKELETON
   ======================================== */

.comp-skeleton-page {
  padding: 0;
  width: 100%;
}

.comp-skeleton {
  position: relative;
  overflow: hidden;
  background: var(--hover-bg);
  border-radius: var(--card-radius);
}

.comp-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--surface) 75%, transparent),
    transparent
  );
  animation: comp-skeleton-shimmer 1.5s ease-in-out infinite;
}

.comp-skeleton-title {
  width: 220px;
  max-width: 65%;
  height: 30px;
  margin-bottom: 18px;
  border-radius: 8px;
}

.comp-skeleton-subtitle {
  width: 290px;
  max-width: 80%;
  height: 14px;
  margin-bottom: 18px;
  border-radius: 6px;
}

.comp-skeleton-action {
  width: 110px;
  height: var(--button-height-md);
  margin-bottom: 28px;
  border-radius: var(--button-radius);
}

.comp-skeleton-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.comp-skeleton-card {
  height: 120px;
}

.comp-skeleton-sidebar {
  display: flex;
  flex-direction: column;
  gap: 25px;
  width: 274px;
  min-height: 100dvh;
  padding: 28px 16px;
  background: var(--surface);
  border-right: 1px solid var(--border-color);
}

.comp-skeleton-brand {
  width: 145px;
  height: 26px;
  border-radius: 7px;
}

.comp-skeleton-nav {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.comp-skeleton-nav-item {
  width: 90%;
  height: 34px;
  border-radius: 8px;
}

.comp-skeleton-nav-item:nth-child(2n) {
  width: 75%;
}

.comp-skeleton-profile {
  height: 58px;
  margin-top: auto;
  border-radius: 12px;
}

.comp-skeleton-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@keyframes comp-skeleton-shimmer {
  to {
    transform: translateX(100%);
  }
}

/* Отключаем стандартное перекрытие при анимации смены темы. */
@supports (view-transition-name: root) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none;
    mix-blend-mode: normal;
  }

  ::view-transition-old(root) {
    z-index: 1;
  }

  ::view-transition-new(root) {
    z-index: 2;
  }
}

@media (max-width: 720px) {
  .comp-skeleton-grid {
    grid-template-columns: 1fr;
  }

  .comp-skeleton-sidebar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .comp-skeleton::after {
    animation: none;
  }
}
