/* Файл: static/app.css */
/* Участвует в: index.html, products.html, services.html, distribution.html (+ их css/js), app.js (разметка меню) */
/* Назначение: общий дизайн-каркас приложения — токены цветов, 3 версии интерфейса:
   >1024px — боковое меню с текстом; 768–1024px — меню сжато до иконок; <768px — нижняя панель вкладок,
   таблицы превращаются в карточки, все элементы управления ≥44px. Брейкпоинты: 1024px и 768px. */

:root {
  --ink: #2B2E33; --ink-soft: #4A4E57;
  --ivory: #F7F4EF; --ivory-deep: #EFEAE1;
  --bronze: #B08D57; --bronze-deep: #8E7040;
  --burgundy: #5C2430; --red: #B3303F; --line: #DCD5C8; --white: #FFFFFF;
  --danger: #A83A3A; --success: #3A7D5C; --radius: 12px;
  --shadow: 0 2px 14px rgba(43,46,51,0.08);
  --shadow-lg: 0 8px 28px rgba(43,46,51,0.14);
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --nav-w: 232px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); background: var(--ivory); color: var(--ink); -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

/* ===== Каркас: боковое меню + контент ===== */
.app-shell { display: flex; min-height: 100vh; }
.app-nav { width: var(--nav-w); background: var(--ink); color: var(--ivory); flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 18px 0; z-index: 60; }
.app-nav__brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 18px; padding: 0 20px 18px; border-bottom: 1px solid rgba(247,244,239,0.15); margin-bottom: 10px; }
.flame { width: 9px; height: 9px; background: var(--bronze); transform: rotate(45deg); border-radius: 2px; flex-shrink: 0; }
.app-nav__item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; font-size: 14px; color: rgba(247,244,239,0.72); border-left: 3px solid transparent; position: relative; min-height: 44px; }
.app-nav__item:hover { background: rgba(247,244,239,0.06); }
.app-nav__item.active { color: var(--ivory); border-left-color: var(--bronze); background: rgba(176,141,87,0.14); }
.lbl-short { display: none; }
.app-nav__icon { font-size: 19px; width: 24px; text-align: center; flex-shrink: 0; }
.app-nav__spacer { flex: 1; }
.app-nav__foot { padding: 12px 20px; font-size: 12px; color: rgba(247,244,239,0.45); }
.nav-badge { position: absolute; top: 6px; left: 34px; background: var(--red); color: var(--white); font-size: 10px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; display: none; align-items: center; justify-content: center; }
.nav-badge.show { display: flex; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--white); border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 50; }
.topbar__title { font-family: var(--font-display); font-size: 22px; flex-shrink: 0; }
.topbar__spacer { flex: 1; }
.offline-badge { font-size: 11px; background: var(--danger); color: var(--white); padding: 3px 10px; border-radius: 20px; display: none; white-space: nowrap; }
.offline-badge.show { display: inline-block; }
.page { padding: 20px 24px 40px; max-width: 1280px; width: 100%; margin: 0 auto; }

/* ===== Поля и кнопки ===== */
.form-input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; background: var(--white); min-height: 44px; }
.form-input:focus { outline: 2px solid var(--bronze); outline-offset: 1px; }
.form-label { font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; display: block; }
.form-field { margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 44px; transition: background .15s, transform .1s; text-align: center; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--ink); color: var(--ivory); }
.btn-primary:hover { background: #3a3e45; }
.btn-accent { background: var(--red); color: var(--white); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-block { display: flex; width: 100%; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn-sm { padding: 7px 14px; font-size: 13px; min-height: 36px; }
.search-box { position: relative; flex: 1; max-width: 420px; }
.search-box input { padding-left: 38px; }
.search-box::before { content: "🔍"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; opacity: .6; pointer-events: none; }

/* ===== Чипы фильтров (красная обводка, как в приложении клиента) ===== */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { padding: 8px 14px; border: 1px solid var(--red); border-radius: 8px; background: var(--white); color: var(--red); font-size: 13px; cursor: pointer; min-height: 38px; display: inline-flex; align-items: center; transition: background .15s, color .15s; }
.chip:hover { background: #FBEFF0; }
.chip.active { background: var(--red); color: var(--white); }
.chip--reset { border-color: var(--ink-soft); color: var(--ink-soft); }
.chip--price { border-color: var(--bronze-deep); color: var(--bronze-deep); }
.chip--price.active { background: var(--bronze-deep); color: var(--white); }

/* ===== Пагинация со стрелками ===== */
.pagination { display: flex; justify-content: center; align-items: center; gap: 16px; padding: 22px 0 6px; }
.page-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--white); font-size: 18px; color: var(--ink); cursor: pointer; }
.page-btn:disabled { opacity: 0.35; cursor: default; }
.page-info { font-size: 13px; color: var(--ink-soft); min-width: 90px; text-align: center; }

/* ===== Шестиугольная иконка (как в приложении клиента) ===== */
.hex { width: 56px; height: 62px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; background: var(--white); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); position: relative; }
.hex::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, var(--red), var(--bronze)); z-index: 0; }
.hex__in { position: relative; z-index: 1; width: calc(100% - 4px); height: calc(100% - 4px); background: var(--white); clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%); display: flex; align-items: center; justify-content: center; }

