/* ═══════════════════════════════════════════
   Layout shell — one screen at a time
   ═══════════════════════════════════════════ */
html, body {
  height: 100%;
  overflow: hidden;
}

html {
  background: #d8d4cc;
}

body {
  font-family: 'Inter', sans-serif;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #fbf9f9;
  position: relative;
}

#map-wrapper {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 0;
}

#map-wrapper.is-hidden {
  visibility: hidden;
  pointer-events: none !important;
}

#app {
  position: relative;
  z-index: 10;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  pointer-events: none;
}

.screen--panel.is-active {
  pointer-events: auto;
}

/* Only ONE screen visible — hidden attr + !important beats Tailwind */
.screen {
  display: none !important;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.screen.is-active {
  display: flex !important;
}

/* Map screens: transparent, show map behind */
.screen--map {
  background: transparent;
}

/* Panel screens: solid background, hide map */
.screen--panel {
  background: #fbf9f9;
}

.screen__header {
  flex-shrink: 0;
  z-index: 2;
}

.screen__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Map screens: transparent overlay — map receives pan/zoom through empty areas */
.screen--map.is-active {
  pointer-events: none;
}

.screen--map.is-active .screen__header,
.screen--map.is-active .screen__sheet,
.screen--map.is-active .collapsible-sheet {
  pointer-events: auto;
}

.screen__map-area {
  flex: 1;
  min-height: 0;
  position: relative;
  pointer-events: none;
}

.screen__map-area > .map-controls,
.screen__map-area > .sheet-expand-fab,
.screen__map-area > .eta-banner {
  pointer-events: auto;
}

.screen__sheet {
  flex-shrink: 0;
  z-index: 2;
}

.screen__sheet-inner {
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 12px 12px 24px;
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
  border-top: 1px solid #d0c6ab;
}

.screen__sheet-handle {
  width: 48px;
  height: 6px;
  background: #d0c6ab;
  border-radius: 999px;
  margin: 0 auto 10px;
}

.collapsible-sheet:not(.sheet--collapsed) .screen__sheet-handle {
  background: #705d00;
}

/* ── Collapsible sheet (tracking only) ── */
.collapsible-sheet {
  flex-shrink: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  transition: max-height 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: min(72vh, 520px);
  overflow: hidden;
}

.collapsible-sheet.sheet--collapsed {
  max-height: 58px;
}

.collapsible-sheet.sheet--dragging {
  transition: none;
}

.sheet-toggle {
  flex-shrink: 0;
  width: 100%;
  border: none;
  background: #fff;
  border-radius: 24px 24px 0 0;
  padding: 12px 16px 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.12);
  border-top: 1px solid #d0c6ab;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.sheet-toggle:active {
  cursor: grabbing;
}

.sheet-drag-label {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 500;
  color: #5f5e5e;
  text-align: center;
}

.sheet-drag-label.is-hidden {
  display: none;
}

.collapsible-sheet.sheet--collapsed .sheet-drag-label {
  display: none;
}

.sheet-toggle:active .screen__sheet-handle {
  background: #705d00;
}

.sheet-peek {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: #1b1c1c;
  padding: 8px 4px 12px;
  min-height: 36px;
}

.sheet-peek-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.collapsible-sheet.sheet--collapsed .sheet-peek {
  display: flex;
}

.collapsible-sheet.sheet--collapsed .screen__sheet-handle {
  margin-bottom: 0;
}

.sheet-body {
  overflow: hidden;
  flex: 1;
  min-height: 0;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.collapsible-sheet.sheet--collapsed .sheet-body {
  opacity: 0;
  pointer-events: none;
  height: 0;
  overflow: hidden;
}

.collapsible-sheet:not(.sheet--collapsed) .sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.collapsible-sheet.sheet--dragging .sheet-body {
  overflow: hidden;
}

.collapsible-sheet:not(.sheet--collapsed) .screen__sheet-inner {
  border-radius: 0;
  box-shadow: none;
  border-top: none;
  padding-top: 0;
}

.is-hidden {
  display: none !important;
}

.sheet-expand-fab {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: #fff;
  border: 1px solid #d0c6ab;
  border-radius: 999px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #705d00;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
  display: none;
  align-items: center;
  gap: 6px;
}

.sheet-expand-fab.is-visible {
  display: flex;
}

body.sheet-collapsed-tracking .map-controls,
body.sheet-collapsed-tariff .map-controls {
  bottom: 80px;
}

body.sheet-collapsed-tracking .sheet-expand-fab,
body.sheet-collapsed-tariff .sheet-expand-fab {
  bottom: 24px;
}

#map-dest-hint-tariff {
  top: auto;
  bottom: 72px;
}

