/* ============================================================
   styles.css — весь дизайн проекта «АДОЛЬФУК»
   Тёмная тема, акцентный градиент, CSS Grid layout
   ============================================================ */

/* ---------- Переменные и базовые сбросы ---------- */
:root {
  --bg: #0a0d14;
  --panel: rgba(18, 22, 32, 0.62);
  --panel-solid: #11151f;
  --border: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --text-dim: #8b93a7;
  --accent: linear-gradient(135deg, #ffb020, #ff5c5c);
  --accent-coral: #ff5c5c;
  --radius: 16px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);

  /* Цвета статусов */
  --status-zaglushka: #ffce4d;
  --status-podtverjdeno: #4ade80;
  --status-sluh: #5aa9ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* Layout: шапка / основное / футер, высота экрана, без скролла страницы */
  display: grid;
  grid-template-rows: 68px 1fr 38px;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Кастомный тёмный скроллбар ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.22); background-clip: padding-box; }

/* ============================================================
   ШАПКА
   ============================================================ */
.app-header {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-badge {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: var(--accent);
  color: #1a1206;
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 22px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 18px rgba(255, 92, 92, 0.35);
}

.brand-text { display: flex; flex-direction: column; line-height: 1; }
.brand-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
  /* Градиентный текст */
  background: var(--accent);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.3px;
}

/* Чипы статистики */
.stats {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.chip-num { color: var(--text); font-weight: 600; }

.chip-live { color: #d7f5e0; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--status-podtverjdeno);
  box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
  animation: pulse-dot 1.8s infinite;
}
@keyframes pulse-dot {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.55); }
  70%  { box-shadow: 0 0 0 9px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

/* Бургер — скрыт на десктопе */
.burger {
  display: none;
  flex-direction: column;
  gap: 4px;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
}
.burger span { width: 20px; height: 2px; background: var(--text); border-radius: 2px; }

/* ============================================================
   ОСНОВНАЯ ЧАСТЬ: сайдбар + карта
   ============================================================ */
.app-main {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0; /* важно для вложенного скролла */
}

/* ---------- Сайдбар ---------- */
.sidebar {
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 900;
}
.sidebar-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 12px; border-bottom: 1px solid var(--border); }
.sidebar-close {
  display: none;
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 20px; line-height: 1;
  cursor: pointer;
}
.sidebar-close:hover { background: rgba(255, 255, 255, 0.1); }
.sidebar-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 1px;
}
.sidebar-hint { margin-top: 5px; font-size: 11.5px; color: var(--text-dim); }

.city-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Карточка города */
.city-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.city-card:hover {
  background: rgba(255, 255, 255, 0.07);
  transform: translateX(4px);
  border-color: rgba(255, 176, 32, 0.35);
}
.city-card.active {
  border-color: #ffb020;
  box-shadow: 0 0 0 1px #ffb020 inset, 0 8px 24px rgba(255, 176, 32, 0.12);
}

.city-card { position: relative; }
.card-add {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  margin-left: auto;
  border-radius: 50%;
  border: 1px solid rgba(255, 176, 32, 0.5);
  background: rgba(255, 176, 32, 0.12);
  color: #ffd27a;
  font-size: 20px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
}
.card-add:hover { background: rgba(255, 176, 32, 0.22); transform: scale(1.06); }
.card-add:active { transform: scale(0.94); }

.city-prev {
  width: 64px; height: 64px; flex: 0 0 auto;
  border-radius: 12px;
  overflow: hidden;
  background: #0e1119;
  border: 1px solid var(--border);
  display: grid; place-items: center;
}
.city-prev img { width: 100%; height: 100%; object-fit: cover; }
.city-prev .ph { width: 100%; height: 100%; }

.city-meta { min-width: 0; flex: 1; }
.city-name {
  font-family: 'Unbounded', sans-serif;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.city-date { margin-top: 3px; font-size: 11.5px; color: var(--text-dim); }

/* Бейдж статуса */
.badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.3px;
}
.badge-zaglushka     { background: rgba(255, 206, 77, 0.15); color: var(--status-zaglushka); }
.badge-podtverjdeno  { background: rgba(74, 222, 128, 0.15); color: var(--status-podtverjdeno); }
.badge-sluh          { background: rgba(90, 169, 255, 0.15); color: var(--status-sluh); }

