/* ============================================================
   main.css — Базовые стили, CSS-переменные, типографика
   Здесь задаём цвета (светлая/тёмная тема) и общую раскладку
   ============================================================ */

/* ─── CSS-переменные: светлая тема (по умолчанию) ─── */
:root {
  /* Цвета Telegram (перезаписываются из themeParams через telegram.js) */
  --tg-bg:           #ffffff;
  --tg-text:         #000000;
  --tg-hint:         #707579;
  --tg-link:         #2AABEE;
  --tg-button:       #2AABEE;
  --tg-button-text:  #ffffff;
  --tg-secondary-bg: #f1f1f1;

  /* Акцентный цвет приложения */
  --accent:          #2AABEE;
  --accent-light:    #e8f6fd;

  /* Цвета статусов */
  --status-confirm:  #31b545;
  --status-pending:  #f5a623;
  --status-cancel:   #9e9e9e;
  --status-danger:   #e53935;

  /* Типографика */
  --font:    -apple-system, 'SF Pro Display', 'Roboto', system-ui, sans-serif;
  --text-xs: 11px;
  --text-sm: 13px;
  --text-md: 15px;
  --text-lg: 17px;
  --text-xl: 20px;
  --text-2xl: 24px;

  /* Скругления */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
  --radius-full: 50%;

  /* Отступы */
  --gap-xs: 4px;
  --gap-sm: 8px;
  --gap-md: 12px;
  --gap-lg: 16px;
  --gap-xl: 20px;
  --gap-2xl: 24px;

  /* Тени */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.12);

  /* Высота tab bar */
  --tab-bar-h: 60px;

  /* Высота хедера экрана */
  --header-h: 56px;

  /* Минимальная область касания */
  --touch-target: 44px;
}

/* ─── Тёмная тема ─── */
[data-theme="dark"] {
  --tg-bg:           #212121;
  --tg-text:         #ffffff;
  --tg-hint:         #aaaaaa;
  --tg-link:         #2AABEE;
  --tg-button:       #2AABEE;
  --tg-button-text:  #ffffff;
  --tg-secondary-bg: #2c2c2e;
  --accent-light:    rgba(42, 171, 238, 0.15);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.5);
}

/* ─── Reset ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ─── База ─── */
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  font-size: var(--text-md);
  color: var(--tg-text);
  background: var(--tg-bg);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

/* ─── Контейнер приложения ─── */
#app {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--tg-bg);
}

/* ─── Область экрана (над tab bar) ─── */
#screens {
  position: relative;
  flex: 1;
  overflow: hidden;
}

/* ─── Скролл внутри экрана ─── */
.screen-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  /* Отступ снизу чтобы контент не уходил под tab bar */
  padding-bottom: calc(var(--tab-bar-h) + 8px);
}

/* ─── Заголовок экрана ─── */
.screen-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--tg-bg);
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 var(--gap-lg);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}

[data-theme="dark"] .screen-header {
  border-bottom-color: rgba(255,255,255,0.08);
}

.screen-header h1 {
  font-size: var(--text-lg);
  font-weight: 600;
  flex: 1;
}

/* ─── Секция с отступами ─── */
.section {
  padding: var(--gap-lg);
}

.section + .section {
  padding-top: 0;
}

/* ─── Заголовок секции ─── */
.section-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--tg-hint);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--gap-md);
}

/* ─── Горизонтальный скролл ─── */
.scroll-x {
  display: flex;
  gap: var(--gap-sm);
  overflow-x: auto;
  padding: var(--gap-xs) var(--gap-lg) var(--gap-xs);
  margin: 0 calc(-1 * var(--gap-lg));
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll-x::-webkit-scrollbar { display: none; }

/* ─── Разделитель ─── */
.divider {
  height: 1px;
  background: rgba(0,0,0,0.06);
  margin: var(--gap-md) 0;
}

[data-theme="dark"] .divider {
  background: rgba(255,255,255,0.08);
}

/* ─── Текстовые утилиты ─── */
.text-hint   { color: var(--tg-hint); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--status-danger); }
.text-sm     { font-size: var(--text-sm); }
.text-lg     { font-size: var(--text-lg); }
.text-xl     { font-size: var(--text-xl); }
.text-bold   { font-weight: 600; }
.text-center { text-align: center; }

/* ─── Stars (рейтинг) ─── */
.stars {
  color: #f5a623;
  font-size: var(--text-sm);
}

/* ─── Анимация пульса (skeleton loader) ─── */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ─── Анимация появления (checkmark на экране успеха) ─── */
@keyframes scale-in {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-scale-in {
  animation: scale-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.animate-fade-in {
  animation: fade-in 0.3s ease both;
}
