/* ============================================================
   «В мечеть» — дизайн-система
   Цвета: зелёный / белый / тёмно-графитовый. Свет + тьма.
   Mobile-first, карта на весь экран, плавающие карточки.
   ============================================================ */

/* ---------- Токены: светлая тема ---------- */
:root {
  --green-500: #22A06B;
  --green-600: #15803D;
  --green-700: #126C34;

  --bg:        #F5F7F6;
  --surface:   #FFFFFF;
  --surface-2: #EDF1EF;
  --text:      #11181C;
  --text-muted:#5B6873;
  --border:    #E3E9E6;

  --primary:    var(--green-600);
  --on-primary: #FFFFFF;
  --accent:     var(--green-500);
  --road:       #2D6FF0;   /* движение: маршрут, точка посадки, моё место */

  --danger:  #D64545;
  --warning: #D9961A;
  --success: #15803D;

  --shadow-sm: 0 1px 3px rgba(16,24,28,.08);
  --shadow-md: 0 6px 20px rgba(16,24,28,.12);
  --shadow-lg: 0 -8px 30px rgba(16,24,28,.16);

  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 26px;
  --r-pill: 999px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Токены: тёмная тема ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #0E1316;
    --surface:   #171E22;
    --surface-2: #212A2F;
    --text:      #EAF0ED;
    --text-muted:#94A39C;
    --border:    #2A343A;
    --primary:    #2DB271;
    --on-primary: #07140C;
    --accent:     #2DB271;
    --road:       #5B96FF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
    --shadow-md: 0 6px 20px rgba(0,0,0,.5);
    --shadow-lg: 0 -8px 30px rgba(0,0,0,.55);
  }
}
[data-theme="dark"] {
  --bg:        #0E1316;
  --surface:   #171E22;
  --surface-2: #212A2F;
  --text:      #EAF0ED;
  --text-muted:#94A39C;
  --border:    #2A343A;
  --primary:    #2DB271;
  --on-primary: #07140C;
  --accent:     #2DB271;
  --road:       #5B96FF;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow-md: 0 6px 20px rgba(0,0,0,.5);
  --shadow-lg: 0 -8px 30px rgba(0,0,0,.55);
}

/* ---------- База ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  position: fixed; inset: 0;
  overscroll-behavior: none;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
h1,h2,h3,p { margin: 0; }

/* ---------- Слои ---------- */
#map { position: fixed; inset: 0; background: var(--surface-2); z-index: 0; }
#overlay {
  position: fixed; inset: 0; z-index: 10;
  pointer-events: none;
}
#overlay > * { pointer-events: auto; }
#screen {
  position: fixed; inset: 0; z-index: 30;
  background: var(--bg);
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
#screen.show { display: flex; }

/* ---------- Кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 54px; padding: 0 22px;
  border-radius: var(--r-pill);
  font-size: 17px; font-weight: 650;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--primary); color: var(--on-primary); box-shadow: var(--shadow-sm); }
.btn--primary:active { filter: brightness(.95); }
.btn--secondary { background: var(--surface-2); color: var(--text); }
.btn--ghost { background: transparent; color: var(--primary); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { display: flex; width: 100%; }
.btn--lg { height: 60px; font-size: 18px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- Карточки / лист ---------- */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
}

.fab {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 22px;
}

/* ---------- Чипы ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 16px;
  border-radius: var(--r-pill);
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-sm);
  font-size: 15px; font-weight: 600;
  border: 1px solid var(--border);
}
.chip--select { background: var(--surface-2); box-shadow: none; }
.chip--active { background: var(--primary); color: var(--on-primary); border-color: transparent; }

/* ---------- Бейдж загруженности ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 650;
  padding: 4px 10px; border-radius: var(--r-pill); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.badge--low    { color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); }
.badge--medium { color: var(--warning); background: color-mix(in srgb, var(--warning) 16%, transparent); }
.badge--high   { color: var(--danger);  background: color-mix(in srgb, var(--danger) 14%, transparent); }

/* ---------- Верхняя плавающая панель (карта) ---------- */
.topbar {
  position: absolute; top: calc(var(--safe-top) + 12px); left: 12px; right: 12px;
  display: flex; gap: 10px; align-items: center;
}
.topbar .chip { flex: 1; justify-content: space-between; height: 50px; border-radius: var(--r-md); }

/* ---------- Нижние плавающие контролы ---------- */
.map-fabs {
  position: absolute; right: 14px; bottom: calc(var(--safe-bottom) + 130px);
  display: flex; flex-direction: column; gap: 12px;
}

