/* EnRuta Taxi — misma paleta que la app Flutter */
:root {
  --primary: #ffc107;
  --primary-dark: #000000;
  --accent: #4caf50;
  --bg: #ffffff;
  --surface: #ffffff;
  --divider: #e0e0e0;
  --text: #000000;
  --text-secondary: #757575;
  --chip: #f5f5f5;
  --danger: #d32f2f;
  --radius: 12px;
  --header-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
  background: var(--bg);
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* —— Header negro (como AppBar Flutter) —— */
.app-header {
  flex-shrink: 0;
  height: var(--header-h);
  background: var(--primary-dark);
  color: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 8px 0 4px;
  gap: 4px;
  z-index: 20;
}

.app-header h1 {
  flex: 1;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  color: var(--primary);
}

.app-header .icon-btn {
  width: 44px;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
}

.app-header .icon-btn:active {
  background: rgba(255, 193, 7, 0.15);
}

/* —— Botones —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border: 0;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-dark);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--primary-dark);
  border: 2px solid var(--divider);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  min-height: 40px;
  font-weight: 600;
}

/* —— Forms —— */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: #fafafa;
  font-size: 16px;
  color: var(--text);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--primary);
  border-color: var(--primary);
  background: #fff;
}

.dni-name-box {
  background: #fff8e1;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
  text-align: left;
}

.dni-name-box strong {
  display: block;
  font-size: 16px;
  margin-top: 2px;
  color: var(--primary-dark);
}

.error-box {
  background: #ffebee;
  color: #b71c1c;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 14px;
  margin-bottom: 12px;
  display: none;
}

.error-box.show {
  display: block;
}

.muted {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.4;
}

/* —— Splash / Login (misma sensación app) —— */
.hero-top {
  flex-shrink: 0;
  height: 38vh;
  min-height: 160px;
  max-height: 280px;
  background: var(--primary-dark) center top / cover no-repeat;
  position: relative;
}

.hero-top::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 0, 0.55));
}

.hero-top .brand {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 20px;
  z-index: 1;
  text-align: center;
  color: #fff;
  padding: 0 16px;
}

.hero-top .brand img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.4));
}

.hero-top .brand h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.5px;
}

.login-sheet {
  flex: 1;
  overflow: auto;
  padding: 20px 20px calc(20px + var(--safe-bottom));
  background: #fff;
}

.login-sheet h3 {
  margin: 0 0 6px;
  font-size: 20px;
  text-align: center;
}

.login-sheet .lead {
  text-align: center;
  margin-bottom: 20px;
}

/* —— Home request —— */
.map-wrap {
  flex: 1;
  min-height: 180px;
  position: relative;
  background: #e8e8e8;
  z-index: 1;
  isolation: isolate;
}

#map {
  width: 100%;
  height: 100%;
}

/* Leaflet no debe tapar modales / buscador */
#app.searching-address .map-wrap,
#app.searching-address #map,
#app.searching-address .leaflet-container,
#app.searching-address .leaflet-pane {
  visibility: hidden !important;
  pointer-events: none !important;
}

.map-pin-hint {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -100%);
  z-index: 500;
  pointer-events: none;
  font-size: 36px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35));
}

.sheet {
  flex-shrink: 0;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  padding: 12px 16px calc(16px + var(--safe-bottom));
  max-height: 52vh;
  overflow: auto;
}

.sheet .handle {
  width: 40px;
  height: 4px;
  background: #ddd;
  border-radius: 2px;
  margin: 0 auto 12px;
}

.addr-btn {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  background: #fafafa;
  margin-bottom: 8px;
  cursor: pointer;
}

.addr-btn .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.addr-btn .dot.origin {
  background: var(--accent);
}

.addr-btn .dot.dest {
  background: #ff5722;
}

.addr-btn strong {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 600;
}

.addr-btn span {
  font-size: 14px;
  color: var(--text);
}

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 12px;
  -webkit-overflow-scrolling: touch;
}

.chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 24px;
  border: 1px solid var(--divider);
  background: var(--chip);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-dark);
}

.price-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}

.price-row input {
  flex: 1;
  min-height: 48px;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: #fffde7;
}

.suggest {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  margin-top: -8px;
  margin-bottom: 12px;
}

