/* Rebuilt mobile-first CSS: larger text, simplified layout, no cards */
/* Base scaling for mobile readability */
body.mobile-ui {
  font-size: 110%; /* slightly larger base but not huge */
  line-height: 1.3;
  -webkit-text-size-adjust: 100%;
}

/* Remove card visuals: make address entries plain list items */
#routeList, #routeTable {
  margin: 0;
  padding: 0;
  list-style: none;
}

#routeList > div,
#routeList [data-address-index],
#routeTable [data-address-index],
.address-item {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  border-radius: 0 !important;
  margin: 0 !important;
  padding: 10px 0 !important; /* slightly larger separation between rows */
  display: block;
  border-bottom: 1px solid #e5e7eb; /* subtle divider */
}
/* Hover and focus states for clarity */
.address-item:hover { background: #f8fafc; }
.address-item:focus-within { background: #f8fafc; }

/* XHR overlay + spinner */
.xhr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.xhr-overlay.active { opacity: 1; pointer-events: auto; }
.xhr-progress-wrap {
  width: min(720px, 92%);
  max-width: 720px;
  background: rgba(255,255,255,0.98);
  padding: 14px 16px;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(2,6,23,0.24);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}
.xhr-progress-label { font-weight: 600; color: #0f172a; font-size: 1rem; }
.xhr-progress {
  height: 12px;
  background: #eef2ff;
  border-radius: 9px;
  overflow: hidden;
}
.xhr-progress .bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg,#3b82f6,#6366f1);
  transition: width 220ms linear;
}
.xhr-progress-meta { display:flex; justify-content:space-between; font-size:0.9rem; color:#374151 }

/* Small utility for screen-reader-only text */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Autocomplete dropdown for address input */
.autocomplete-wrapper { position: relative; }
.autocomplete-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(2,6,23,0.08);
  max-height: 220px;
  overflow: auto;
  z-index: 1200;
}
.autocomplete-list.hidden { display: none; }
.autocomplete-item {
  padding: 8px 10px;
  font-size: 0.95rem;
  color: #0f172a;
  cursor: pointer;
}
.autocomplete-item:hover, .autocomplete-item.active {
  background: #f1f5f9;
}
.autocomplete-item .small { display:block; font-size:0.85rem; color:#6b7280; }
/* Select button inside suggestion */
.autocomplete-select {
  float: right;
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
}
.autocomplete-select:active { transform: translateY(1px); }

/* Make the address text very prominent */
#routeList [data-address-index] .address-text,
#routeList [data-address-index],
#routeTable [data-address-index] {
  font-size: 1em; /* uses large base */
  color: #111827;
}

/* Buttons: full width, large and touch-friendly */
button,
touch-btn,
move-up,
move-down,
form button[type="submit"] {
  display: block;
  width: 100%;
  font-size: 1em;
  padding: 10px 14px;
  border-radius: 10px;
}

/* Inputs and textarea bigger */
input[type="text"], textarea {
  font-size: 1em;
  padding: 8px 10px;
}

/* Map behavior: hide by default on small screens, keep accessible via toggle */
#mapContainer.collapsed {
  display: none !important;
}

@media (max-width: 768px) {
  #mapContainer.collapsed { display: none !important; }
  .map-toggle { display: block; }
}

/* Floating map toggle button */
.map-toggle {
  position: fixed;
  right: 14px;
  bottom: 18px;
  z-index: 60;
}
.map-toggle button {
  background: #2563eb;
  color: #fff;
  border: none;
  padding: 12px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.12);
  font-size: 1.05em;
}

/* Map size when visible */
#map {
  height: 34vh !important;
  min-height: 160px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(15,23,42,0.06);
}

/* Touch button variant */
.touch-btn {
  padding-top: 14px;
  padding-bottom: 14px;
  padding-left: 18px;
  padding-right: 18px;
  font-size: 1.15em;
  min-height: 50px;
}
.touch-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Minor spacing tweaks */
body.mobile-ui .max-w-4xl { padding: 0.8rem; }

/* Ensure headings are legible */
body.mobile-ui h1, body.mobile-ui h2, body.mobile-ui h3 {
  font-size: 1.05em;
}

/* Dragging visual for swipe-to-reorder */
.address-item.dragging,
.address-item.dragging * {
  pointer-events: none;
}
.address-item.dragging {
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  background: #fff;
  transform: translateZ(0);
}

/* Drag handle visuals */
.drag-handle {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  border-radius: 8px;
  transition: background-color 120ms ease;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  touch-action: none;
}
.drag-handle:hover {
  background-color: rgba(0, 0, 0, 0.05);
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:focus { outline: 3px solid rgba(37,99,235,0.18); }
.drag-handle svg { width: 20px; height: 20px; pointer-events: none; }

/* Sortable classes */
.sortable-ghost { opacity: 0.5; }
.sortable-chosen { box-shadow: 0 10px 24px rgba(0,0,0,0.14); }

/* Ensure mobile styles apply even without `mobile-ui` class */
@media (max-width: 768px) {
  body {
    font-size: 100%;
    line-height: 1.25;
    -webkit-text-size-adjust: 100%;
  }

  /* Layout adjustments */
  .max-w-4xl { padding: 0.8rem; }
  h1, h2, h3 { font-size: 1.05em; }

  /* Address list: plain stacked rows */
  #routeList, #routeTable { margin: 0; padding: 0; }
  #routeList > div, #routeList [data-address-index], .address-item { padding: 10px 0 !important; }
  /* Make each address row a single horizontal line: drag handle + text */
  .address-item { display: flex !important; align-items: center; gap: 10px; }
  .address-text { font-size: 1em; flex: 1 1 auto; display: block; margin-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* Controls inline on wide screens but stacked on small screens */
  .controls { display: flex; gap: 8px; }
  .controls button { flex: 1; }

  /* Inputs and buttons larger */
  input[type="text"], textarea { font-size: 1em; }
  button, .touch-btn, form button[type="submit"] { font-size: 1em; padding: 10px 14px; }

  /* Make drag handle easier to hit and keep inline */
  .drag-handle { width: 48px; height: 48px; flex: 0 0 48px; display: inline-flex; align-items: center; justify-content: center; order: 0; }
  .address-text { order: 1; }
  /* Force row direction in case other styles set column */
  .address-item { flex-direction: row !important; }
}