.map-hint {
  position: absolute;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 6;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  padding: 10px 16px;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  border: 1px solid #d0c6ab;
  font-size: 13px;
  font-weight: 600;
  color: #4d4732;
  text-align: center;
  pointer-events: none;
}

/* Bottom nav */
.app-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 50;
  background: #fff;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  padding: 8px 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

/* Map */
#map {
  width: 100%;
  height: 100%;
  background: #e8e4dc;
}

.leaflet-container {
  font-family: 'Inter', sans-serif;
  background: #e8e4dc;
  touch-action: pan-x pan-y pinch-zoom;
}

.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(255, 255, 255, 0.6) !important;
  border-radius: 8px 0 0 0 !important;
  opacity: 0.7;
}

.leaflet-control-zoom { display: none; }

#map .leaflet-tile-pane {
  filter: saturate(0.75) sepia(0.12) hue-rotate(5deg) brightness(1.08) contrast(0.95);
}

.map-vignette {
  position: absolute;
  inset: 0;
  z-index: 401;
  pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(27, 28, 28, 0.12) 100%);
}

.map-warm-overlay {
  position: absolute;
  inset: 0;
  z-index: 402;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,215,0,0.04) 0%, transparent 30%, transparent 60%, rgba(112,93,0,0.06) 100%);
}

.map-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 5;
}

.map-control-btn {
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  border-radius: 50%;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4d4732;
  border: 1px solid rgba(208, 198, 171, 0.5);
}

.map-control-btn:active { transform: scale(0.92); }

.route-pills {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 5;
  pointer-events: none;
}

