/* ===================================================
   БензоДозор — style.css
   Мобильный-first, тёмная тема, нет зависимостей
   =================================================== */

/* ===== CSS-переменные ===== */
:root {
  --color-ok:      #22C55E;   /* зелёный — Есть */
  --color-queue:   #F97316;   /* оранжевый — Очередь */
  --color-empty:   #EF4444;   /* красный — Нет */
  --color-unknown: #9CA3AF;   /* серый — нет данных */

  --bg:            #0F172A;   /* тёмный фон */
  --bg-card:       #1E293B;   /* карточки */
  --bg-input:      #334155;   /* поля ввода */
  --border:        #334155;
  --text:          #F1F5F9;
  --text-muted:    #94A3B8;
  --text-dim:      #64748B;

  --accent:        #22C55E;
  --accent-hover:  #16A34A;
  --telegram:      #2AABEE;
  --max-color:     #FF6B00;

  --radius:        12px;
  --radius-sm:     8px;
  --nav-h:         64px;
  --header-h:      56px;
  --panel-max:     420px;

  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
}

/* ===== Сброс ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }

/* ===== Основной контейнер ===== */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== Экраны ===== */
.screen {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}
.screen.active {
  display: flex;
}

/* ===== Верхний header ===== */
.header {
  height: var(--header-h);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 50;
}

.header__logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
}
.header__logo span {
  color: var(--text);
}

.header__city {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  min-width: 0;
}
.header__city::after {
  content: '▾';
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ===== Карта ===== */
#map {
  flex: 1;
  z-index: 1;
  background: var(--bg);
}

/* Leaflet тайлы в тёмном режиме */
.leaflet-tile {
  filter: brightness(0.85) saturate(0.9);
}

/* Убираем Attribution */
.leaflet-control-attribution {
  font-size: 10px;
  opacity: 0.6;
}

/* ===== Кастомные маркеры ===== */
.marker-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-pin {
  width: 32px;
  height: 32px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,0.3);
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}
.marker-pin.ok      { background: var(--color-ok); }
.marker-pin.queue   { background: var(--color-queue); }
.marker-pin.empty   { background: var(--color-empty); }
.marker-pin.unknown { background: var(--color-unknown); }

.marker-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--telegram);
  color: white;
  font-size: 10px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text-dim);
  transition: color 0.2s;
  position: relative;
}
.nav-btn.active {
  color: var(--accent);
}
.nav-btn__icon {
  font-size: 22px;
  line-height: 1;
}
.nav-btn__label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ===== Город — выпадающее меню ===== */
.city-menu {
  position: fixed;
  top: var(--header-h);
  right: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  z-index: 200;
  min-width: 180px;
  overflow: hidden;
  display: none;
}
.city-menu.open { display: block; }

.city-menu__item {
  padding: 12px 16px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.city-menu__item:hover {
  background: var(--bg-input);
}
.city-menu__item.active {
  color: var(--accent);
  font-weight: 600;
}
.city-menu__item.active::after {
  content: '✓';
}

/* ===== Панель АЗС (slide-up) ===== */
.station-panel {
  position: fixed;
  bottom: var(--nav-h);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 24px rgba(0,0,0,0.5);
  z-index: 150;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 80dvh;
  overflow-y: auto;
}
.station-panel.open {
  transform: translateY(0);
}

.station-panel__handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.station-panel__header {
  padding: 12px 16px 8px;
}

.station-panel__name {
  font-size: 17px;
  font-weight: 700;
  line-height: 1.3;
}
.station-panel__address {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}
.station-panel__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  background: var(--bg-input);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
}

/* Кнопки статуса */
.status-btns {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px 16px 12px;
}

.status-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 2px solid transparent;
  transition: all 0.15s;
  -webkit-user-select: none;
  user-select: none;
}
.status-btn:active { transform: scale(0.96); }

.status-btn.ok     { border-color: var(--color-ok); }
.status-btn.queue  { border-color: var(--color-queue); }
.status-btn.empty  { border-color: var(--color-empty); }

