/* GeoAtlas — единая дизайн-система (tokens -> компоненты -> раскладка) */

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --accent: #4169e1;
  --accent-hover: #3558c7;
  --accent-soft: rgba(65, 105, 225, 0.12);
  --on-accent: #ffffff;

  --tone-blue: #4169e1;
  --tone-orange: #f08c00;
  --tone-violet: #8e44ad;
  --tone-teal: #0f9d8f;
  --tone-red: #e5484d;
  --tone-indigo: #5b5bd6;
  --tone-green: #2f9e44;

  --star: #f5a524;

  --radius-s: 8px;
  --radius-m: 12px;
  --radius-l: 16px;

  --rail-w: 64px;
  --panel-w: 360px;

  --t-fast: 120ms ease;
}

[data-theme="light"] {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f2f3f5;
  --surface-3: #e8eaee;
  --rail-bg: #f7f8fa;
  --text: #1c1d1f;
  --text-2: #5f6368;
  --text-3: #8a8f98;
  --divider: #eceef1;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.08), 0 2px 8px rgba(16, 24, 40, 0.08);
  --scroll-thumb: #c9ccd2;
}

[data-theme="dark"] {
  --bg: #16181d;
  --surface: #1c1f25;
  --surface-2: #262a31;
  --surface-3: #30353d;
  --rail-bg: #16181d;
  --text: #eceef1;
  --text-2: #a5abb5;
  --text-3: #7b818c;
  --divider: #2a2e35;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.35);
  --scroll-thumb: #3a3f48;
  --accent-soft: rgba(110, 145, 255, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
svg { fill: currentColor; }
.hidden { display: none !important; }
.muted { color: var(--text-3); font-weight: 400; }

/* Минималистичный скроллбар */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 3px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Раскладка ---------- */
.app-shell { position: fixed; inset: 0; }
.map-canvas { position: absolute; inset: 0; }
.poi-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }

/* ---------- Рейл ---------- */
.rail {
  position: absolute; top: 0; left: 0; bottom: 0; z-index: 12;
  width: var(--rail-w);
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 12px 0;
  background: var(--rail-bg);
}
.rail-logo {
  width: 40px; height: 40px; margin-bottom: 8px;
  display: grid; place-items: center;
  border-radius: var(--radius-m);
  background: var(--accent); color: var(--on-accent);
}
.rail-logo svg { width: 22px; height: 22px; }
.rail-item {
  width: 56px; padding: 6px 0;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border-radius: var(--radius-m);
  color: var(--text-2); font-size: 10.5px; line-height: 1.2;
  transition: background var(--t-fast), color var(--t-fast);
}
.rail-item svg { width: 22px; height: 22px; }
.rail-item:hover { background: var(--surface-2); color: var(--text); }
.rail-item.active { color: var(--accent); }
.rail-lang { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.rail-spacer { flex: 1; }

/* ---------- Панель ---------- */
.panel {
  position: absolute; top: 0; bottom: 0; left: var(--rail-w); z-index: 11;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: transform 200ms ease;
}
.panel.collapsed { transform: translateX(calc(-100% - var(--rail-w))); }
.panel.collapsed .panel-edge { transform: translateX(var(--rail-w)) rotate(180deg); }

/* ---------- Плавающая кнопка поиска (внизу экрана при скрытой панели) ---------- */
.floating-search-pill {
  position: absolute;
  bottom: 18px;
  left: calc(var(--rail-w) + 18px);
  z-index: 15;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 20px 0 14px;
  background: var(--surface);
  color: var(--text-2);
  border-radius: 23px;
  box-shadow: 0 4px 18px rgba(16, 24, 40, 0.18);
  font-size: 14px;
  font-weight: 500;
  transition: transform 180ms ease, background var(--t-fast), color var(--t-fast);
}
.floating-search-pill svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
  flex: none;
}
.floating-search-pill:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Полное скрытие любых значков копирайта/атрибуции движка */
[class*="copyright"] {
  display: none !important;
}

.panel-edge {
  position: absolute; top: 16px; right: -28px;
  width: 28px; height: 44px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text-2);
  border-radius: 0 var(--radius-s) var(--radius-s) 0;
  box-shadow: var(--shadow);
  transition: transform 200ms ease;
}
.panel-edge svg { width: 18px; height: 18px; }
.panel-edge:hover { color: var(--text); }

