/* ============================================================
   Барбершоп — мини-приложение MAX
   Современный, простой дизайн. Тёмная тема.
   ============================================================ */

:root {
  --bg: #0f1115;
  --bg-card: #1a1d24;
  --bg-card-hover: #22262f;
  --bg-input: #15181e;
  --border: #2a2f3a;
  --text: #f5f6f8;
  --text-muted: #8b94a3;
  --text-dim: #5b6473;
  --accent: #e0b46a;        /* золотистый — фирменный барбершоп */
  --accent-hover: #ecc886;
  --accent-text: #1a1410;
  --success: #4ade80;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  --max-width: 520px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto',
    'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#app {
  max-width: var(--max-width);
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Шапка экрана
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
}

.topbar .back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.topbar .spacer {
  width: 32px;
}

/* ============================================================
   Кнопки
   ============================================================ */

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s;
  font-family: inherit;
  text-decoration: none;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  background: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.btn-ghost:hover { background: rgba(224, 180, 106, 0.1); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.1); }

.btn-sm {
  padding: 8px 14px;
  font-size: 14px;
  width: auto;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Карточки
   ============================================================ */

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.card-selectable {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid transparent;
}
.card-selectable:hover { background: var(--bg-card-hover); }
.card-selectable.selected {
  border-color: var(--accent);
  background: rgba(224, 180, 106, 0.08);
}

/* ============================================================
   Главный экран
   ============================================================ */

.hero {
  text-align: center;
  padding: 28px 20px 8px;
}

.hero .logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #b88a4a);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  box-shadow: 0 8px 24px rgba(224, 180, 106, 0.3);
}

.hero h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero .subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

.info-block {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
}

.info-row .icon {
  font-size: 18px;
  width: 24px;
  flex-shrink: 0;
  text-align: center;
}

.info-row .label {
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.info-row .value {
  color: var(--text);
}

/* ============================================================
   Списки выбора (услуги, мастера, дни)
   ============================================================ */

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 8px 4px 4px;
}

.list-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 12px;
}
.list-item:hover { background: var(--bg-card-hover); }
.list-item.selected {
  border-color: var(--accent);
  background: rgba(224, 180, 106, 0.08);
}

.list-item .li-body { flex: 1; min-width: 0; }
.list-item .li-title {
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 2px;
}
.list-item .li-sub {
  color: var(--text-muted);
  font-size: 13px;
}
.list-item .li-meta {
  text-align: right;
  flex-shrink: 0;
}
.list-item .li-price {
  font-weight: 700;
  color: var(--accent);
  font-size: 16px;
}
.list-item .li-duration {
  color: var(--text-muted);
  font-size: 12px;
}

/* ============================================================
   Сетка слотов времени
   ============================================================ */

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.slot {
  padding: 12px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.slot:hover:not(.disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent);
}
.slot.selected {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.slot.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  text-decoration: line-through;
}

/* ============================================================
   Дни (горизонтальная лента)
   ============================================================ */

.days-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.days-scroll::-webkit-scrollbar { height: 4px; }
.days-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.day-pill {
  flex-shrink: 0;
  min-width: 78px;
  padding: 12px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.day-pill:hover { border-color: var(--accent); }
.day-pill.selected {
  background: var(--accent);
  color: var(--accent-text);
  border-color: var(--accent);
}
.day-pill .dp-day {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.day-pill.selected .dp-day { color: var(--accent-text); opacity: 0.8; }
.day-pill .dp-date {
  font-size: 16px;
  font-weight: 700;
}

/* ============================================================
   Формы / инпуты
   ============================================================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.input, textarea.input, select.input {
  width: 100%;
  padding: 13px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  transition: border-color 0.15s;
}

.input:focus, textarea.input:focus, select.input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

.input-row {
  display: flex;
  gap: 8px;
}
.input-row .input { flex: 1; }

/* ============================================================
   Сводка записи
   ============================================================ */

.summary {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  border: 1px solid var(--border);
}

.summary h3 {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .sr-label { color: var(--text-muted); }
.summary-row .sr-value { font-weight: 600; text-align: right; }
.summary-row.total {
  padding-top: 14px;
  margin-top: 6px;
  border-top: 2px solid var(--accent);
  border-bottom: none;
}
.summary-row.total .sr-value {
  color: var(--accent);
  font-size: 18px;
}

/* ============================================================
   Капча
   ============================================================ */

.captcha-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}
.captcha-box .captcha-q {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}
.captcha-box .captcha-input {
  width: 100px;
  margin: 0 auto;
  text-align: center;
  font-size: 20px;
  font-weight: 700;
}

/* ============================================================
   Статусы записей
   ============================================================ */

.booking-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 3px solid var(--accent);
}
.booking-card.done { border-left-color: var(--text-dim); opacity: 0.7; }
.booking-card.cancelled { border-left-color: var(--danger); opacity: 0.6; }
.booking-card.no_show { border-left-color: var(--warning); opacity: 0.7; }

.booking-card .bc-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.booking-card .bc-service {
  font-weight: 700;
  font-size: 16px;
}
.booking-card .bc-status {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 8px;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.bc-status.planned { background: rgba(224, 180, 106, 0.15); color: var(--accent); }
.bc-status.done { background: rgba(74, 222, 128, 0.15); color: var(--success); }
.bc-status.cancelled { background: rgba(248, 113, 113, 0.15); color: var(--danger); }
.bc-status.no_show { background: rgba(251, 191, 36, 0.15); color: var(--warning); }

.booking-card .bc-info {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.booking-card .bc-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  color: var(--text);
  padding: 14px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 1000;
  font-size: 14px;
  max-width: calc(100% - 32px);
  text-align: center;
  border: 1px solid var(--border);
  animation: toastIn 0.25s ease;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.hidden { display: none; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ============================================================
   Загрузчик
   ============================================================ */

.loader {
  position: fixed;
  inset: 0;
  background: rgba(15, 17, 21, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  backdrop-filter: blur(2px);
}
.loader.hidden { display: none; }

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Пустое состояние
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .es-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.empty-state .es-text {
  font-size: 15px;
}

/* ============================================================
   Шаги записи
   ============================================================ */

.steps {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0 8px;
}
.step-dot {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  transition: background 0.2s;
}
.step-dot.active { background: var(--accent); }
.step-dot.done { background: var(--success); }

/* ============================================================
   Админ-панель: табы
   ============================================================ */

.tabs {
  display: flex;
  gap: 6px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.tab {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.tab.active {
  background: var(--bg-card);
  color: var(--accent);
}

/* Админ: строка таблицы с действиями */
.admin-item {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-item .ai-body { flex: 1; min-width: 0; }
.admin-item .ai-title { font-weight: 600; font-size: 15px; }
.admin-item .ai-sub { color: var(--text-muted); font-size: 13px; }
.admin-item .ai-actions { display: flex; gap: 6px; flex-shrink: 0; }

.icon-btn {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--bg-card-hover); }
.icon-btn.danger { color: var(--danger); }
.icon-btn.danger:hover { background: rgba(248, 113, 113, 0.1); }

/* ============================================================
   Утилиты
   ============================================================ */

.hidden { display: none !important; }
.text-center { text-align: center; }
.muted { color: var(--text-muted); }
.mb-8 { margin-bottom: 8px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }

.bottom-actions {
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  padding: 16px 0 calc(8px + env(safe-area-inset-bottom));
  margin-top: auto;
}

/* Десктоп: ограничиваем ширину и центрируем */
@media (min-width: 768px) {
  body { padding-top: 24px; }
}