/* ---------- Bottom sheet ---------- */
#sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(8,12,14,.45);
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
#sheet-backdrop.show { opacity: 1; pointer-events: auto; }
#sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 10px 18px calc(var(--safe-bottom) + 20px);
  transform: translateY(110%);
  transition: transform .28s cubic-bezier(.22,.61,.36,1);
  max-height: 86vh; overflow-y: auto;
}
#sheet.show { transform: translateY(0); }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: var(--border);
  margin: 4px auto 14px; }

/* ---------- Карточка транспорта ---------- */
.trip-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.trip-ico { width: 54px; height: 54px; border-radius: var(--r-md); background: var(--surface-2);
  display: grid; place-items: center; font-size: 28px; flex: none; }
.trip-title { font-size: 19px; font-weight: 700; }
.trip-sub { color: var(--text-muted); font-size: 14px; margin-top: 2px; }
.trip-stats { display: flex; gap: 10px; margin: 16px 0; }
.stat { flex: 1; background: var(--surface-2); border-radius: var(--r-md); padding: 12px 14px; }
.stat b { display: block; font-size: 20px; font-weight: 750; }
.stat span { color: var(--text-muted); font-size: 13px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.sheet-actions .btn { flex: 1; }

/* ---------- Список (мечети / профиль) ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 14px 16px;
  width: 100%; text-align: left;
}
.row__ico { width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2);
  display: grid; place-items: center; font-size: 22px; flex: none; }
.row__body { flex: 1; min-width: 0; }
.row__title { font-weight: 650; font-size: 16px; }
.row__sub { color: var(--text-muted); font-size: 13px; margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row__meta { color: var(--text-muted); font-size: 13px; text-align: right; flex: none; }

/* ---------- Полноэкранные секции ---------- */
.screen-pad { padding: calc(var(--safe-top) + 20px) 20px calc(var(--safe-bottom) + 20px); }
.screen-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.screen-title { font-size: 24px; font-weight: 750; }
.back-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--surface-2);
  display: grid; place-items: center; font-size: 20px; flex: none; }

/* ---------- Splash ---------- */
.splash {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px; text-align: center; padding: 40px;
  background: radial-gradient(120% 80% at 50% 18%, var(--green-500), var(--green-700));
  color: #fff; position: relative; overflow: hidden;
}
.splash__logo { width: 132px; height: 132px; color: #fff; }
.splash__title { font-size: 30px; font-weight: 800; letter-spacing: .5px; }
.splash__slogan { font-size: 16px; opacity: .92; max-width: 260px; line-height: 1.5; }
.splash__pattern { position: absolute; inset: 0; opacity: .07; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='60'%3E%3Cpath d='M30 0l8 22 22 8-22 8-8 22-8-22-22-8 22-8z' fill='%23fff'/%3E%3C/svg%3E");
  background-size: 60px 60px; }

/* ---------- Onboarding ---------- */
.onb { flex: 1; display: flex; flex-direction: column; }
.onb__art { flex: 1; display: grid; place-items: center; padding: 40px;
  background: var(--surface-2); }
.onb__art svg { width: 180px; height: 180px; color: var(--primary); }
.onb__body { padding: 30px 26px calc(var(--safe-bottom) + 26px); display: flex; flex-direction: column; gap: 18px; }
.onb__title { font-size: 25px; font-weight: 780; line-height: 1.25; }
.onb__text { color: var(--text-muted); font-size: 16px; line-height: 1.5; }
.dots { display: flex; gap: 8px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: width .2s; }
.dots i.on { width: 22px; background: var(--primary); }
.onb__row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

/* ---------- Выбор роли ---------- */
.roles { flex: 1; display: flex; flex-direction: column; gap: 16px; justify-content: center; }
.role-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 26px 22px; text-align: left;
  display: flex; align-items: center; gap: 18px;
}
.role-card:active { transform: scale(.99); }
.role-card__ico { width: 64px; height: 64px; border-radius: 20px; flex: none;
  display: grid; place-items: center; font-size: 34px; background: var(--surface-2); }