.status-btn.active.ok    { background: var(--color-ok); color: #000; }
.status-btn.active.queue { background: var(--color-queue); color: #000; }
.status-btn.active.empty { background: var(--color-empty); color: #fff; }

.status-btn__icon  { font-size: 22px; }
.status-btn__label { font-size: 12px; font-weight: 600; }

/* Кнопка комментариев */
.comments-toggle {
  margin: 0 16px 16px;
  padding: 10px 16px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  width: calc(100% - 32px);
}
.comments-toggle__count {
  margin-left: auto;
  background: var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
}

/* ===== Комментарии ===== */
.comments-section {
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  max-height: 200px;
  overflow-y: auto;
}

.comment-item {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.comment-item__text {
  font-size: 14px;
  line-height: 1.4;
}
.comment-item__time {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 3px;
}
.comment-empty {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 8px 0;
}

.comment-form {
  display: flex;
  gap: 8px;
}
.comment-input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
  outline: none;
  resize: none;
}
.comment-input:focus { border-color: var(--accent); }
.comment-send {
  background: var(--accent);
  color: #000;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}
.comment-send:active { background: var(--accent-hover); }

/* ===== CTA всплывашка ===== */
.cta-popup {
  position: fixed;
  bottom: calc(var(--nav-h) + 12px);
  left: 12px;
  right: 12px;
  background: linear-gradient(135deg, #1A2744, #1E293B);
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  z-index: 200;
  transform: translateY(calc(100% + var(--nav-h) + 24px));
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.cta-popup.open {
  transform: translateY(0);
}

.cta-popup__title {
  font-size: 15px;
  font-weight: 700;
}
.cta-popup__text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}
.cta-popup__btns {
  display: flex;
  gap: 8px;
}
.cta-popup__close {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--text-dim);
  font-size: 18px;
  padding: 2px 6px;
}
.cta-btn {
  flex: 1;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.cta-btn.tg  { background: var(--telegram); color: #fff; }
.cta-btn.max { background: var(--max-color); color: #fff; }

/* ===== Toast уведомление ===== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  z-index: 300;
  white-space: nowrap;
  opacity: 0;
  transition: all 0.25s ease;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ===== Экран: Каналы ===== */
.screen-inner {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.screen-title {
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
  line-height: 1.3;
}
.screen-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 8px;
}

.channel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.channel-card__head {
  display: flex;
  align-items: center;
  gap: 12px;
}
.channel-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}
.channel-card__icon.tg  { background: var(--telegram); }
.channel-card__icon.max { background: var(--max-color); }

.channel-card__name {
  font-size: 17px;
  font-weight: 700;
}
.channel-card__desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 1px;
}
.channel-card__btn {
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  display: block;
}
.channel-card__btn.tg  { background: var(--telegram); color: #fff; }
.channel-card__btn.max { background: var(--max-color); color: #fff; }

.channels-footer {
  font-size: 13px;
  color: var(--text-dim);
  text-align: center;
  padding: 8px;
  line-height: 1.6;
}

/* ===== Экран: Поделиться ===== */
.share-text-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  white-space: pre-line;
  position: relative;
}

.share-btns {
  display: flex;
  gap: 8px;
}
.share-btn {
  flex: 1;
  padding: 13px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.share-btn.tg  { background: var(--telegram); color: #fff; }
.share-btn.max { background: var(--max-color); color: #fff; }

.copy-btn {
  width: 100%;
  padding: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.copy-btn:active { background: var(--bg-input); }

.share-hint {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* ===== Экран: Поддержать ===== */
.donate-intro {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}

.amount-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.amount-btn {
  padding: 12px 8px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  transition: all 0.15s;
}
.amount-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(34, 197, 94, 0.1);
}

.donate-btn {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: #000;
  border-radius: var(--radius);
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s;
}
.donate-btn:active { background: var(--accent-hover); }

.donate-safe {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* ===== Спиннер загрузки ===== */
.loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 999;
  transition: opacity 0.4s;
}
.loader.hidden {
  opacity: 0;
  pointer-events: none;
}
.loader__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.loader__text {
  font-size: 14px;
  color: var(--text-muted);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Overlay (фон для модалок) ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 140;
  display: none;
}
.overlay.open { display: block; }

/* ===== Пустое состояние на карте ===== */
.map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: var(--text-muted);
  z-index: 10;
  pointer-events: none;
}
.map-empty__icon { font-size: 48px; margin-bottom: 8px; }
.map-empty__text { font-size: 14px; line-height: 1.5; }

/* ===== Safe area на iOS ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  }
  .station-panel { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); }
  .cta-popup    { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
  .toast        { bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); }
}

/* ===== Адаптив для планшетов ===== */
@media (min-width: 600px) {
  .station-panel {
    max-width: var(--panel-max);
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(100%);
    border-radius: var(--radius);
    bottom: calc(var(--nav-h) + 12px);
  }
  .station-panel.open {
    transform: translateX(-50%) translateY(0);
  }
  .cta-popup {
    max-width: 400px;
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(200px);
  }
  .cta-popup.open {
    transform: translateX(-50%) translateY(0);
  }
  .screen-inner {
    max-width: 500px;
    margin: 0 auto;
    width: 100%;
  }
}

/* ===== Скроллбар (WebKit) ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