.panel-head { padding: 14px 16px 4px; }

.search-field {
  display: flex; align-items: center; gap: 8px;
  height: 44px; padding: 0 6px 0 14px;
  background: var(--surface-2);
  border-radius: var(--radius-m);
  transition: background var(--t-fast), box-shadow var(--t-fast);
}
.search-field:focus-within { background: var(--surface); box-shadow: 0 0 0 2px var(--accent); }
.search-icon { width: 20px; height: 20px; color: var(--text-3); flex: none; }
.search-input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: none; background: transparent;
  font: inherit; font-size: 15px; color: var(--text);
}
.search-input::placeholder { color: var(--text-3); }
.search-input::-webkit-search-cancel-button { display: none; }

.icon-btn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; color: var(--text-2);
  transition: background var(--t-fast);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- MySelect (город) и шапка ---------- */
.sheet-grabber { display: none; }
.city-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 10px;
}
.mobile-quick-actions { display: none; align-items: center; gap: 6px; }
.mob-chip-btn {
  height: 32px; min-width: 32px; padding: 0 10px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: var(--surface-2); color: var(--text-2);
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  transition: background var(--t-fast), color var(--t-fast);
}
.mob-chip-btn svg { width: 16px; height: 16px; transition: transform 200ms ease; }
.mob-chip-btn.peek-mode svg { transform: rotate(180deg); }
.mob-chip-btn:hover { background: var(--surface-3); color: var(--text); }

.my-select { position: relative; }
.city-title {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 4px 6px 4px 2px; border-radius: var(--radius-s);
  font-size: 20px; font-weight: 600;
}
.city-title:hover { background: var(--surface-2); }
.chevron { width: 22px; height: 22px; color: var(--text-3); transition: transform var(--t-fast); }
.city-title[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.my-select-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  width: 100%; max-height: 60vh; overflow-y: auto;
  padding: 6px;
  background: var(--surface);
  border-radius: var(--radius-m);
  box-shadow: 0 8px 28px rgba(16, 24, 40, 0.18);
}
.my-select-group-title {
  padding: 10px 10px 4px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--text-3);
}
.my-select-option {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 9px 10px; border-radius: var(--radius-s); text-align: left;
}
.my-select-option:hover { background: var(--surface-2); }
.my-select-option.active { color: var(--accent); font-weight: 600; }
.my-select-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--tone-green); }

/* ---------- Прокручиваемые области ---------- */
.panel-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* ---------- Рубрики (круглые иконки) ---------- */
.rubrics {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 6px 4px; padding: 10px 10px 4px;
}
.rubric {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px 2px; border-radius: var(--radius-m);
  transition: background var(--t-fast);
}
.rubric:hover { background: var(--surface-2); }
.rubric-icon {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 12%, transparent);
  transition: background var(--t-fast), color var(--t-fast);
}
.rubric-icon svg { width: 24px; height: 24px; }
.rubric-label { font-size: 12px; line-height: 1.25; color: var(--text-2); text-align: center; }
.rubric.active .rubric-icon { background: var(--tone); color: #fff; }
.rubric.active .rubric-label { color: var(--text); font-weight: 600; }

/* ---------- Чипы ---------- */
.chips {
  display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 16px 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 32px; padding: 0 12px;
  border-radius: 16px;
  background: var(--surface-2); color: var(--text);
  font-size: 13px; white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.chip:hover { background: var(--surface-3); }
.chip.active { background: var(--accent); color: var(--on-accent); }

/* ---------- Мета списка + переключатель ---------- */
.list-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 16px 8px;
  font-size: 13px; color: var(--text-2);
  border-bottom: 1px solid var(--divider);
}
.list-meta strong { color: var(--text); }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.switch-track {
  position: relative; width: 34px; height: 20px; border-radius: 10px;
  background: var(--surface-3); transition: background var(--t-fast);
}
.switch-thumb {
  position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  transition: transform var(--t-fast);
}
.switch.active .switch-track { background: var(--accent); }
.switch.active .switch-thumb { transform: translateX(14px); }

/* ---------- Список объектов ---------- */
.object-list { padding: 0 0 12px; }
.object-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--t-fast);
}
.object-item:hover { background: var(--surface-2); }
.object-item.selected { background: var(--accent-soft); }
.obj-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.obj-title { font-size: 15px; font-weight: 600; line-height: 1.3; color: var(--accent); }
[data-theme="dark"] .obj-title { color: #8ea8ff; }
.obj-badge { flex: none; font-size: 11px; color: var(--text-3); }
.obj-rubrics { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.obj-address { margin-top: 2px; font-size: 13px; color: var(--text); }
.obj-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--text-2); }
.rating-tag { color: var(--text); font-weight: 600; }
.rating-tag b { color: var(--star); font-weight: 400; }
.empty-state { padding: 28px 24px; text-align: center; color: var(--text-3); line-height: 1.5; }

