/* forge/static/css/site-base.css
 *
 * Ядерный header/nav/footer/admin-page стиль. Подключается из ядерного
 * `forge/templates/_base.html.tera` (через путь `/shared/css/site-base.css`).
 *
 * Все классы здесь — ядерные. Если проекту нужна доменная вёрстка
 * (например `.hero` главной, `.prv-block` карточки товара) — он живёт
 * в `<project>/static/css/site.css`. Здесь — никаких project-specific
 * правил.
 *
 * Зависимости — CSS-переменные ds-палитры из `/shared/css/tokens.css`
 * (либо локальное переопределение в проекте).
 */
/* ikru.me — структура и компоненты. Без иконок и эмодзи.
   Стартовая болванка — финальный дизайн делаем отдельной задачей. */

* { box-sizing: border-box; }



html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

/* Layout — без max-width, контент во всю ширину с боковыми padding'ами.
   "Ушей" нет: на широких экранах сайт растягивается полностью. */
.brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px var(--gutter);
  border-bottom: 1px solid var(--line);
}

.brand .mark {
  font-family: var(--font);
  font-size: 22px;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand .mark a:hover { text-decoration: none; }

/* индикатор живости WS-коннекта.
   data-ws-status выставляет bootstrap.js: on/off/connecting/reconnecting. */
.ws-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 200ms;
}
.ws-dot[data-ws-status="on"]           { background: var(--ds-success); }
.ws-dot[data-ws-status="off"]          { background: var(--ds-error); }
.ws-dot[data-ws-status="connecting"],
.ws-dot[data-ws-status="reconnecting"] {
  background: var(--ds-warn);
  animation: ws-pulse 1s infinite;
}
@keyframes ws-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav a {
  color: var(--muted);
}

/* ─── admin-nav: пункты меню в шапке + dropdown'ы для children ──────────── */

.nav--admin {
  gap: 4px;
  flex-wrap: wrap;
}

.nav-item {
  position: relative;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover {
  color: var(--fg);
  background: var(--line);
  text-decoration: none;
}
/* активный пункт (текущая страница) — охровый акцент, чтобы было видно где ты.
   Выставляется server-side (render::mark_active_menu → item.active). */
.nav-link.is-active {
  color: var(--ds-info, #d4af6a);
  font-weight: 600;
}
.nav-item.is-active > .nav-link {
  color: var(--ds-info, #d4af6a);
  font-weight: 600;
}

.nav-item--has-children > .nav-link::after {
  content: "▾";
  margin-left: 6px;
  font-size: 10px;
  opacity: 0.6;
}

.nav-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 180px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px;
  display: none;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  z-index: 20;
}
.nav-item:hover > .nav-dropdown,
.nav-item:focus-within > .nav-dropdown {
  display: flex;
}
.nav-link--child {
  padding: 6px 10px;
  font-size: 12px;
}

/* burger — скрыт на десктопе, виден на мобилке */
.nav-burger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 22px;
  height: 16px;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  margin-left: auto;
}
.nav-burger span {
  display: block;
  height: 2px;
  background: var(--fg);
  border-radius: 2px;
}

@media (max-width: 720px) {
  .nav-burger { display: inline-flex; }
  .nav--admin {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    display: none;
    margin-top: 12px;
  }
  .nav--admin.is-open { display: flex; }
  .nav-item--has-children > .nav-link::after { content: ""; }
  .nav-dropdown {
    position: static;
    border: 0;
    box-shadow: none;
    padding-left: 16px;
    display: flex;
  }
}

/* ─── Public header — site-меню в центре, actions справа ──────────────── */

.nav--site {
  flex: 1;
  gap: 16px;
}
.nav--site .nav-link {
  font-size: 14px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--radius);
  color: var(--fg);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease;
}
.header-action:hover {
  background: var(--line);
  text-decoration: none;
}
.header-action__label {
  font-size: 13px;
  white-space: nowrap;
}
/* Pulse при добавлении в корзину — basket-actions.js ставит .is-pulse
   на короткое время (~0.5s) после успешного basket_add. Visual-feedback
   взамен toast'а. */