/* ===== Карточки списка ===== */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); }
.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-soft); }
.empty-state .flame { margin: 0 auto 14px; width: 12px; height: 12px; }
.loader { text-align: center; padding: 40px 0; color: var(--ink-soft); font-size: 13px; }

/* ===== Модалки ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(43,46,51,0.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal-sheet { background: var(--ivory); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; border-radius: 16px; padding: 24px; position: relative; box-shadow: var(--shadow-lg); }
.close-x { position: absolute; top: 12px; right: 12px; width: 44px; height: 44px; border-radius: 50%; background: var(--white); border: none; font-size: 16px; cursor: pointer; }
.modal-title { font-family: var(--font-display); font-size: 20px; margin-bottom: 16px; padding-right: 44px; }
.warning-box { background: #FBF3E7; border: 1px solid var(--bronze); border-radius: 10px; padding: 10px 12px; font-size: 12px; color: var(--ink-soft); margin-bottom: 14px; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }
.btn-row .btn { flex: 1; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--ivory); padding: 12px 20px; border-radius: 24px; font-size: 13px; z-index: 300; box-shadow: var(--shadow-lg); max-width: 90%; text-align: center; animation: toast-in .2s ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ===== Таблицы: на телефоне превращаются в карточки «подпись: значение» ===== */
.data-table { width: 100%; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); border-collapse: collapse; overflow: hidden; }
.data-table th { text-align: left; padding: 11px 14px; font-size: 12px; color: var(--ink-soft); background: var(--ivory-deep); }
.data-table td { padding: 11px 14px; font-size: 13px; border-top: 1px solid var(--line); vertical-align: middle; }
.status-badge { font-size: 11px; padding: 4px 10px; border-radius: 12px; font-weight: 600; white-space: nowrap; }
.status-new { background: #E9F0FF; color: #2E5AA8; }
.status-processing { background: #FBF3E7; color: var(--bronze-deep); }
.status-confirmed, .status-paid { background: #E7F4EC; color: var(--success); }
.status-cancelled { background: #FAEBEB; color: var(--danger); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ================= ПЛАНШЕТ (768–1024px): меню сжато до иконок ================= */
@media (max-width: 1024px) {
  :root { --nav-w: 68px; }
  .app-nav__brand span:last-child, .app-nav__label, .app-nav__foot { display: none; }
  .lbl-short { display: none; }
  .app-nav__brand { justify-content: center; padding: 0 0 16px; }
  .app-nav__item { justify-content: center; padding: 12px 0; border-left-width: 0; border-bottom: 0; }
  .app-nav__item.active { box-shadow: inset 3px 0 0 var(--bronze); }
  .nav-badge { left: auto; right: 12px; }
  .page { padding: 18px 18px 36px; }
  .topbar { padding: 10px 18px; }
}

/* ================= ТЕЛЕФОН (<768px): нижняя панель вкладок ================= */
@media (max-width: 768px) {
  body { padding-bottom: 72px; }
  .app-shell { display: block; }
  .app-nav { position: fixed; top: auto; bottom: 0; left: 0; right: 0; width: 100%; height: 64px; flex-direction: row; padding: 0 0 env(safe-area-inset-bottom); box-shadow: 0 -4px 18px rgba(0,0,0,.18); }
  .app-nav__brand, .app-nav__spacer, .app-nav__foot, .app-nav__item--desktop-only { display: none; }
  .app-nav__item { flex: 1; flex-direction: column; justify-content: center; gap: 2px; padding: 6px 0; font-size: 10px; border-left: 0; min-width: 44px; }
  .app-nav__item.active { box-shadow: inset 0 3px 0 var(--bronze); background: rgba(176,141,87,0.14); }
  .app-nav__label { display: block; text-align: center; }
  .lbl-long { display: none; }
  .lbl-short { display: block; }
  .app-nav__icon { font-size: 20px; }
  .nav-badge { top: 4px; left: 50%; right: auto; margin-left: 6px; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar__title { font-size: 19px; }
  .search-box { max-width: none; flex-basis: 100%; order: 5; }
  .page { padding: 14px 14px 28px; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-sheet { max-width: 100%; border-radius: 18px 18px 0 0; max-height: 92vh; }
  .toast { bottom: 84px; }

  /* таблицы → карточки */
  .data-table, .data-table thead, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table thead { display: none; }
  .data-table { background: transparent; box-shadow: none; }
  .data-table tr { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 12px; padding: 6px 0; }
  .data-table td { border-top: 0; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 14px; text-align: right; }
  .data-table td::before { content: attr(data-label); color: var(--ink-soft); font-size: 12px; text-align: left; flex-shrink: 0; }
  .data-table td[data-label=""]::before { display: none; }
}
