/* =====================================================================
   Unified UI component layer (.ui-*)
   ---------------------------------------------------------------------
   Единая система базовых компонентов формы и контейнеров. За эталон взято
   оформление настроек бота (функции и контекст): карточка .surface-card /
   .bot-function-card, поля .admin-input, кнопки .admin-*-button.

   Этот файл подключается ПОСЛЕ base.css и выполняет две задачи:
     1) Объявляет канонические классы .ui-card / .ui-field / .ui-input /
        .ui-btn и т.п. для новых и мигрированных шаблонов.
     2) Сводит расходящиеся легаси-классы к единому виду (группируя их
        селекторы вместе с каноническими), чтобы весь сайт выглядел
        единообразно даже на ещё не мигрированных страницах.

   Значения намеренно совпадают с эталонными правилами base.css, чтобы уже
   согласованные страницы не «поехали»; правятся только выявленные выбросы
   (две разные подписи-подсказки, поле логина, и т.п.).
   ===================================================================== */

/* ── Контейнер-карточка ───────────────────────────────────────────── */
/* База визуала наследуется от .surface-card (см. base.css). Канонический
   .ui-card повторяет её, а легаси-варианты карточек выравниваются по тем
   же отступам/скруглению, устраняя «десять контейнеров на странице». */
.ui-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid color-mix(in srgb, var(--border-color), transparent 15%);
  border-radius: 24px;
  padding: var(--panel-padding-block, 28px) var(--panel-padding-inline, 32px);
  box-shadow: var(--panel-shadow, 0 20px 40px rgba(15, 23, 42, 0.12));
  overflow: hidden;
}

/* ── Заголовок/описание карточки ──────────────────────────────────── */
.ui-card__header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}

.ui-card__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-color);
}

.ui-card__desc {
  margin: 0;
  font-size: 0.9rem;
  color: color-mix(in srgb, var(--text-color), transparent 35%);
}

/* ── Поле формы (label + control + hint) ──────────────────────────── */
.ui-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ui-field__label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-color);
}

/* Единая подсказка под полем. Раньше сосуществовали .field-hint и
   .admin-form-hint с разными размерами/отступами — теперь один вид. */
.ui-field__hint,
.field-hint,
.admin-form-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  line-height: 1.4;
  color: color-mix(in srgb, var(--text-color), transparent 45%);
}

/* ── Поля ввода ───────────────────────────────────────────────────── */
/* Канонический вид совпадает с .admin-input. Сюда же подтянут .auth-input
   (страница входа), который раньше брал цвета из других токенов. */
.ui-input,
.ui-select,
.ui-textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--border-color), transparent 15%);
  padding: 14px 16px;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
  backdrop-filter: blur(6px);
}

.ui-textarea {
  min-height: 140px;
  resize: vertical;
}

.ui-select {
  appearance: none;
}

.ui-input:focus,
.ui-select:focus,
.ui-textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--primary-color), white 35%);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
  transform: translateY(-1px);
}

.ui-input:disabled,
.ui-select:disabled,
.ui-textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

html[data-theme="dark"] .ui-input,
html[data-theme="dark"] .ui-select,
html[data-theme="dark"] .ui-textarea {
  background: rgba(17, 24, 39, 0.7);
  color: var(--text-color);
}

/* Подтягиваем поле логина к единому виду. */
.auth-input {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid color-mix(in srgb, var(--border-color), transparent 15%);
}

html[data-theme="dark"] .auth-input {
  background: rgba(17, 24, 39, 0.7);
}

.auth-input:focus {
  border-color: color-mix(in srgb, var(--primary-color), white 35%);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
}

/* ── Кнопки ───────────────────────────────────────────────────────── */
/* База повторяет .admin-button из base.css. */
.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 15px;
  padding: 14px 24px;
  min-height: 48px;
  line-height: 1.1;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
  text-decoration: none;
  box-sizing: border-box;
}

.ui-btn--primary {
  background: #2563eb;
  color: #fff;
}

.ui-btn--primary:visited {
  color: #fff;
}

.ui-btn--primary:hover,
.ui-btn--primary:focus-visible {
  transform: translateY(-1px);
  background: #1d4ed8;
}

.ui-btn--secondary {
  background: rgba(148, 163, 184, 0.1);
  color: color-mix(in srgb, var(--text-color), transparent 10%);
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.ui-btn--secondary:hover,
.ui-btn--secondary:focus-visible {
  transform: translateY(-1px);
  background: rgba(148, 163, 184, 0.2);
}

.ui-btn--danger {
  background: #dc2626;
  color: #fff;
}

.ui-btn--danger:hover,
.ui-btn--danger:focus-visible {
  transform: translateY(-1px);
  background: #b91c1c;
}

.ui-btn--ghost {
  background: transparent;
  color: var(--text-color);
  border-color: color-mix(in srgb, var(--border-color), transparent 40%);
}

.ui-btn--ghost:hover,
.ui-btn--ghost:focus-visible {
  background: color-mix(in srgb, var(--border-color), transparent 85%);
}

.ui-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
}

.ui-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ── Секция (группа полей с заголовком) ───────────────────────────── */
.ui-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ui-section + .ui-section {
  margin-top: 24px;
}

/* ── Inline-чекбокс (например «Активен») ──────────────────────────── */
.ui-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-color);
  cursor: pointer;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--border-color), transparent 35%);
  border-radius: 14px;
}

.ui-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary-color);
  cursor: pointer;
}

/* ── Автопостинг: верхняя строка настроек ─────────────────────────── */
.autopost-settings-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

@media (max-width: 720px) {
  .autopost-settings-row {
    grid-template-columns: 1fr;
  }
}

/* ── Автопостинг: матрица «тип поста × день недели» ───────────────── */
.autopost-matrix-wrap {
  margin-top: 10px;
  overflow-x: auto;
}

.autopost-matrix {
  width: 100%;
  min-width: 420px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
}

.autopost-matrix th,
.autopost-matrix td {
  padding: 8px 6px;
  text-align: center;
}

.autopost-matrix thead th {
  font-size: 0.8rem;
  font-weight: 600;
  color: color-mix(in srgb, var(--text-color), transparent 35%);
  border-bottom: 1px solid color-mix(in srgb, var(--border-color), transparent 45%);
}

.autopost-matrix__corner {
  font-weight: 500;
  white-space: nowrap;
}

.autopost-matrix thead th:first-child,
.autopost-matrix tbody th {
  text-align: left;
}

.autopost-matrix tbody th {
  font-weight: 600;
  color: var(--text-color);
  white-space: nowrap;
  padding-right: 14px;
}

.autopost-matrix tbody tr + tr th,
.autopost-matrix tbody tr + tr td {
  border-top: 1px solid color-mix(in srgb, var(--border-color), transparent 60%);
}

.autopost-rowhint {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: color-mix(in srgb, var(--text-color), transparent 55%);
}

.autopost-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.autopost-cell:hover {
  background: color-mix(in srgb, var(--primary-color), transparent 88%);
}

.autopost-cell input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary-color);
  cursor: pointer;
}
