/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Tokens ── */
:root {
  --bg:            #f8f8f8;
  --surface:       #ffffff;
  --surface-2:     #f2f2f2;
  --text:          #111111;
  --text-2:        #555555;
  --border:        #e2e2e2;
  --accent:        #111111;
  --accent-hover:  #333333;
  --verified:      #1a6b3c;
  --danger:        #b91c1c;
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.06);
  --shadow-md:     0 6px 24px rgba(0,0,0,0.10);
  --shadow-lg:     0 12px 40px rgba(0,0,0,0.13);
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     14px;
  --radius-pill:   999px;
  --font:          "Segoe UI", system-ui, -apple-system, sans-serif;
  --transition:    0.18s ease;
}

/* ── Base ── */
html, body { height: 100%; font-family: var(--font); color: var(--text); background: var(--bg); overflow: hidden; }
.hidden { display: none !important; }

/* ── Map ── */
#map { position: fixed; inset: 0; z-index: 0; }
.leaflet-tile-pane { filter: grayscale(100%) contrast(1.04); }
.leaflet-div-icon { background: transparent; border: none; }
.leaflet-control-zoom { border: 1px solid var(--border) !important; border-radius: var(--radius-sm) !important; box-shadow: var(--shadow-sm) !important; }
.leaflet-control-zoom a {
  background: var(--surface) !important;
  color: var(--text) !important;
  border-bottom: 1px solid var(--border) !important;
  line-height: 28px !important;
  width: 28px !important;
  height: 28px !important;
  font-size: 15px !important;
}
.leaflet-control-zoom a:hover { background: var(--surface-2) !important; }

/* ── Header ── */
.header {
  position: fixed;
  top: 4.5rem;
  left: 0;
  z-index: 500;
  padding: 1rem 1.25rem;
  pointer-events: none;
  user-select: none;
}
.header h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.header-title-row { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.header-logo {
  display: block;
  width: 22px;
  height: 22px;
  max-width: 22px;
  max-height: 22px;
  min-width: 22px;
  min-height: 22px;
  object-fit: contain;
  flex-shrink: 0;
}
.subtitle { font-size: 0.775rem; color: var(--text-2); margin-top: 0.2rem; }

/* ── Search ── */
.search-container {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 700;
  width: min(420px, calc(100% - 2rem));
}

.search-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0.6rem 0.875rem;
  box-shadow: var(--shadow-md);
  transition: box-shadow var(--transition), border-color var(--transition);
}
.search-box:focus-within {
  border-color: #aaa;
  box-shadow: var(--shadow-lg);
}

.search-icon { color: var(--text-2); flex-shrink: 0; }

.search-input {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  min-width: 0;
}
.search-input::placeholder { color: #aaa; }

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--surface-2);
  color: var(--text-2);
  cursor: pointer;
  padding: 3px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
  line-height: 0;
}
.search-clear:hover { background: var(--border); color: var(--text); }

.search-results {
  list-style: none;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: pop-in 0.16s ease forwards;
}

@keyframes pop-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 0.625rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active { background: var(--surface-2); }

.result-icon { color: var(--text-2); flex-shrink: 0; margin-top: 1px; }
.result-name { font-size: 0.875rem; font-weight: 500; line-height: 1.3; color: var(--text); }
.result-sub  { font-size: 0.73rem; color: var(--text-2); margin-top: 0.1rem; line-height: 1.4; }
.search-empty { padding: 0.875rem 1rem; font-size: 0.85rem; color: var(--text-2); text-align: center; }

/* ── Panel ── */
.panel {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  width: min(460px, 100%);
  max-height: 82vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem 1.375rem 2rem;
  transition: transform 0.26s cubic-bezier(0.32,0.72,0,1), opacity 0.2s ease;
}
.panel.hidden {
  transform: translate(-50%, 100%);
  opacity: 0;
  pointer-events: none;
}

.panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  line-height: 0;
}
.panel-close:hover { background: var(--border); color: var(--text); }

.panel h2 { font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; padding-right: 2.5rem; }
.panel-coords { font-size: 0.73rem; color: var(--text-2); margin-top: 0.3rem; font-variant-numeric: tabular-nums; }

/* ── Form ── */
.form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.25rem; }

.field { display: flex; flex-direction: column; gap: 0.375rem; border: none; padding: 0; }

.field-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
}

.field legend {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 0.375rem;
}

.field input[type="date"],
.field input[type="time"],
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(17,17,17,0.08);
}
.field textarea { resize: vertical; min-height: 3.5rem; line-height: 1.5; }

/* Radio group */
.radio-group { display: flex; gap: 0.5rem; }
.radio-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  user-select: none;
}
.radio-label:has(input:checked) { border-color: var(--accent); background: var(--surface-2); }
.radio-label input { accent-color: var(--accent); width: 14px; height: 14px; }