/* —— Waiting / offers —— */
.waiting-body {
  flex: 1;
  overflow: auto;
  padding: 20px 16px calc(16px + var(--safe-bottom));
  text-align: center;
}

.waiting-body img.illu {
  width: min(180px, 50vw);
  height: auto;
  margin: 12px auto 16px;
  display: block;
}

.offer-card {
  text-align: left;
  border: 1px solid var(--divider);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.offer-card .top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.offer-card .price {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
}

.offer-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.offer-actions .btn {
  flex: 1;
}

/* —— Trip —— */
.trip-status {
  background: var(--accent);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  font-size: 15px;
}

.trip-panel {
  padding: 16px 16px calc(16px + var(--safe-bottom));
  overflow: auto;
}

.trip-panel .driver-name {
  font-size: 18px;
  font-weight: 700;
}

/* —— Overlay search (por encima de Leaflet z-index ~400–1000) —— */
.overlay {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 8000;
  background: #fff;
  flex-direction: column;
  isolation: isolate;
}

.overlay.open {
  display: flex;
}

.overlay .search-bar {
  display: flex;
  gap: 8px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 12px;
  border-bottom: 1px solid var(--divider);
  align-items: flex-start;
  background: #fff;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.overlay .search-bar .icon-btn {
  margin-top: 18px;
  color: var(--primary-dark) !important;
  flex-shrink: 0;
}

.overlay .search-bar input {
  flex: 1;
  width: 100%;
  min-height: 48px;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 16px;
  background: #fffde7;
}

.overlay .search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.suggest-list {
  flex: 1;
  overflow: auto;
  list-style: none;
  margin: 0;
  padding: 0 0 calc(16px + var(--safe-bottom));
  background: #fff;
  position: relative;
  z-index: 1;
  -webkit-overflow-scrolling: touch;
}

.suggest-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.suggest-list li {
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.suggest-list li:active {
  background: #fff8e1;
}

.suggest-list .main {
  font-weight: 600;
  font-size: 15px;
}

.suggest-list .sec {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.toast {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(24px + var(--safe-bottom));
  background: #323232;
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 200;
  display: none;
  text-align: center;
}

.toast.show {
  display: block;
}

.install-modal {
  position: absolute;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.install-modal[hidden] {
  display: none !important;
}

.install-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.install-modal-sheet {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 24px 20px calc(20px + var(--safe-bottom));
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: sheetUp 0.35s ease-out;
}

@keyframes sheetUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.install-logo {
  width: 72px;
  height: 72px;
  object-fit: contain;
  margin: 0 auto 12px;
  display: block;
}

.install-modal-sheet h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  color: var(--primary-dark);
}

.install-lead {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.45;
}

.install-steps {
  text-align: left;
  margin: 0 0 16px;
  padding: 14px 14px 14px 32px;
  background: #fff8e1;
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.5;
  color: var(--primary-dark);
}

.install-steps li {
  margin-bottom: 10px;
}

.install-steps li:last-child {
  margin-bottom: 0;
}

.share-glyph {
  display: inline-flex;
  vertical-align: middle;
  color: #007aff;
  margin: 0 2px;
}

.install-safari-note {
  font-size: 13px;
  margin: 0 0 14px;
  padding: 10px;
  background: #ffebee;
  border-radius: var(--radius);
  color: #b71c1c;
}

.install-modal-sheet .btn {
  margin-top: 6px;
}

.install-fab {
  position: absolute;
  right: 16px;
  bottom: calc(20px + var(--safe-bottom));
  z-index: 250;
  border: 0;
  border-radius: 28px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 800;
  background: var(--primary);
  color: var(--primary-dark);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.install-fab[hidden] {
  display: none !important;
}

.install-fab:active {
  transform: scale(0.97);
}

.update-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  top: calc(10px + env(safe-area-inset-top, 0px));
  z-index: 280;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff8e1;
  border: 2px solid var(--primary);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.update-banner[hidden] {
  display: none !important;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #eee;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 16px auto;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .hero-top {
    height: 100%;
    max-height: none;
    width: 42%;
    min-height: 0;
  }

  #view-login.active {
    flex-direction: row;
  }

  .login-sheet {
    width: 58%;
  }
}
