/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Base ───────────────────────────────────────────────────────────────── */
html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', sans-serif;
  background:
    radial-gradient(1200px 600px at 80% -10%, #16203a 0%, transparent 60%),
    linear-gradient(180deg, #0a0e17 0%, #0c111c 100%);
  min-height: 100vh;
  color: #c4cdde;
  line-height: 1.5;
}

/* ── Site header (logo + description, над всем) ──────────────────────────── */
.site-header {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 20px 6px;
}
.header-icon { font-size: 22px; vertical-align: middle; }
.header-name {
  font-size: 22px;
  font-weight: 800;
  color: #f4f7fc;
  letter-spacing: -.3px;
  line-height: 1.2;
}
.header-sub {
  font-size: 13px;
  color: #9aa6bd;
  line-height: 1.5;
  margin-top: 3px;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  min-height: calc(100vh - 100px);
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 20px 28px;
  gap: 24px;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  width: 272px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #141b2c, #111726);
  border: 1px solid #232c42;
  border-radius: 18px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-self: flex-start;
  position: sticky;
  top: 20px;
  overflow: hidden;
  transition: width .3s cubic-bezier(.4,0,.2,1),
              padding .3s cubic-bezier(.4,0,.2,1),
              background .3s,
              border-color .3s;
}

.sidebar.collapsed {
  width: 52px;
  padding: 12px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

/* Кнопка ☰ — абсолютно в правом верхнем углу сайдбара */
.sidebar-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 30px;
  height: 30px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: #9aa6bd;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  z-index: 1;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: rgba(124,108,245,.2); color: #a8acff; }

.sidebar-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-width: 228px;
  padding-top: 4px; /* отступ чтобы контент не лез под кнопку */
  opacity: 1;
  transition: opacity .2s;
}
.sidebar.collapsed .sidebar-body {
  opacity: 0;
  pointer-events: none;
}

/* ── Fields ─────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 8px; }

.field-label {
  font-size: 13px;
  color: #9aa6bd;
  font-weight: 500;
}

/* Select */
.select-wrap { position: relative; }
.select-wrap select {
  width: 100%;
  background: #1a2236;
  border: 1px solid #2c3650;
  border-radius: 10px;
  color: #c4cdde;
  font-size: 14px;
  padding: 10px 36px 10px 13px;
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: border-color .15s;
}
.select-wrap select:focus { border-color: #7c6cf5; }
.select-wrap select option { background: #1a2236; }
.select-arrow {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  pointer-events: none;
}

/* Duration buttons */
.dur-btns {
  display: flex;
  gap: 8px;
}
.dur-btn {
  flex: 1;
  padding: 10px 6px;
  background: #1a2236;
  border: 1.5px solid #3a4568;
  border-radius: 10px;
  color: #9aa7be;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.dur-btn:hover { border-color: rgba(124,108,245,.45); color: #a8acff; }
.dur-btn.active {
  background: linear-gradient(135deg, #6366f1, #7c6cf5);
  border-color: transparent;
  color: #fff;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #6366f1, #7c6cf5);
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  letter-spacing: -.1px;
}
.btn-primary:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

/* ── Main ────────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ── Content toolbar (tabs left, share/PDF right) ──────────────────────────── */
.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Tabs ────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: none;
  padding: 7px 12px;
  background: #1a2236;
  border: 1.5px solid #3a4568;
  border-radius: 9px;
  color: #9aa7be;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color .15s, color .15s, background .15s;
}
.tab-btn:hover { border-color: rgba(124,108,245,.45); color: #a8acff; }
.tab-btn.active {
  background: linear-gradient(135deg, #6366f1, #7c6cf5);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

/* ── Toolbar actions (Share / PDF) ─────────────────────────────────────────── */
.toolbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.btn-toolbar {
  padding: 7px 14px;
  background: #1a2236;
  border: 1.5px solid #3a4568;
  border-radius: 9px;
  color: #a8acff;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s, opacity .15s;
}
.btn-toolbar:hover:not(:disabled) { border-color: rgba(124,108,245,.45); color: #c7cbff; }
.btn-toolbar:disabled { opacity: .35; cursor: not-allowed; }

/* ── Output ──────────────────────────────────────────────────────────────── */
.output {
  flex: 1;
  min-height: 320px;
}

/* Place-card Replace/Remove buttons (ui/render.py marks them data-no-print).
   The app's own "Save PDF" never snapshots the DOM, but this guards against
   a plain browser Ctrl+P on the page. */
@media print {
  [data-no-print] { display: none !important; }
}

.place-action-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: 14px;
  color: #4a5568;
}
.empty-state p { font-size: 14px; text-align: center; }

/* ── How it works (empty-state explainer) ──────────────────────────────────── */
.hiw {
  width: 100%;
  max-width: 460px;
  text-align: center;
}
.hiw-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #7c6cf5;
  margin-bottom: 8px;
}
.hiw-title {
  font-size: 20px;
  font-weight: 800;
  color: #f4f7fc;
  margin-bottom: 8px;
}
.hiw-subtitle {
  font-size: 13.5px;
  color: #9aa6bd;
  margin-bottom: 22px;
}
.hiw-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}
.hiw-step {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: #1a2236;
  border: 1px solid #2c3650;
  border-radius: 14px;
  padding: 14px 18px;
}
.hiw-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: rgba(124,108,245,.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}
.hiw-text { flex: 1; min-width: 0; }
.hiw-step-title { font-size: 14.5px; font-weight: 700; color: #f1f4fb; }
.hiw-step-desc { font-size: 12.5px; color: #9aa6bd; margin-top: 2px; }
.hiw-num {
  font-size: 20px;
  font-weight: 800;
  color: #2c3650;
  flex-shrink: 0;
  margin-top: 2px;
}
.hiw-slot {
  margin-top: 12px;
}
.hiw-slot:empty {
  display: none;
}
.hiw-slot .field { gap: 8px; }
.hiw-slot .field-label { display: none; }
.hiw-slot #gen-btn { margin: 0; }

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  gap: 20px;
}

.loader-orbit {
  position: relative;
  width: 180px;
  height: 180px;
}
.loader-cloud {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
}
.loader-cloud-sm {
  position: absolute;
  opacity: .5;
  font-size: 28px;
}
.loader-cloud-sm:nth-child(2) { top: 12px; right: 20px; }
.loader-cloud-sm:nth-child(3) { bottom: 16px; left: 14px; font-size: 22px; opacity: .35; }

/* Самолёт летит носом вперёд по часовой стрелке */
.loader-plane {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 28px;
  animation: orbit 3s linear infinite;
  transform-origin: 0 0;
}

@keyframes orbit {
  from { transform: rotate(0deg) translateX(78px) rotate(180deg); }
  to   { transform: rotate(360deg) translateX(78px) rotate(180deg); }
}

.loading-text {
  color: #6b7a94;
  font-size: 14px;
  font-style: italic;
}
.dots { display: flex; gap: 5px; align-items: center; }
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7c6cf5;
  animation: blink 1.4s ease-in-out infinite;
}
.dot:nth-child(2) { animation-delay: .2s; }
.dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink {
  0%, 80%, 100% { opacity: .2; transform: scale(.9); }
  40%           { opacity: 1;  transform: scale(1.2); }
}

/* Inline generating indicator */
.gen-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding: 8px 0;
}
.gen-indicator span:last-child {
  color: #6b7a94;
  font-size: 13px;
  margin-left: 4px;
}

/* ── Arrows ──────────────────────────────────────────────────────────────── */
.arrows {
  display: flex;
  align-items: center;
  min-height: 56px;
}

.arr-btn {
  background: #1a2236;
  border: 1.5px solid #3a4568;
  color: #a8acff;
  cursor: pointer;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  font-size: 18px;
  transition: border-color .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.arr-btn:hover { border-color: rgba(124,108,245,.45); background: rgba(124,108,245,.07); }

/* «Подробнее» всегда справа */
.arr-next {
  margin-left: auto;
  border-radius: 24px;
  width: auto;
  padding: 0 20px;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
}

.arr-prev[hidden], .arr-next[hidden] { display: none !important; }

/* На вкладке дня ← стартует от левого края колонки с планом (2-я колонка грида) */
.arrows--day { padding-left: calc(50% + 12px); }

/* ── Map legend ──────────────────────────────────────────────────────────── */
.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #9aa6bd;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.legend-dot--visit { background: #7c6cf5; }
.legend-dot--food  { background: #f0a92a; }

/* ── Day layout (карта + план) ───────────────────────────────────────────── */
.day-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

/* ── Map card ────────────────────────────────────────────────────────────── */
.map-card {
  position: sticky;
  top: 24px;
  border: 1px solid #2c3650;
  border-radius: 14px;
  overflow: hidden;
  background: #11182a;
  box-shadow: 0 8px 22px rgba(0,0,0,.3);
}

.map-card__header {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 15px;
  background: #161d30;
  border-bottom: 1px solid #232c42;
}

.map-card__title {
  font-size: 13.5px;
  font-weight: 700;
  color: #e6ebf5;
  line-height: 1.2;
}

.map-card__subtitle {
  font-size: 11.5px;
  color: #7a849a;
  line-height: 1.3;
}

.map-card__frame-wrap {
  position: relative;
  line-height: 0;
  background: #0e1526;
}

.map-card__frame {
  display: block;
  width: 100%;
  height: 520px;
  border: 0;
  filter: saturate(.9) brightness(.96) contrast(1.02);
}

.map-card__frame-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 1px rgba(124,108,245,.1),
    inset 0 14px 22px -16px rgba(14,21,38,.9);
}

/* ── Walk indicator ──────────────────────────────────────────────────────── */
.walk-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 18px;
  color: #828daa;
  font-size: 12.5px;
  font-weight: 600;
  margin: 2px 0;
}

.walk-indicator__line {
  width: 0;
  height: 22px;
  border-left: 2px dotted #39435c;
  flex-shrink: 0;
}

.walk-indicator__icon {
  flex: none;
  color: #828daa;
}

.walk-indicator__label { white-space: nowrap; }

/* ── Mobile ──────────────────────────────────────────────────────────────── */
@media (max-width: 720px) {
  .site-header {
    padding: 20px 14px 4px;
    gap: 10px;
  }
  .header-icon  { font-size: 22px; }
  .header-name  { font-size: 18px; }
  .header-sub   { font-size: 12px; }

  .app {
    flex-direction: column;
    padding: 14px 14px 24px;
    gap: 16px;
  }

  .sidebar {
    width: 100%;
    position: static;
    border-radius: 14px;
    padding: 18px 16px;
    gap: 16px;
  }

  .main { gap: 12px; }

  .day-layout {
    grid-template-columns: 1fr;
  }
  .map-card { position: static; }
  .map-card__frame { height: 300px; }
  .arrows--day { padding-left: 0; }

  .tabs { flex-wrap: wrap; }
  .tab-btn { flex: none; }

  .arr-btn { width: 42px; height: 42px; font-size: 16px; }
  .arr-next { padding: 0 16px; font-size: 13px; }
}