@keyframes cart-pulse {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.header-action--cart.is-pulse {
  animation: cart-pulse 0.5s ease;
}

.header-action__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--ds-accent, #c8a04a);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

@media (max-width: 720px) {
  .header-action__label { display: none; }
  .nav--site { display: none; }
}

/* Опциональный переключатель темы. По умолчанию тема ставится автоматом
   по prefers-color-scheme — кнопку добавляем только если нужно дать юзеру
   ручной контроль. Любой элемент с [data-theme-toggle] будет работать.
   Базовые стили — через .foot-btn (рамка/padding/uppercase). Здесь только
   логика переключения текста: тёмная тема показывает "light", светлая — "dark". */
.theme-toggle .when-light { display: none; }
html.light .theme-toggle .when-dark  { display: none; }
html.light .theme-toggle .when-light { display: inline; }

/* Hero-блок — крупный заголовок страницы (главная сайта, /admin/, и т.п.).
   Generic, не доменный. Проектные доменные hero-варианты — .hero--*. */
.hero {
  padding: 80px var(--gutter);
}
.hero h1 {
  font-family: var(--font);
  font-weight: 400;
  font-size: 48px;
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}
.hero .lead {
  font-size: 18px;
  margin: 0 0 8px;
  max-width: 640px;
}
.hero .muted {
  color: var(--muted);
  margin-top: 24px;
}

.foot {
  padding: 32px var(--gutter);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.foot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.foot-title {
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
}

.dim {
  color: var(--muted);
}

.foot-spacer {
  flex: 1;
}

/* Кнопки футера (админка / выйти / тема) — единый стиль с рамкой.
   Текст-as-кнопка: маленький, uppercase, с рамкой, как theme-toggle. */
.foot-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  line-height: 1;
}

.foot-btn:hover {
  color: var(--fg);
  border-color: var(--fg);
  text-decoration: none;
}

.foot-btn .ds-btn__icon,
.foot-btn svg {
  width: 12px;
  height: 12px;
  display: inline-flex;
  align-items: center;
}

.link {
  border-bottom: 1px solid currentColor;
}

/* admin-page — shell для всех админ-страниц.
   Никакого max-width — контент во всю ширину. "Уши" не делаем по умолчанию,
   только если пользователь явно попросит. */
.admin-page {
  padding: 32px var(--gutter);
}

.admin-page__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-page__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-page__header h1 {
  font-family: var(--font);
  font-weight: 400;
  font-size: 28px;
  margin: 0;
}

/* «Назад» — ссылка в шапке admin_detail: иконка + текст, приглушённая,
   ярче на hover. Иконка и текст выровнены по центру. */
.admin-page__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: var(--ds-radius, 2px);
  transition: color .15s ease;
}
.admin-page__back:hover { color: var(--fg); }
.admin-page__back .ds-icon { flex: 0 0 auto; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

/* hover на строку — stylable: лёгкий tint фона + плавный fade-in actions.
   В обычном состоянии кнопки edit/trash полу-прозрачные; при hover на
   строку выходят в полный opacity. Это даёт «оживающую» строку как в
   GitHub/Notion-админках. */
.admin-table tbody tr {
  transition: background 0.15s ease;
}
.admin-table tbody tr:hover {
  background: var(--line);
}

/* Колонка действий (открыть/удалить) — выравнивание по правому краю строки. */
.admin-table__actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

/* Кнопки edit/delete в таблице — полу-прозрачные пока строка не в hover.
   text-decoration: none на случай если basis-стили проекта что-то рисуют
   на <a> по умолчанию. */
.admin-table__actions .ds-btn,
.admin-table__actions a.ds-btn {
  opacity: 0.4;
  transition: opacity 0.15s ease;
  text-decoration: none;
}
.admin-table__actions a.ds-btn:hover { text-decoration: none; }
.admin-table tbody tr:hover .admin-table__actions .ds-btn,
.admin-table tbody tr:hover .admin-table__actions a.ds-btn {
  opacity: 1;
}

.admin-table code {
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 13px;
  color: var(--accent);
}

/* Thumbnail-колонка в admin-таблицах: фиксированная ширина, центрирование. */
.admin-table__thumb-cell {
  width: 56px;
  padding: 6px 8px;
}
.admin-table__thumb {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--ds-radius, 4px);
  background: var(--ds-line, #f0f0f0);
}
.admin-table__thumb--empty {
  background: repeating-linear-gradient(
    45deg,
    var(--ds-line, #f0f0f0),
    var(--ds-line, #f0f0f0) 6px,
    transparent 6px,
    transparent 12px
  );
  opacity: 0.4;
}