.route-pill {
  background: rgba(251, 249, 249, 0.95);
  backdrop-filter: blur(8px);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border: 1px solid rgba(208, 198, 171, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
}

/* Markers */
.custom-marker { background: none !important; border: none !important; }
.marker-pin { position: relative; display: flex; align-items: center; justify-content: center; }

.marker-pin--pickup {
  width: 36px; height: 36px; background: #ffd700; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 4px 16px rgba(112, 93, 0, 0.35);
  animation: marker-pulse 2s ease-in-out infinite;
}
.marker-pin--pickup .material-symbols-outlined { font-size: 18px; color: #705e00; font-variation-settings: 'FILL' 1; }

.marker-pin--dest {
  width: 32px; height: 32px; background: #ba1a1a; border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg); border: 3px solid #fff;
}
.marker-pin--dest::after {
  content: ''; width: 10px; height: 10px; background: #fff; border-radius: 50%;
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
}

.marker-pin--driver {
  width: 44px; height: 44px; background: linear-gradient(135deg, #ffd700, #e9c400);
  border-radius: 12px; border: 3px solid #fff; box-shadow: 0 6px 20px rgba(112, 93, 0, 0.4);
}
.marker-pin--driver .material-symbols-outlined { font-size: 24px; color: #705e00; font-variation-settings: 'FILL' 1; }

@keyframes marker-pulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(112, 93, 0, 0.35), 0 0 0 0 rgba(255, 215, 0, 0.5); }
  50% { box-shadow: 0 4px 16px rgba(112, 93, 0, 0.35), 0 0 0 12px rgba(255, 215, 0, 0); }
}

/* UI components */
.material-symbols-outlined { font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24; }
.fill-icon { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24; }

.service-chip {
  background: #e9e8e7; color: #1b1c1c; border: 2px solid transparent;
  border-radius: 12px; padding: 12px 16px; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600;
}
.service-chip.is-active { background: #ffd700; color: #705e00; border-color: #705d00; }

.nav-tab {
  display: flex; flex-direction: column; align-items: center;
  padding: 4px 24px; border-radius: 999px; color: #5f5e5e; border: none; background: none;
}
.nav-tab.is-active { background: #ffd700; color: #705e00; }
.nav-tab .material-symbols-outlined { font-size: 24px; }
.nav-tab span { font-size: 14px; font-weight: 600; }

.tariff-card {
  border: 2px solid transparent; background: #f5f3f3; border-radius: 16px;
  padding: 16px; display: flex; align-items: center; gap: 16px; cursor: pointer;
}
.tariff-card.is-active { border-color: #ffd700; background: #fffbeb; }

.order-card {
  background: #fff; border: 1px solid rgba(208, 198, 171, 0.4);
  border-radius: 16px; padding: 16px;
}

.btn-primary {
  width: 100%; background: #ffd700; color: #705e00; font-weight: 700;
  font-size: 18px; padding: 16px; border-radius: 12px; border: none;
}
.btn-primary:active { transform: scale(0.98); }
.btn-secondary {
  flex: 1; background: #e9e8e7; font-weight: 700; font-size: 16px;
  padding: 14px; border-radius: 12px; border: none;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}

.chips-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { scrollbar-width: none; }

/* Loading */
.loading-overlay {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 100;
  background: rgba(251, 249, 249, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.loading-overlay.is-hidden { display: none !important; }

.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255, 215, 0, 0.3); border-top-color: #705d00;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.app-toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%); z-index: 200;
  background: #303031; color: #f2f0f0; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; max-width: 90%; text-align: center;
}

/* Modals & overlays — stay inside 480px frame */
.modal-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 60;
}

#search-modal {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 50;
}

#pickup-hint {
  position: fixed;
  top: 96px;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  z-index: 40;
  text-align: center;
  pointer-events: none;
}

#pickup-hint > div {
  display: inline-block;
}
.modal-panel.is-hidden { display: none !important; }
.modal-panel:not(.is-hidden) { display: flex; }

#search-modal.is-hidden { display: none !important; }
#search-modal:not(.is-hidden) { display: block; }

.menu-item {
  width: 100%; text-align: left; padding: 12px 16px; border-radius: 12px;
  border: none; background: none; font-size: 16px;
}
.menu-item:active { background: #f5f3f3; }

.chat-bubble { max-width: 80%; padding: 10px 14px; border-radius: 16px; font-size: 15px; }
.chat-bubble--user { align-self: flex-end; background: #ffd700; color: #705e00; }
.chat-bubble--driver { align-self: flex-start; background: #e9e8e7; }
.chat-time { display: block; font-size: 10px; opacity: 0.6; margin-top: 4px; }
#chat-messages { display: flex; flex-direction: column; gap: 12px; }

.payment-option {
  width: 100%; display: flex; align-items: center; gap: 16px; padding: 16px;
  border-radius: 12px; border: 2px solid transparent; background: #f5f3f3; text-align: left;
}
.payment-option.is-active { border-color: #ffd700; background: #fffbeb; }

button, input, select, textarea { touch-action: manipulation; font-family: inherit; }

.eta-banner {
  background: #ffd700; color: #705e00; padding: 14px 20px; border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between; font-weight: 600;
  margin: 12px 16px 0;
}

.profile-link:active { background: #e9e8e7; }

.search-result-item {
  padding: 12px 16px; border-radius: 12px; border: none; background: none;
  width: 100%; text-align: left; display: flex; align-items: center; gap: 12px;
}
.search-result-item:active { background: #f5f3f3; }

.search-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.search-modal__panel {
  position: relative;
  background: #fbf9f9;
  border-radius: 0 0 24px 24px;
  padding: 24px 16px;
  max-height: 85vh;
  overflow-y: auto;
}

.pickup-hint__bubble {
  background: #fff;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  font-size: 12px;
  white-space: nowrap;
}

@keyframes bounce-subtle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}
.animate-bounce-subtle { animation: bounce-subtle 2s ease-in-out infinite; }

#pickup-hint.is-hidden { display: none !important; }
#pickup-hint:not(.is-hidden) { display: block; }