/* Checkbox */
.checkbox-field { flex-direction: row; align-items: center; gap: 0.5rem; cursor: pointer; }
.checkbox-field input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); flex-shrink: 0; }
.checkbox-label { font-size: 0.875rem; color: var(--text); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.1rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: #999; }

.btn-ghost { background: transparent; color: var(--text-2); border-color: transparent; padding: 0.5rem 0.75rem; font-size: 0.8rem; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: transparent; color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: #fef2f2; }

.btn-success { background: transparent; color: var(--verified); border-color: #6ee7b7; }
.btn-success:hover:not(:disabled) { background: #f0fdf4; }

.btn-sm { padding: 0.45rem 0.75rem; font-size: 0.8rem; border-radius: var(--radius-sm); }

/* ── Details view ── */
.details { display: flex; flex-direction: column; gap: 0.875rem; }
.detail-meta {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
}
.detail-meta strong { font-weight: 600; color: var(--text-2); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.detail-route { font-size: 0.875rem; color: var(--text-2); white-space: pre-wrap; line-height: 1.6; }
.detail-badges { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: 0.73rem;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-2);
}
.badge.verified { color: var(--verified); border-color: #6ee7b7; background: #f0fdf4; }
.badge.going    { color: #1d4ed8;         border-color: #93c5fd; background: #eff6ff; }

/* ── Hint ── */
.hint { font-size: 0.75rem; color: var(--text-2); text-align: center; line-height: 1.5; }
.hint.warn { color: var(--danger); }

/* ── Owner cancel section ── */
.panel-divider { border: none; border-top: 1px solid var(--border); margin: 0.25rem 0 0; }
.owner-cancel-section { display: flex; flex-direction: column; gap: 0.6rem; }
.owner-cancel-section .btn { width: 100%; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 1.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 0.625rem 1.125rem;
  background: #111;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-md);
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
}
.toast.hidden { opacity: 0; transform: translate(-50%, 6px); pointer-events: none; }

/* ── Admin trigger ── */
.admin-trigger {
  position: fixed;
  bottom: 0;
  right: 0;
  z-index: 400;
  width: 52px;
  height: 52px;
  border: none;
  background: transparent;
  cursor: default;
  opacity: 0.01;
}
.admin-trigger:hover { opacity: 0.03; }

/* ── Modals ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  padding: 1rem;
  backdrop-filter: blur(2px);
  animation: fade-in 0.18s ease forwards;
}
.modal.hidden { display: none; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: min(360px, 100%);
  box-shadow: var(--shadow-lg);
  animation: slide-up 0.2s ease forwards;
}
.modal-wide { width: min(620px, 100%); max-height: 80vh; overflow-y: auto; }

@keyframes slide-up { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: var(--surface-2);
  border-radius: 50%;
  cursor: pointer;
  color: var(--text-2);
  transition: background var(--transition), color var(--transition);
  line-height: 0;
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-title { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; padding-right: 2rem; margin-bottom: 1.25rem; }

.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.admin-header .modal-title { margin-bottom: 0; }

/* ── Admin list ── */
.admin-list { display: flex; flex-direction: column; gap: 0.75rem; }
.admin-empty { font-size: 0.875rem; color: var(--text-2); text-align: center; padding: 1.5rem 0; }

.admin-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.125rem;
  font-size: 0.875rem;
  line-height: 1.6;
  transition: border-color var(--transition);
}
.admin-item:hover { border-color: #ccc; }
.admin-item.cancelled { opacity: 0.45; }

.admin-item-title { font-weight: 600; font-size: 0.9rem; margin-bottom: 0.2rem; }
.admin-item-meta  { font-size: 0.8rem; color: var(--text-2); margin-bottom: 0.75rem; line-height: 1.6; }

.admin-item textarea {
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.825rem;
  background: var(--bg);
  color: var(--text);
  resize: vertical;
  min-height: 3rem;
  margin-bottom: 0.625rem;
  transition: border-color var(--transition);
}
.admin-item textarea:focus { outline: none; border-color: var(--accent); }

.admin-item-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }

/* ── User location dot ── */
.user-dot {
  position: relative;
  width: 20px;
  height: 20px;
}
.user-dot::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #2563eb;
  border: 2px solid #fff;
  box-shadow: 0 1px 5px rgba(37,99,235,0.45);
  z-index: 1;
}
.user-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(37,99,235,0.22);
  animation: pulse 2.2s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(1);   opacity: 0.8; }
  100% { transform: scale(3.2); opacity: 0; }
}

/* ── Rideout markers ── */
.ride-marker-wrap {
  position: relative;
  background: transparent !important;
  border: none !important;
}
.ride-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #111;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.ride-dot.verified { background: var(--verified); }
.ride-dot.cancelled-pending {
  background: #fff;
  border-color: var(--danger);
  opacity: 0.85;
  animation: cancelled-pulse 1.6s ease-in-out infinite;
}
@keyframes cancelled-pulse {
  0%, 100% { opacity: 0.85; }
  50%      { opacity: 0.35; }
}
.ride-check {
  position: absolute;
  top: -8px;
  left: 6px;
  width: 14px;
  height: 14px;
  background: var(--verified);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* Verified badge next to panel title */
.title-verified {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  background: #f0fdf4;
  color: var(--verified);
  border: 1px solid #6ee7b7;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
  letter-spacing: 0.02em;
}

/* Cancelled badge next to panel title */
.title-cancelled {
  display: inline-flex;
  align-items: center;
  margin-left: 0.5rem;
  padding: 0.15rem 0.5rem;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.badge.cancelled { color: var(--danger); border-color: #fca5a5; background: #fef2f2; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .header { padding: 0.75rem 1rem; }
  .panel { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .radio-group { flex-direction: column; }
  .admin-item-actions { flex-direction: column; }
  .admin-item-actions .btn { width: 100%; }
}