/* skeleton загрузки */
.skeleton { padding: 14px 16px; border-bottom: 1px solid var(--divider); }
.skeleton i { display: block; height: 10px; border-radius: 5px; background: var(--surface-2); margin: 6px 0; }
.skeleton i:first-child { width: 60%; height: 13px; }
.skeleton i:last-child { width: 40%; }

/* ---------- Карточка объекта ---------- */
.details-bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
}
.details-bar-title { font-size: 14px; color: var(--text-2); flex: 1; }
.details-close-x { margin-left: auto; }
.details-body { padding: 4px 0 20px; }
.detail-hero { padding: 14px 16px 12px; }
.detail-hero-title { font-size: 22px; font-weight: 700; line-height: 1.25; }
.detail-hero-sub { margin-top: 4px; font-size: 14px; color: var(--text-2); }
.detail-rating { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 14px; }
.detail-rating .stars { color: var(--star); letter-spacing: 1px; }
.detail-actions { display: flex; gap: 8px; padding: 4px 16px 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-s);
  font-weight: 600; font-size: 14px; text-decoration: none;
  transition: background var(--t-fast);
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-tonal { background: var(--surface-2); color: var(--text); }
.btn-tonal:hover { background: var(--surface-3); }

.detail-row {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 11px 16px;
  border-top: 1px solid var(--divider);
}
.detail-row > svg { width: 20px; height: 20px; flex: none; color: var(--text-3); margin-top: 1px; }
.detail-row-body { min-width: 0; flex: 1; }
.detail-label { display: block; font-size: 12px; color: var(--text-3); margin-bottom: 2px; }
.detail-val { font-size: 14px; line-height: 1.45; word-break: break-word; }
.detail-val a { color: var(--accent); text-decoration: none; }
.detail-val a:hover { text-decoration: underline; }
.schedule-today { font-weight: 600; }
.schedule-open { color: var(--tone-green); }
.schedule-closed { color: var(--tone-red); }
.schedule-table { width: 100%; margin-top: 6px; border-collapse: collapse; font-size: 13px; color: var(--text-2); }
.schedule-table td { padding: 2px 0; }
.schedule-table td:last-child { text-align: right; }
.schedule-table tr.today td { color: var(--text); font-weight: 600; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.detail-chip { padding: 4px 10px; border-radius: 14px; background: var(--surface-2); font-size: 12.5px; }
.tenants-list { margin-top: 4px; }
.tenant-item { display: flex; flex-direction: column; padding: 8px 0; border-bottom: 1px solid var(--divider); cursor: pointer; }
.tenant-item:last-child { border-bottom: 0; }
.tenant-item:hover .tenant-name { text-decoration: underline; }
.tenant-name { font-weight: 600; color: var(--accent); }
.tenant-rubric { font-size: 12.5px; color: var(--text-2); }

/* ---------- Контролы карты ---------- */
.map-controls {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%); z-index: 10;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.ctrl-group { display: flex; flex-direction: column; border-radius: var(--radius-s); overflow: hidden; box-shadow: var(--shadow); }
.ctrl-group .ctrl { box-shadow: none; border-radius: 0; }
.ctrl-group .ctrl + .ctrl { border-top: 1px solid var(--divider); }
.ctrl {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-s);
  box-shadow: var(--shadow);
  font-weight: 700; font-size: 13px;
  transition: background var(--t-fast), color var(--t-fast);
}
.ctrl svg { width: 22px; height: 22px; }
.ctrl:hover { background: var(--surface-2); }
.ctrl.active { color: var(--accent); }
.ctrl-round { border-radius: 50%; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  max-width: 420px; padding: 12px 18px;
  background: #1c1d1f; color: #fff;
  border-radius: var(--radius-s);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}

