/* Dovezy Mini App. Colours come from Telegram.WebApp.themeParams (set as --tg-* by app.js); these are fallbacks. */
:root {
  --bg: var(--tg-bg, #ffffff);
  --text: var(--tg-text, #1b1f24);
  --hint: var(--tg-hint, #6b7280);
  --link: var(--tg-link, #2481cc);
  --btn: var(--tg-button, #2481cc);
  --btn-text: var(--tg-button-text, #ffffff);
  --bg2: var(--tg-secondary-bg, #f1f3f5);
  --danger: var(--tg-destructive, #d93d3d);
  --me: #16a34a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

#map { position: fixed; inset: 0; }

/* ---------- bottom panel ---------- */
.panel {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px calc(12px + var(--safe-bottom));
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, .14);
}

.roles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--bg2);
  border-radius: 12px;
}

.role {
  min-height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.role[aria-checked="true"] { background: var(--bg); box-shadow: 0 1px 4px rgba(0, 0, 0, .12); }
.role:disabled { color: var(--hint); cursor: default; }

.note { margin: 0; color: var(--hint); font-size: 14px; }

.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.btn.primary { background: var(--btn); color: var(--btn-text); }
.btn.secondary { background: var(--bg2); color: var(--link); }
.btn:disabled { opacity: .55; cursor: default; }

/* ---------- markers ---------- */
.marker {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  font-size: 22px;
  line-height: 40px;
  text-align: center;
  cursor: pointer;
}
.marker.driver { background: #fff4d6; }
.marker.passenger { background: #e3efff; }
.marker.post { background: #ffe4e4; }
.marker.me {
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  background: var(--me);
  box-shadow: 0 0 0 6px rgba(22, 163, 74, .25), 0 2px 6px rgba(0, 0, 0, .3);
  cursor: default;
  pointer-events: none; /* never block taps on a marker underneath */
}

/* ---------- sheet (consent and cards) ---------- */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .35); }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 21;
  max-height: 85vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px calc(16px + var(--safe-bottom));
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, .2);
}

.close {
  position: absolute;
  top: 6px; right: 6px;
  width: 44px; height: 44px;
  border: 0;
  background: transparent;
  color: var(--hint);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.sheet h2 { margin: 0 44px 6px 0; font-size: 19px; overflow-wrap: anywhere; }
.sheet p { margin: 0 0 12px; overflow-wrap: anywhere; }
.sheet .meta { color: var(--hint); }
.sheet .row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.sheet label, .sheet .label { font-weight: 600; }
.sheet .btn + .btn { margin-top: 8px; }

.consent-icon { font-size: 34px; margin-bottom: 6px; }

select, input[type="text"] {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--bg2);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* no zoom-in on iOS */
}

.seats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seat, .choice {
  min-height: 44px;
  border: 2px solid var(--bg2);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.seat[aria-pressed="true"], .choice[aria-checked="true"] { border-color: var(--btn); }
.choice { display: block; width: 100%; padding: 8px 12px; text-align: left; overflow-wrap: anywhere; }
.choices { display: flex; flex-direction: column; gap: 6px; }

.request {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.request strong { display: block; }
.request span { color: var(--link); }

.error { color: var(--danger); }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 16px; right: 16px;
  top: calc(12px + env(safe-area-inset-top, 0px));
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  border-radius: 12px;
  background: rgba(20, 22, 26, .92);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.toast span { flex: 1; overflow-wrap: anywhere; }
.toast-action {
  min-height: 44px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

/* ---------- "open from the bot" screen ---------- */
.blocked {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  text-align: center;
}
.blocked-icon { font-size: 56px; }
.blocked p { max-width: 320px; font-size: 18px; font-weight: 600; }