.role-card--primary .role-card__ico { background: var(--primary); color: var(--on-primary); }
.role-card__title { font-size: 20px; font-weight: 720; }
.role-card__sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ---------- Форма ---------- */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 600; color: var(--text-muted); }
.input {
  height: 54px; padding: 0 16px; font-size: 17px;
  background: var(--surface); color: var(--text);
  border: 1.5px solid var(--border); border-radius: var(--r-md);
}
.input:focus { outline: none; border-color: var(--primary); }
.chips-wrap { display: flex; flex-wrap: wrap; gap: 10px; }
.stepper { display: flex; align-items: center; gap: 18px; }
.stepper button { width: 48px; height: 48px; border-radius: 50%; background: var(--surface-2);
  font-size: 24px; font-weight: 700; display: grid; place-items: center; }
.stepper b { font-size: 24px; min-width: 40px; text-align: center; }

/* ---------- Статус-плашка водителя ---------- */
.live-pill {
  position: absolute; top: calc(var(--safe-top) + 14px); left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface); box-shadow: var(--shadow-md);
  padding: 10px 18px; border-radius: var(--r-pill); font-weight: 650; font-size: 15px;
}
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger);
  animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.3 } }

/* ---------- Нижняя панель (фиксированная над картой) ---------- */
.dock {
  position: absolute; left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + 16px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  padding: 16px 18px;
}
.dock__label { font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 650; margin-bottom: 10px; }
.dock__row { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; }
.dock__body { flex: 1; min-width: 0; }
.dock__stale { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 650;
  color: var(--warning); margin-bottom: 10px; }
.dock__stale::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Пустые состояния ---------- */
.empty { text-align: center; color: var(--text-muted); padding: 26px 18px; }
.empty .ico { font-size: 40px; }
.empty .t { color: var(--text); font-weight: 700; font-size: 17px; margin-top: 8px; }
.empty .s { font-size: 14px; margin-top: 4px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 90px); transform: translateX(-50%) translateY(20px);
  z-index: 80; background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: var(--r-pill); font-size: 15px; font-weight: 600;
  box-shadow: var(--shadow-md); opacity: 0; pointer-events: none; transition: all .25s ease;
  max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Leaflet маркеры ---------- */
.leaflet-div-icon { background: transparent; border: 0; }
.mk { display: grid; place-items: center; background: transparent; border: 0; }
.mk-mosque { width: 38px; height: 38px; border-radius: 50% 50% 50% 4px;
  background: var(--primary); color: var(--on-primary); transform: rotate(45deg);
  box-shadow: var(--shadow-md); }
.mk-mosque span { transform: rotate(-45deg); font-size: 18px; }
.mk-trip { position: relative; padding: 5px 10px 5px 7px; border-radius: var(--r-pill);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-md);
  border: 2px solid var(--primary); font-weight: 700; font-size: 13px; white-space: nowrap;
  display: inline-flex; gap: 5px; align-items: center; transition: border-color .2s, opacity .2s; }
.mk-trip__i { font-size: 14px; line-height: 1; }
.mk-trip__n { position: absolute; top: -7px; right: -7px; width: 17px; height: 17px; border-radius: 50%;
  background: var(--primary); color: var(--on-primary); font-size: 10.5px; font-weight: 800;
  font-style: normal; display: grid; place-items: center; border: 2px solid var(--surface); }
.mk-trip--sel { background: var(--road); color: #fff; border-color: var(--road); }
.mk-trip--sel .mk-trip__n { background: #fff; color: var(--road); border-color: var(--road); }
.mk-trip--full { border-color: var(--warning); }
.mk-trip--full .mk-trip__n { background: var(--warning); }
.mk-trip--stale { border-color: var(--border); opacity: .6; }
.mk-trip--stale .mk-trip__n { background: var(--text-muted); }

/* Шевроны направления движения: 🚗 → → → 🕌 */
.mk-chev svg { width: 16px; height: 16px; display: block; }
.mk-chev path { fill: none; stroke: var(--road); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.mk-chev { opacity: .75; }

/* Маршруты: намерение (тонкий пунктир к мечети) и выбранный маршрут (бегущий пунктир) */
.trip-route { stroke-dasharray: 14 10; animation: route-flow 1.1s linear infinite; }
@keyframes route-flow { to { stroke-dashoffset: -24; } }
.map--stale .mk-trip { border-color: var(--border) !important; opacity: .55; }
.map--stale .leaflet-tile-pane { filter: grayscale(.4); }

.mk-me { width: 18px; height: 18px; border-radius: 50%; background: #2D7DF6;
  border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(45,125,246,.25); }
.leaflet-control-attribution { font-size: 9px !important; }

.muted { color: var(--text-muted); }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { flex:1; display:grid; place-items:center; }

@media (prefers-reduced-motion: reduce) {
  .trip-route { animation: none; }
  .live-dot { animation: none; }
}
