/* =====================================================
   EventApp — базовые стили и дизайн-токены
   Mobile-first, CSS custom properties
   ===================================================== */

/* ----- Токены темы (переопределяются из theme.js) ----- */
:root {
  --color-primary:    #6366f1;
  --color-primary-dk: #4f46e5;
  --color-secondary:  #06b6d4;
  --color-accent:     #f59e0b;

  --color-bg:         #0f172a;
  --color-bg-card:    #1e293b;
  --color-bg-input:   #273549;
  --color-border:     #334155;

  --color-text:       #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-text-inv:   #0f172a;

  --color-success:    #22c55e;
  --color-warning:    #f59e0b;
  --color-error:      #ef4444;

  --radius-sm:  0.375rem;
  --radius-md:  0.75rem;
  --radius-lg:  1.25rem;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 12px rgba(0,0,0,.5);
  --shadow-lg:  0 8px 24px rgba(0,0,0,.6);

  --font-sans:  'Inter', system-ui, sans-serif;
  --font-size-xs:   0.75rem;
  --font-size-sm:   0.875rem;
  --font-size-base: 1rem;
  --font-size-lg:   1.125rem;
  --font-size-xl:   1.25rem;
  --font-size-2xl:  1.5rem;
  --font-size-3xl:  1.875rem;

  /* Отступ под нижний навбар */
  --nav-h: 64px;
}

/* ----- Сброс и базовые настройки ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  padding-bottom: var(--nav-h);
  -webkit-font-smoothing: antialiased;
}

/* Страницы без нижней навигации */
body.no-nav { padding-bottom: 0; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

ul, ol { list-style: none; }

/* ----- Типографика ----- */
h1 { font-size: var(--font-size-2xl); font-weight: 700; line-height: 1.2; }
h2 { font-size: var(--font-size-xl);  font-weight: 700; line-height: 1.3; }
h3 { font-size: var(--font-size-lg);  font-weight: 600; line-height: 1.4; }
h4 { font-size: var(--font-size-base); font-weight: 600; }

p  { line-height: 1.6; }

.text-muted  { color: var(--color-text-muted); font-size: var(--font-size-sm); }
.text-sm     { font-size: var(--font-size-sm); }
.text-xs     { font-size: var(--font-size-xs); }
.text-center { text-align: center; }

/* ----- Контейнер ----- */
.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ----- Сетка ----- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }

@media (max-width: 400px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}

/* ----- Flex-утилиты ----- */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1  { gap: 0.25rem; }
.gap-2  { gap: 0.5rem; }
.gap-3  { gap: 0.75rem; }
.gap-4  { gap: 1rem; }

/* ----- Отступы ----- */
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

/* ----- Карточка ----- */
.card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

.card-link {
  display: block;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--color-text);
  transition: border-color .15s, transform .15s;
}
.card-link:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  text-decoration: none;
}

/* ----- Кнопки ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
  line-height: 1;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dk); text-decoration: none; }

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

.btn-ghost {
  background: transparent;
  color: var(--color-text-muted);
}
.btn-ghost:hover { color: var(--color-text); text-decoration: none; }

.btn-danger {
  background: var(--color-error);
  color: #fff;
}

.btn-sm { padding: 0.375rem 0.75rem; font-size: var(--font-size-xs); }
.btn-full { width: 100%; }

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ----- Формы ----- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

label { font-size: var(--font-size-sm); font-weight: 500; color: var(--color-text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--font-size-base);
  font-family: var(--font-sans);
  transition: border-color .15s;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--color-primary); }

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

/* Toggle (checkbox-флаг) */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}
.toggle-wrap input[type="checkbox"] { display: none; }
.toggle {
  width: 2.5rem; height: 1.375rem;
  background: var(--color-border);
  border-radius: var(--radius-full);
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 1rem; height: 1rem;
  background: #fff;
  border-radius: 50%;
  transition: left .2s;
}
.toggle-wrap input:checked + .toggle { background: var(--color-primary); }
.toggle-wrap input:checked + .toggle::after { left: calc(100% - 1.125rem); }

