/* RiderShare iPhone webapp */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #667085;
  --border: #d9dde3;
  --primary: #1f6feb;
  --accent: #f5a623;
  --danger: #d1242f;
  --nav: #1b7f3b;
  --nav-text: #ffffff;
  --shadow: 0 4px 16px rgba(0, 0, 0, .18);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --tabbar-h: 58px;
  color-scheme: light;
}

body.night {
  --bg: #0f141b;
  --card: #1a2230;
  --text: #e6e9ef;
  --muted: #9aa4b2;
  --border: #2c3647;
  --primary: #4c8dff;
  --nav: #145c2b;
  --shadow: 0 4px 16px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
a { color: var(--primary); }
h1, h2, h3 { margin: .2rem 0 .6rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; margin-top: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); }
.grow { flex: 1; }
.row { display: flex; gap: .5rem; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

button, .button, input, select, textarea {
  font: inherit;
  color: inherit;
}
button, .button {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 12px;
  padding: .6rem 1rem;
  min-height: 44px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
}
button:active { filter: brightness(.92); }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
button.danger { color: var(--danger); }
button.small { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; }
button.link { border: 0; background: none; color: var(--primary); padding: .3rem 0; min-height: 0; }
button.wide { width: 100%; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .65rem .75rem;
  background: var(--card);
  font-size: 16px; /* iOS: így nem nagyít rá a mezőre */
}
label { display: block; margin-bottom: .7rem; color: var(--muted); font-size: .9rem; }
label input { margin-top: .25rem; color: var(--text); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
}

/* Belépés */
.login {
  height: 100%;
  overflow-y: auto;
  padding: calc(var(--safe-top) + 2rem) 1rem calc(var(--safe-bottom) + 1rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.login .card { width: 100%; max-width: 400px; }
.login h1 { display: flex; align-items: center; gap: .5rem; }
.install-hint p { margin: .4rem 0 0; }
.share-ico { display: inline-block; border: 1px solid var(--border); border-radius: 6px; padding: 0 .3rem; }

/* Térkép */
#app { position: fixed; inset: 0; }
#map-wrap { position: absolute; inset: 0; overflow: hidden; background: #dfe3e8; }
body.night #map-wrap { background: #111; }
#map { position: absolute; inset: 0; }
#map.rotating { transition: transform .5s linear; }
body.night .leaflet-tile-pane .osm-tiles { filter: invert(1) hue-rotate(180deg) brightness(.85) contrast(.9); }
.leaflet-control-attribution { font-size: 9px; }
.leaflet-bottom.leaflet-right { margin-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }
body.navigating .leaflet-bottom.leaflet-right { margin-bottom: var(--safe-bottom); }
.leaflet-control-zoom { display: none; }

.marker-rot { transform: rotate(var(--counter-rot, 0deg)); transition: transform .5s linear; }
.rider-icon {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .45);
  color: #fff; font-weight: 700; font-size: 13px;
  background-size: cover; background-position: center;
}
.rider-label {
  position: absolute; left: 50%; top: 100%;
  transform: translateX(-50%);
  white-space: nowrap;
  background: rgba(0, 0, 0, .65); color: #fff;
  font-size: 11px; border-radius: 6px; padding: 0 5px; margin-top: 2px;
}
.rider-icon.roaming { border-color: var(--accent); }
.me-icon {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: #1f6feb;
  border: 3px solid #fff;
  box-shadow: 0 0 0 6px rgba(31, 111, 235, .25), 0 1px 4px rgba(0, 0, 0, .4);
}
.me-arrow { width: 100%; height: 100%; }
.poi-icon {
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  background: #d1242f; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .4);
}
.poi-icon span { display: grid; place-items: center; width: 100%; height: 100%; transform: rotate(45deg); font-size: 13px; }
.wp-icon {
  display: grid; place-items: center;
  width: 100%; height: 100%;
  border-radius: 50%; background: var(--accent); color: #1b2430;
  font-weight: 700; font-size: 12px; border: 2px solid #fff;
}

/* Felső sáv */
.topbar {
  position: absolute;
  top: calc(var(--safe-top) + 8px); left: calc(var(--safe-left) + 10px); right: calc(var(--safe-right) + 10px);
  display: flex; gap: 8px; z-index: 1000;
}
.topbar select {
  flex: 1; min-width: 0;
  box-shadow: var(--shadow);
  border-radius: 12px;
  font-weight: 600;
  -webkit-appearance: none; appearance: none;
}
.icon-btn {
  width: 46px; padding: 0; font-size: 20px;
  box-shadow: var(--shadow);
}
body.navigating .topbar { display: none; }
/* a paneleken a felső sáv háttere eltakarja az alatta görgetett tartalmat */
body:not([data-tab="map"]) .topbar {
  top: 0; left: 0; right: 0;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 10px) 8px calc(var(--safe-left) + 10px);
  background: var(--bg);
}

/* Gombok a térképen */
.fabs {
  position: absolute;
  right: calc(var(--safe-right) + 10px);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 14px);
  display: flex; flex-direction: column; gap: 10px;
  z-index: 1000;
}
.fab {
  width: 50px; height: 50px; padding: 0;
  border-radius: 50%; font-size: 21px;
  box-shadow: var(--shadow);
}
.fab.big { width: 58px; height: 58px; font-size: 26px; background: var(--primary); color: #fff; border-color: var(--primary); }
.fab.on { background: var(--primary); color: #fff; border-color: var(--primary); }
body.navigating .fabs { top: calc(var(--safe-top) + 10px); bottom: auto; }
body:not([data-tab="map"]):not(.navigating) .fabs,
body:not([data-tab="map"]):not(.navigating) .leaflet-control-container { display: none; }

/* Navigációs panel */
.nav {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  left: calc(var(--safe-left) + 8px);
  width: calc(100% - var(--safe-left) - var(--safe-right) - 82px);
  z-index: 1001;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.nav > * { pointer-events: auto; }
.nav-panel {
  background: var(--nav); color: var(--nav-text);
  border-radius: 18px; box-shadow: var(--shadow);
  padding: 12px 14px;
}
.nav-main { display: flex; gap: 12px; align-items: center; }
.nav-icon { font-size: 46px; line-height: 1; width: 56px; text-align: center; flex: none; }
.nav-dist { font-size: 30px; font-weight: 800; line-height: 1.1; }
.nav-text { font-size: 18px; font-weight: 600; line-height: 1.25; }
.nav-then { margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255, 255, 255, .25); font-size: 15px; }
.nav-bottom { margin-top: 8px; font-size: 15px; opacity: .95; }
.nav-bottom b { font-size: 17px; }

/* Fekvő tájolás (pl. tartóban): a panel balra, legfeljebb a szélesség harmada */
@media (orientation: landscape) {
  .nav { width: calc(33.3% - 8px); min-width: 260px; bottom: 8px; }
  .nav-icon { font-size: 40px; width: 48px; }
  .nav-dist { font-size: 26px; }
  .nav-text { font-size: 16px; }
  .msg-card .text { font-size: 18px; }
}

/* Beérkező üzenet: 30 mp-ig látszik */
.msg-card {
  position: absolute; z-index: 1002;
  left: calc(var(--safe-left) + 8px); right: calc(var(--safe-right) + 8px);
  top: calc(var(--safe-top) + 64px);
  background: var(--card); color: var(--text);
  border-radius: 16px; box-shadow: var(--shadow);
  border-left: 6px solid var(--accent);
  padding: 10px 12px;
  display: flex; gap: 10px; align-items: flex-start;
}
.msg-card .rider-icon { width: 44px; height: 44px; flex: none; }
.msg-card .who { font-weight: 700; font-size: 15px; }
.msg-card .text { font-size: 20px; font-weight: 600; line-height: 1.25; word-break: break-word; }
.msg-card .acts { display: flex; flex-direction: column; gap: 6px; }
.msg-card .acts button { min-height: 40px; padding: .3rem .6rem; }

/* Panelek */
.panel {
  position: absolute; inset: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  background: var(--bg);
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-top) + 64px) calc(var(--safe-right) + 14px) 1.5rem calc(var(--safe-left) + 14px);
  z-index: 999;
}
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: .7rem .8rem; display: flex; gap: .7rem; align-items: center;
}
.list li .rider-icon { width: 40px; height: 40px; flex: none; border-width: 2px; }
.list .title { font-weight: 600; }
.list .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.list li.clickable:active { filter: brightness(.95); }
.points { padding-left: 1.4rem; }
.points li { padding: .5rem 0; border-bottom: 1px solid var(--border); }
.profile { display: flex; gap: .9rem; align-items: center; margin-bottom: 1rem; }
.profile .rider-icon { width: 64px; height: 64px; font-size: 22px; }
.profile .title { font-weight: 700; font-size: 1.15rem; margin-bottom: .3rem; }
.toggle-card { margin-bottom: .8rem; }
.toggle-card p { margin: .5rem 0 0; }
.switch-row { display: flex; gap: 1rem; align-items: center; justify-content: space-between; margin: 0; color: var(--text); font-size: 1rem; }
.switch {
  -webkit-appearance: none; appearance: none;
  width: 52px; height: 32px; flex: none; padding: 0;
  border-radius: 16px; background: #c5cad3; border: 0;
  position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 26px; height: 26px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: left .2s;
}
.switch:checked { background: #34c759; }
.switch:checked::after { left: 23px; }
.messages { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: .55rem .75rem; }
.messages li.mine { border-left: 4px solid var(--primary); }
.messages .meta { font-size: .8rem; color: var(--muted); display: flex; gap: .5rem; align-items: center; }
.messages .meta .grow { flex: 1; }

/* Alsó fülsáv */
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
  display: flex; z-index: 1003;
  background: var(--card); border-top: 1px solid var(--border);
}
.tabbar button {
  flex: 1; border: 0; border-radius: 0; background: none;
  flex-direction: column; gap: 0; font-size: 11px; color: var(--muted);
  position: relative; padding: 4px 0 0;
}
.tabbar button span { font-size: 22px; line-height: 1.1; }
.tabbar button.active { color: var(--primary); font-weight: 600; }
.badge {
  position: absolute; top: 4px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--danger); color: #fff; font-size: 11px; font-style: normal; line-height: 18px;
}
body.navigating .tabbar { display: none; }
body.navigating .fabs { bottom: auto; }