/* ---------- Мобильная адаптация (Bottom Sheet + Touch UI в стиле 2ГИС) ---------- */
@media (max-width: 768px) {
  :root {
    --rail-w: 0px;
    --panel-w: 100vw;
  }

  .rail { display: none; }
  .panel-edge { display: none; }
  .mobile-quick-actions { display: flex; }

  /* Интерактивная нижняя шторка (Bottom Sheet) с 3 состояниями: peek / half / full */
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 88dvh;
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 12px);
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px));
    background: var(--surface);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.18);
    will-change: transform;
    transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  .panel.dragging { transition: none !important; }

  /* 4 фиксированных положения шторки: full, half, peek (строка поиска + город Астана + РУС + Тема + шеврон) и hidden */
  .panel[data-sheet="full"] { transform: translateY(0); }
  .panel[data-sheet="half"] { transform: translateY(38dvh); }
  .panel[data-sheet="peek"] { transform: translateY(calc(100% - 116px - env(safe-area-inset-bottom, 0px))); }
  .panel[data-sheet="hidden"],
  .panel.collapsed {
    transform: translateY(105%) !important;
    box-shadow: none !important;
    pointer-events: none;
  }

  /* В режиме peek видна вся шапка (поиск + город + язык + тема), а список категорий/объектов ниже плавно скрыт */
  .panel[data-sheet="peek"] .panel-scroll {
    opacity: 0;
    pointer-events: none;
  }
  .panel .panel-scroll {
    transition: opacity 200ms ease;
  }

  /* Вверх открывающееся меню городов, если шторка свернута снизу (peek) */
  .panel[data-sheet="peek"] .my-select-menu {
    top: auto;
    bottom: calc(100% + 6px);
  }

  /* Строка поиска внизу по центру при полностью скрытой панели */
  .floating-search-pill {
    top: auto;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 12px;
    right: 12px;
    height: 48px;
    border-radius: 14px;
    justify-content: flex-start;
  }

  /* Ручка перетаскивания (Grabber) */
  .sheet-grabber {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 22px;
    flex: none;
    touch-action: none;
    user-select: none;
    cursor: grab;
  }
  .sheet-pill {
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: var(--surface-3);
  }

  .panel-head {
    padding: 2px 14px 6px;
    touch-action: none;
  }

  .search-field {
    height: 42px;
    border-radius: 12px;
  }
  /* 16px предотвращает авто-зум Safari/iOS при фокусе */
  .search-input { font-size: 16px; }

  .city-row { margin-top: 6px; }
  .city-title { font-size: 17px; padding: 2px 4px; }

  /* Горизонтальная свайп-карусель рубрик на мобильном (экономит высоту экрана) */
  .rubrics {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding: 6px 12px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .rubrics::-webkit-scrollbar { display: none; }
  .rubric {
    flex: 0 0 68px;
    padding: 4px 2px;
    gap: 4px;
  }
  .rubric-icon { width: 44px; height: 44px; }
  .rubric-icon svg { width: 21px; height: 21px; }
  .rubric-label { font-size: 11px; white-space: nowrap; }

  .chips { padding: 6px 12px 8px; }
  .chip { height: 30px; padding: 0 11px; font-size: 12.5px; }

  .list-meta { padding: 4px 14px 6px; font-size: 12px; }
  .object-item { padding: 11px 14px; }

  /* Крупные touch-кнопки в карточке объекта */
  .detail-hero { padding: 10px 14px; }
  .detail-hero-title { font-size: 19px; }
  .detail-actions { padding: 2px 14px 10px; }
  .detail-actions .btn { flex: 1; height: 42px; }

  /* Кнопки управления картой строго по центру справа */
  .map-controls {
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    gap: 8px;
  }
  .ctrl { width: 42px; height: 42px; }

  .toast {
    left: 16px;
    right: 16px;
    bottom: calc(126px + env(safe-area-inset-bottom, 0px));
    transform: none;
    max-width: none;
    text-align: center;
  }
}