/* ----- Шапка страницы ----- */
.page-header {
  padding: 1.25rem 1rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.page-header h1 { flex: 1; font-size: var(--font-size-xl); }
.page-header .back-btn { color: var(--color-text-muted); font-size: 1.25rem; }

/* ----- Нижняя навигация ----- */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--color-bg-card);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
  font-weight: 500;
  text-decoration: none;
  transition: color .15s;
  position: relative;
}
.nav-item:hover { text-decoration: none; }
.nav-item.active { color: var(--color-primary); }

.nav-item svg { width: 1.375rem; height: 1.375rem; }

/* Бейдж на иконке */
.nav-badge {
  position: absolute;
  top: 0.25rem; right: calc(50% - 1.375rem);
  min-width: 1rem; height: 1rem;
  background: var(--color-error);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  display: flex; align-items: center; justify-content: center;
  padding: 0 0.2rem;
}

/* ----- Бейджи и чипы ----- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 600;
  background: var(--color-bg-input);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}
.badge-primary { background: color-mix(in srgb, var(--color-primary) 20%, transparent); color: var(--color-primary); border-color: transparent; }
.badge-success { background: color-mix(in srgb, var(--color-success) 20%, transparent); color: var(--color-success); border-color: transparent; }
.badge-warning { background: color-mix(in srgb, var(--color-warning) 20%, transparent); color: var(--color-warning); border-color: transparent; }
.badge-error   { background: color-mix(in srgb, var(--color-error)   20%, transparent); color: var(--color-error);   border-color: transparent; }

/* ----- Алёрты ----- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  margin-bottom: 1rem;
}
.alert-error   { background: color-mix(in srgb, var(--color-error) 15%, transparent); border: 1px solid var(--color-error); color: var(--color-error); }
.alert-success { background: color-mix(in srgb, var(--color-success) 15%, transparent); border: 1px solid var(--color-success); color: var(--color-success); }
.alert-info    { background: color-mix(in srgb, var(--color-primary) 15%, transparent); border: 1px solid var(--color-primary); color: var(--color-primary); }

/* ----- Скелетон / загрузка ----- */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg-card) 25%, var(--color-bg-input) 50%, var(--color-bg-card) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
@keyframes skeleton-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.loading-spinner {
  width: 2rem; height: 2rem;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- Список элементов ----- */
.list-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--color-border);
}
.list-item:last-child { border-bottom: none; }

/* ----- Аватар ----- */
.avatar {
  width: 2.5rem; height: 2.5rem;
  border-radius: 50%;
  background: var(--color-bg-input);
  object-fit: cover;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--font-size-sm);
  color: var(--color-primary);
}
.avatar-lg { width: 4rem; height: 4rem; font-size: var(--font-size-lg); }

/* ----- Цветная полоска трека ----- */
.track-dot {
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ----- Баланс баллов ----- */
.points-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 40%, transparent);
  color: var(--color-accent);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: 700;
}

/* ----- Вкладки (tabs) ----- */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  padding: 0.625rem 1rem;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  border-top: none; border-left: none; border-right: none;
  transition: color .15s, border-color .15s;
}
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }
.tab:hover  { color: var(--color-text); }

/* ----- Поиск ----- */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  gap: 0.5rem;
}
.search-bar input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--color-text);
  font-size: var(--font-size-sm);
  width: 100%;
  padding: 0;
}
.search-bar svg { color: var(--color-text-muted); flex-shrink: 0; width: 1rem; height: 1rem; }

/* ----- Пустое состояние ----- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--color-text-muted);
}
.empty-state svg { width: 3rem; height: 3rem; margin: 0 auto 1rem; opacity: .4; }

/* ----- Модальный диалог ----- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--color-bg-card);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1.5rem 1rem 2rem;
  width: 100%;
  max-width: 640px;
  transform: translateY(2rem);
  transition: transform .25s;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal-handle {
  width: 2.5rem; height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: 0 auto 1.25rem;
}
.modal h2 { font-size: var(--font-size-xl); margin-bottom: 1rem; }

/* ----- Код-пинблок (инвайт-код) ----- */
.code-display {
  text-align: center;
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.3em;
  color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 10%, transparent);
  border: 2px dashed color-mix(in srgb, var(--color-primary) 40%, transparent);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 1rem 0;
}