/* Menü-lap */
.sheet {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(0, 0, 0, .35);
  display: flex; align-items: flex-end;
}
.sheet-body {
  width: 100%; max-height: 85%; overflow-y: auto;
  background: var(--card); color: var(--text);
  border-radius: 18px 18px 0 0;
  padding: .5rem 0 calc(var(--safe-bottom) + .5rem);
}
.sheet-body button {
  width: 100%; border: 0; border-radius: 0; justify-content: flex-start;
  min-height: 52px; padding: .6rem 1.2rem; gap: .8rem; background: none; font-size: 17px;
}
.sheet-body button .ico { width: 1.6rem; text-align: center; }
.sheet-body hr { border: 0; border-top: 1px solid var(--border); margin: .3rem 0; }
.sheet-body .sheet-title { padding: .6rem 1.2rem .2rem; font-weight: 700; color: var(--muted); font-size: .9rem; }

/* Párbeszédablak */
dialog { border: 0; padding: 0; background: transparent; color: var(--text); width: min(94vw, 460px); max-height: 90dvh; }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog .card { max-height: 88dvh; overflow-y: auto; }
#dlg-body p { margin: .3rem 0 .7rem; }
.progress { height: 10px; background: var(--border); border-radius: 5px; overflow: hidden; margin: .5rem 0; }
.progress > div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }

.update-banner {
  position: absolute; z-index: 1500;
  left: 10px; right: 10px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 10px);
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: .5rem .8rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.toasts {
  position: absolute; z-index: 2500; left: 0; right: 0;
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 80px);
  display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none;
}
.toast {
  background: rgba(20, 26, 36, .92); color: #fff;
  border-radius: 12px; padding: .55rem .9rem; max-width: 90%;
  font-size: .95rem; box-shadow: var(--shadow);
}
