/* Moto — спокойная светлая/тёмная тема */
:root {
  --bg: #f4f5f7;
  --panel: rgba(255, 255, 255, 0.86);
  --panel-solid: #ffffff;
  --text: #1c1c1e;
  --muted: #6b7280;
  --border: rgba(0, 0, 0, 0.08);
  --accent: #0a84ff;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  --radius: 16px;
}
:root[data-theme="dark"] {
  --bg: #0c0d10;
  --panel: rgba(24, 26, 31, 0.82);
  --panel-solid: #181a1f;
  --text: #f2f3f5;
  --muted: #9aa0aa;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #0a84ff;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

#map { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; background: var(--bg); }

/* загрузчик */
#loader {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; z-index: 50; display: grid; place-items: center;
  background: var(--bg); gap: 18px;
}
.spinner {
  width: 46px; height: 46px; border: 4px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loader .lbl { color: var(--muted); font-size: 14px; }
#loader .err {
  max-width: 360px; text-align: center; padding: 22px;
  background: var(--panel-solid); border-radius: var(--radius);
  box-shadow: var(--shadow); line-height: 1.5;
}
#loader .err small { color: var(--muted); }

/* боковая панель */
#panel {
  position: fixed; top: 14px; left: 14px; bottom: 14px; width: 330px; z-index: 20;
  display: flex; flex-direction: column; gap: 14px; padding: 18px;
  background: var(--panel); backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-y: auto;
  transition: transform 0.35s cubic-bezier(.4,0,.2,1), opacity .3s;
  scrollbar-width: thin;
}
#panel.collapsed { transform: translateX(calc(-100% - 20px)); opacity: 0; }

.p-head h1 { margin: 0; font-size: 21px; letter-spacing: -0.02em; }
.p-head p { margin: 3px 0 12px; color: var(--muted); font-size: 13px; }

.lang-row { display: flex; gap: 6px; }
.lang {
  flex: 1; padding: 7px 4px; font-size: 12.5px; cursor: pointer;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 9px; transition: .15s;
}
.lang:hover { color: var(--text); }
.lang.on { background: var(--accent); color: #fff; border-color: var(--accent); }

/* мото-карточка */
.moto-card {
  display: flex; gap: 12px; align-items: center; padding: 14px;
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 13px; transition: .25s;
}
.moto-card.on { border-color: #ff9500; box-shadow: 0 0 0 2px rgba(255,149,0,.25); }
.moto-title { font-weight: 600; font-size: 14.5px; }
.moto-hint { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }

/* переключатели */
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch.sm { width: 40px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0; cursor: pointer; background: var(--border);
  border-radius: 999px; transition: .25s;
}
.slider::before {
  content: ""; position: absolute; height: 22px; width: 22px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch.sm .slider::before { height: 18px; width: 18px; }
.switch input:checked + .slider { background: var(--accent); }
.moto-card .switch input:checked + .slider { background: #ff9500; }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* группы */
.grp { display: flex; flex-direction: column; gap: 10px; }
.grp-head {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
}
.grp-head .links a { cursor: pointer; color: var(--accent); }
.grp-head .links a:hover { text-decoration: underline; }

.cats { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.cat {
  display: flex; align-items: center; gap: 7px; padding: 7px 9px; cursor: pointer;
  background: var(--panel-solid); border: 1px solid var(--border);
  border-radius: 10px; font-size: 12px; opacity: .45; transition: .15s; user-select: none;
}
.cat.on { opacity: 1; border-color: var(--c, var(--accent)); }
.cat input { display: none; }
.cat-ico {
  width: 20px; height: 24px; flex: none; display: grid; place-items: center;
}
.cat-ico img { height: 24px; width: auto; display: block; }
.cat-lbl { line-height: 1.2; }

.row { display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.row b { color: var(--accent); }
.row input[type="range"] { width: 100%; accent-color: var(--accent); }
.toggle-row { flex-direction: row; justify-content: space-between; align-items: center; }

.legend .leg { display: flex; align-items: center; gap: 9px; font-size: 13px; padding: 2px 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--border); }

.p-foot {
  margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.p-foot button {
  padding: 8px 12px; font-size: 12.5px; cursor: pointer; color: var(--text);
  background: var(--panel-solid); border: 1px solid var(--border); border-radius: 10px; transition: .15s;
}
.p-foot button:hover { border-color: var(--accent); }
#counter { font-size: 12px; color: var(--muted); width: 100%; }

/* кнопка сворачивания панели */
#panelToggle {
  position: fixed; top: 22px; left: 358px; z-index: 21; width: 38px; height: 38px;
  display: grid; place-items: center; cursor: pointer; font-size: 17px;
  background: var(--panel); backdrop-filter: blur(20px); color: var(--text);
  border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow);
  transition: left .35s cubic-bezier(.4,0,.2,1);
}
#panel.collapsed ~ #panelToggle { left: 14px; }

/* инфо-панель */
#info {
  position: fixed; right: 14px; bottom: 14px; width: 320px; z-index: 25;
  padding: 18px; background: var(--panel); backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  transform: translateY(140%); opacity: 0; transition: .35s cubic-bezier(.4,0,.2,1); pointer-events: none;
}
#info.open { transform: none; opacity: 1; pointer-events: auto; }
.info-close {
  position: absolute; top: 12px; right: 12px; width: 28px; height: 28px; cursor: pointer;
  border: none; border-radius: 8px; background: var(--border); color: var(--text); font-size: 17px;
}
.info-head { display: flex; gap: 12px; align-items: center; margin-bottom: 14px; }
.info-ico {
  width: 40px; height: 48px; flex: none; display: grid; place-items: center;
}
.info-ico img { height: 46px; width: auto; display: block; }
.info-cat { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.info-name { font-size: 16px; font-weight: 600; margin-top: 2px; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; font-size: 13.5px; }
.info-grid dt { color: var(--muted); }
.info-grid dd { margin: 0; display: flex; align-items: center; gap: 7px; }

@media (max-width: 560px) {
  #panel { width: auto; right: 14px; bottom: auto; max-height: 70vh; }
  #panelToggle { left: auto; right: 22px; }
  #panel.collapsed { transform: translateY(calc(-100% - 30px)); }
  #info { left: 14px; width: auto; }
}

/* Стили для кнопок действий в инфо-панели */
.btn {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 9px;
  cursor: pointer;
  border: none;
  transition: background 0.2s, opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn:hover {
  opacity: 0.9;
}
.btn-add {
  background: var(--accent);
  color: #fff;
}
.btn-remove {
  background: #ff3b30;
  color: #fff;
}
.btn-primary {
  background: #34c759;
  color: #fff;
}
.btn-secondary {
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Ховер эффекты для вкладок и элементов маршрута */
.tab-btn:hover {
  background: var(--panel-solid) !important;
  color: var(--text) !important;
}
.route-item {
  transition: transform 0.15s, box-shadow 0.15s;
}
.route-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.route-btn-move:hover, .route-btn-delete:hover {
  background: var(--border) !important;
}
.route-btn-move:disabled {
  opacity: 0.3;
  cursor: not-allowed !important;
}