/* ----- Страница входа ----- */
.auth-page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem 1.5rem;
}
.auth-logo {
  font-size: var(--font-size-3xl);
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}

/* ----- Горизонтальный скролл карточек ----- */
.cards-scroll {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cards-scroll::-webkit-scrollbar { display: none; }
.cards-scroll .card-link { flex-shrink: 0; width: 200px; }

/* ----- Разделитель ----- */
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 1rem 0;
}

/* ----- Скрытие/показ ----- */
.hidden { display: none !important; }

/* ----- Секция ----- */
.section { padding: 1rem; }
.section + .section { padding-top: 0; }
.section-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

/* ----- Плашка события (hero) ----- */
.event-hero {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  padding: 1.5rem 1rem;
  color: #fff;
}
.event-hero h1 { color: #fff; font-size: var(--font-size-2xl); }
.event-hero p  { color: rgba(255,255,255,.8); font-size: var(--font-size-sm); margin-top: 0.25rem; }

/* ----- QR-блок ----- */
.qr-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.5rem;
  background: #fff;
  border-radius: var(--radius-md);
  color: #000;
}
.qr-block canvas, .qr-block img { width: 180px; height: 180px; }

/* ----- Таймлайн расписания ----- */
.talk-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem;
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--color-primary);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.talk-card:hover { transform: translateX(2px); }
.talk-time {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  min-width: 4.5rem;
  padding-top: 0.125rem;
}
.talk-info { flex: 1; min-width: 0; }
.talk-title { font-weight: 600; font-size: var(--font-size-sm); }
.talk-speakers { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 0.25rem; }

/* ----- Партнёры ----- */
.partner-tier-title {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--color-text-muted);
  font-weight: 700;
  padding: 0.5rem 0 0.25rem;
}
.partner-logo {
  width: 100%;
  height: 80px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: .85;
}

/* ----- Мерч ----- */
.merch-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--color-bg-input);
}

/* ----- Карта ----- */
#map-container {
  width: 100%;
  overflow: auto;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y pinch-zoom;
}
#map-container svg {
  min-width: 600px;
  cursor: pointer;
}
.map-zone { cursor: pointer; transition: opacity .15s; }
.map-zone:hover { opacity: .75; }

/* ----- Транзакции ----- */
.tx-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border);
}
.tx-row:last-child { border-bottom: none; }
.tx-icon {
  width: 2rem; height: 2rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 0.875rem;
}
.tx-earn  { background: color-mix(in srgb, var(--color-success) 15%, transparent); color: var(--color-success); }
.tx-spend { background: color-mix(in srgb, var(--color-error) 15%, transparent);   color: var(--color-error); }
.tx-amount { margin-left: auto; font-weight: 700; }
.tx-amount.earn  { color: var(--color-success); }
.tx-amount.spend { color: var(--color-error); }

/* ----- Уведомления ----- */
.notif-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.875rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
  border: 1px solid var(--color-border);
}
.notif-item.unread { border-color: var(--color-primary); }
.notif-dot {
  width: 0.5rem; height: 0.5rem;
  border-radius: 50%;
  background: var(--color-primary);
  flex-shrink: 0;
  margin-top: 0.375rem;
}

/* ----- Встречи ----- */
.meeting-card {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  margin-bottom: 0.5rem;
}
.meeting-actions { display: flex; gap: 0.5rem; margin-top: 0.75rem; }

/* ----- Desktop-адаптация (больше 640px просто центрируем) ----- */
@media (min-width: 640px) {
  .bottom-nav { max-width: 640px; left: 50%; transform: translateX(-50%); border-radius: var(--radius-md) var(--radius-md) 0 0; }
}
