:root {
  --bg: #0d0f12;
  --surface: #14171b;
  --surface-2: #1a1e24;
  --surface-3: #21262e;
  --border: #2c313a;
  --text: #f2efe6;
  --text-muted: #9a968c;
  --accent: #f4c430;
  --accent-hover: #e0b32a;
  --accent-ink: #14120a;
  --error: #ff9270;
  --success: #7fd68a;
  --body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

#app {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}

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

/* ---------- topbar ---------- */

#topbar {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(to bottom, rgba(13,15,18,0.92), rgba(13,15,18,0));
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }
#topbar h1 { font-size: 16px; margin: 0; font-weight: 600; }

#modeSwitch {
  display: flex;
  background: var(--surface);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--border);
}
#modeSwitch button {
  border: none;
  background: none;
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}
#modeSwitch button.active { background: var(--accent); color: var(--accent-ink); }

#topbarActions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 36px; height: 36px;
  border-radius: 10px;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- bottom sheet ---------- */

#sheet {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 20;
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 72dvh;
  overflow-y: auto;
}

.sheet-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.sheet-sub { color: var(--text-muted); font-size: 13px; margin: -6px 0 12px; }

.field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.field .dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.field.pickup .dot { background: var(--success); }
.field.dropoff .dot { background: var(--error); }
.field input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.field input::placeholder { color: var(--text-muted); }

#suggestions {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: -4px 0 10px;
  overflow: hidden;
  display: none;
}
#suggestions.visible { display: block; }
.suggestion-item {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--surface-3); }

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: 0.5; cursor: default; }
.btn-secondary { background: var(--surface-3); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: transparent; color: var(--error); border: 1px solid var(--error); }
.btn + .btn { margin-top: 8px; }

.fare-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 8px 0 14px;
}
.fare-amount { font-size: 26px; font-weight: 800; color: var(--accent); }
.fare-note { color: var(--text-muted); font-size: 12px; }

.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--surface-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 4px auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-text { text-align: center; }

.driver-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.driver-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--surface-3);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.driver-info { flex: 1; }
.driver-name { font-weight: 700; font-size: 15px; }
.driver-car { color: var(--text-muted); font-size: 13px; }
.driver-plate {
  display: inline-block;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 3px;
}
.driver-rating { color: var(--accent); font-size: 13px; }

.nav-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
}
.nav-arrow { font-size: 26px; color: var(--accent); width: 30px; text-align: center; }
.nav-text { font-size: 14px; font-weight: 600; flex: 1; }
.nav-meta { color: var(--text-muted); font-size: 12px; margin-top: 2px; }

.stars {
  display: flex;
  gap: 8px;
  justify-content: center;
  font-size: 34px;
  margin: 10px 0 16px;
}
.star { color: var(--surface-3); }
.star.filled { color: var(--accent); }

textarea.comment {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px;
  font-size: 13px;
  resize: none;
  min-height: 60px;
  margin-bottom: 10px;
}

.form-row { margin-bottom: 10px; }
.form-row label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.form-row input, .form-row select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
}

.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13px;
}
.upload-row .status { color: var(--success); font-size: 12px; }
.upload-row label {
  background: var(--surface-3);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
}
.upload-row input[type=file] { display: none; }

.error-banner {
  background: rgba(255, 146, 112, 0.15);
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

#toast {
  position: absolute;
  top: 60px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  display: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
#toast.visible { display: block; }

/* ---------- ride offer overlay (driver) ---------- */

#offerOverlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(13,15,18,0.65);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
#offerOverlay.visible { display: flex; }
#offerCard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  width: 100%;
  max-width: 480px;
}
#offerTimerBar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  margin-bottom: 14px;
  overflow: hidden;
}
#offerTimerFill {
  height: 100%;
  background: var(--accent);
  width: 100%;
}
.offer-fare { font-size: 30px; font-weight: 800; color: var(--accent); text-align: center; margin-bottom: 4px; }
.offer-addr { font-size: 13px; color: var(--text-muted); text-align: center; margin-bottom: 16px; }
.offer-actions { display: flex; gap: 10px; }
.offer-actions .btn { margin-top: 0; }

/* ---------- history list ---------- */

.history-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.history-item:last-child { border-bottom: none; }
.history-addr { color: var(--text-muted); }
.history-fare { font-weight: 700; color: var(--accent); }

/* ---------- admin ---------- */

.admin-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  font-size: 13px;
}
.admin-row-actions { display: flex; gap: 8px; margin-top: 8px; }
.admin-row-actions .btn { padding: 8px; font-size: 12px; margin-top: 0; }

/* ---------- misc ---------- */

.hidden { display: none !important; }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  text-align: center;
  width: 100%;
  padding: 8px;
}

.user-puck {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #3ea6ff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px rgba(62,166,255,0.4);
}