/* ---------- Карта ---------- */
.map-wrap { position: relative; min-height: 0; }
#map {
  position: absolute; inset: 0;
  background:
    radial-gradient(1200px 800px at 50% 35%, #131a26 0%, #0a0d14 70%);
}
/* гарантируем, что тач-жесты идут карте, а не прокрутке страницы (важно на телефоне) */
.leaflet-container { touch-action: none; background: transparent; }

/* Инструменты навигации поверх карты */
.map-tools {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.map-tool {
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(17, 21, 31, 0.85);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  transition: background 0.2s, transform 0.15s, border-color 0.2s;
}
.map-tool:hover { background: rgba(255, 176, 32, 0.15); border-color: rgba(255, 176, 32, 0.4); }
.map-tool:active { transform: scale(0.94); }

/* ============================================================
   МАРКЕРЫ (L.divIcon)
   ============================================================ */
.ad-marker { position: relative; width: 40px; height: 40px; }
.ad-marker-dot {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  color: #1a1206;
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 18px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 2;
}
.ad-marker-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--accent-coral);
  animation: ring-pulse 2.4s ease-out infinite;
}
@keyframes ring-pulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  70%  { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

/* ============================================================
   ПОПАП ГОРОДА (перестилизация Leaflet)
   ============================================================ */
.leaflet-popup-content-wrapper {
  background: var(--panel-solid);
  color: var(--text);
  border-radius: 18px !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}
.leaflet-popup-content { margin: 14px 16px; width: 280px !important; }
.leaflet-popup-tip { background: var(--panel-solid); border: 1px solid var(--border); }

.leaflet-popup-close-button {
  color: var(--text-dim) !important;
  width: 26px !important; height: 26px !important;
  font-size: 20px !important;
  padding: 4px 6px 0 0 !important;
}

/* Лента фото в попапе */
.popup-photos {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  height: 170px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.popup-photos img,
.popup-photos .ph {
  flex: 0 0 auto;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
  scroll-snap-align: center;
  border: 1px solid var(--border);
}

.popup-name {
  font-family: 'Unbounded', sans-serif;
  font-weight: 600;
  font-size: 18px;
}
.popup-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.popup-date { font-size: 12px; color: var(--text-dim); }
.popup-desc { margin-top: 10px; font-size: 13px; line-height: 1.5; color: #c7cdda; }

/* Кнопка «добавить фото» и подсказка в попапе */
.popup-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding: 7px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed var(--border);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.popup-add:hover {
  background: rgba(255, 176, 32, 0.1);
  color: #ffd27a;
  border-color: rgba(255, 176, 32, 0.4);
}
.popup-note {
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-dim);
  opacity: 0.7;
}

/* ============================================================
   КОНТРОЛЫ LEAFLET — тёмная тема
   ============================================================ */
.leaflet-bar {
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
}
.leaflet-bar a {
  background: var(--panel-solid) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
}
.leaflet-bar a:hover { background: rgba(255, 255, 255, 0.08) !important; }

.leaflet-control-attribution {
  background: rgba(10, 13, 20, 0.7) !important;
  color: var(--text-dim) !important;
  border-radius: 8px 0 0 0;
  backdrop-filter: blur(6px);
}
.leaflet-control-attribution a { color: #9aa3b8 !important; }

/* Зум-контрол справа внизу */
.leaflet-bottom.leaflet-right { margin-bottom: 14px; margin-right: 14px; }

/* ============================================================
   ФУТЕР
   ============================================================ */
.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.foot-right { white-space: nowrap; }

/* ============================================================
   МОБИЛЬНАЯ ВЕРСИЯ (≤900px)
   ============================================================ */
@media (max-width: 900px) {
  body { grid-template-rows: auto 1fr auto; }

  .app-header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px 14px;
    gap: 10px 12px;
  }
  .add-city-btn { display: none; } /* на телефоне — плавающая кнопка */
  .burger { display: flex; margin-left: auto; }
  .stats {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .app-main { grid-template-columns: 1fr; }

  /* Сайдбар — нижняя шторка поверх карты */
  .sidebar {
    position: fixed;
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%;
    height: 74vh;
    transform: translateY(110%);
    transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.5);
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  /* «пик» — видна только шапка списка, карта остаётся почти вся */
  .sidebar.peek { transform: translateY(calc(100% - 132px)); }
  .sidebar.open { transform: translateY(0); }
  .sheet-handle {
    width: 44px; height: 5px; border-radius: 3px;
    background: rgba(255, 255, 255, 0.22);
    margin: 10px auto 2px;
    cursor: pointer;
    flex: 0 0 auto;
  }
  .sidebar-close { display: block; }
  .chip-photo { display: none; }

  /* Плавающая кнопка добавления города */
  body .fab {
    display: grid;
    position: fixed;
    right: 18px; bottom: calc(20px + env(safe-area-inset-bottom, 0));
    width: 56px; height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #1a1206;
    font-size: 30px; font-weight: 700; line-height: 1;
    place-items: center;
    cursor: pointer;
    z-index: 1100;
    box-shadow: 0 10px 28px rgba(255, 92, 92, 0.45);
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
  }
  .fab:active { transform: scale(0.92); }
  .fab:hover { filter: brightness(1.05); box-shadow: 0 12px 32px rgba(255, 92, 92, 0.55); }
  .fab.hidden { display: none; }

  .leaflet-popup-content { width: min(280px, 84vw) !important; }
  .popup-add { display: flex; width: 100%; justify-content: center; }
  .foot-right { display: none; }
}

/* Мелкие экраны — прячем подзаголовок и лишние чипы */
@media (max-width: 520px) {
  .brand-sub { display: none; }
  .chip-live .live-dot { display: inline-block; }
  .foot-left { font-size: 10px; }
}
@media (max-width: 600px) {
  .app-footer { display: none; }
}

/* ============================================================
   КНОПКА «ДОБАВИТЬ ГОРОД» В ШАПКЕ
   ============================================================ */
.add-city-btn {
  margin-left: 14px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: var(--accent);
  color: #1a1206;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.add-city-btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(255, 92, 92, 0.35); filter: brightness(1.05); }
.add-city-btn:active { transform: translateY(0); }

/* Плавающая кнопка — видна только на телефоне (см. медиа-запрос) */
.fab { display: none; }

/* ============================================================
   МОДАЛКА «ДОБАВИТЬ ГОРОД»
   ============================================================ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 6, 11, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: fade-in 0.2s ease;
}
.modal[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  width: min(440px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--panel-solid);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.modal-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 600;
  font-size: 18px;
  margin-bottom: 16px;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 32px; height: 32px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: rgba(255, 255, 255, 0.1); }

.city-form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-dim); }
.field input,
.field textarea,
.field select {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.field input:focus,
.field textarea:focus,
.field select:focus { border-color: #ffb020; background: rgba(255, 176, 32, 0.06); }
.field textarea { resize: vertical; min-height: 64px; }
.coords { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn-primary {
  margin-top: 4px;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #1a1206;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.2s ease;
}
.btn-primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn-ghost {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}
.btn-ghost:hover { border-color: rgba(255, 176, 32, 0.4); background: rgba(255, 176, 32, 0.06); }

.hint { font-size: 11.5px; color: var(--text-dim); margin: -4px 0 0; }
.ugc-note {
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 11px;
}
.form-error { font-size: 12px; color: #ff8a8a; min-height: 14px; margin: 0; }

/* Режим выбора точки на карте — курсор-перекрестье */
body.picking .leaflet-container { cursor: crosshair !important; }

/* ============================================================
   ЛАЙТБОКС (зум/пан)
   ============================================================ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  background: rgba(2, 3, 7, 0.92);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.lightbox[hidden] { display: none; }
.lightbox img {
  max-width: 92vw;
  max-height: 86vh;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  transform-origin: center center;
  transition: transform 0.05s linear;
  touch-action: none;
  cursor: grab;
}
.lightbox img:active { cursor: grabbing; }
.lightbox-close {
  position: absolute;
  top: 16px; right: 18px;
  width: 40px; height: 40px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 1;
}
.lightbox-close:hover { background: rgba(255, 255, 255, 0.14); }
.lightbox-hint {
  position: absolute;
  bottom: 16px; left: 0; right: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-dim);
}
