/* Force light theme — same reasoning as the desktop app: iOS's dark mode
   otherwise inverts our floating controls to unreadable contrasts. */
html { color-scheme: light; }
html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  background: #fff; color: #222;
  overscroll-behavior: none;   /* stops iOS Safari rubber-band scroll pulling the map */
  -webkit-tap-highlight-color: transparent;
}

/* Google Maps sets its own inline position:relative on the element passed
   to new google.maps.Map(...). Wrap the map div so the fixed positioning
   lives on a wrapper Google Maps doesn't touch. */
#map-wrap { position: fixed; top: 0; right: 0; bottom: 0; left: 0; }
#map { width: 100%; height: 100%; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  padding: max(env(safe-area-inset-top), 8px) 12px 8px;
  display: flex; align-items: center; gap: 8px;
  pointer-events: none; /* only the controls inside catch touches — the map underneath stays draggable */
}
#topbar > * { pointer-events: auto; }
#locate-btn {
  padding: 10px 14px; font: inherit; font-size: 15px; font-weight: 600;
  background: #fff; color: #1a73e8; border: 1px solid #d0d5dd; border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,.2); cursor: pointer;
  min-height: 44px;
}
#locate-btn:active { background: #eef5ff; }
#locate-btn.locating { opacity: .6; }
#topbar-status {
  padding: 6px 10px; font-size: 12px; color: #555;
  background: rgba(255,255,255,.92); border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
  display: none;
}
#topbar-status.visible { display: block; }
#topbar-status.error { color: #a00; }

/* Filter FAB — bottom-right, only appears after "Meu local" places a reference point. */
#filter-fab {
  position: fixed; right: 12px;
  bottom: max(env(safe-area-inset-bottom), 12px);
  z-index: 10;
}
#filter-fab.hidden { display: none; }
#filter-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 16px; font: inherit; font-size: 14px; font-weight: 600;
  background: #1a73e8; color: #fff; border: 0; border-radius: 999px;
  box-shadow: 0 3px 10px rgba(0,0,0,.3); cursor: pointer;
  min-height: 44px;
}
#filter-toggle:active { background: #1558b0; }
.filter-icon { font-size: 18px; line-height: 1; }

/* Filter bottom sheet */
#filter-sheet {
  position: fixed; left: 0; right: 0;
  bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid #d0d5dd;
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  box-shadow: 0 -6px 20px rgba(0,0,0,.25);
  padding: 16px 16px max(env(safe-area-inset-bottom), 16px);
  transform: translateY(0); transition: transform .2s ease-out;
}
#filter-sheet.hidden { transform: translateY(100%); pointer-events: none; }
.filter-sheet-title { font-size: 14px; color: #555; margin-bottom: 12px; }
.filter-sheet-title b { color: #222; }
.filter-sheet-value {
  display: flex; align-items: center; gap: 6px;
  font-size: 32px; font-weight: 700; color: #1a73e8; margin-bottom: 8px;
}
.filter-sheet-value input {
  width: 110px; padding: 4px 6px; font: inherit; font-size: 28px; font-weight: 700;
  border: 1px solid #d0d5dd; border-radius: 6px; text-align: right; color: #1a73e8;
  background: #fff;
}
.filter-sheet-value span { color: #666; font-size: 20px; font-weight: 500; }
#filter-km-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 34px; padding: 0; margin: 8px 0 16px;
  background: transparent; cursor: pointer;
}
#filter-km-slider::-webkit-slider-runnable-track {
  height: 8px; background: #d0d5dd; border-radius: 4px;
}
#filter-km-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 28px; height: 28px; margin-top: -10px; border-radius: 50%;
  background: #1a73e8; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.filter-sheet-actions { display: flex; gap: 8px; }
.filter-sheet-actions button {
  flex: 1; padding: 14px; font: inherit; font-size: 15px; font-weight: 600;
  border-radius: 8px; cursor: pointer; min-height: 48px;
}
.btn-primary { background: #1a73e8; color: #fff; border: 0; }
.btn-primary:active { background: #1558b0; }
.btn-secondary { background: #fff; color: #333; border: 1px solid #d0d5dd; }
.btn-secondary:active { background: #f5f5f5; }

/* Pin details bottom sheet */
#pin-sheet {
  position: fixed; left: 0; right: 0;
  bottom: 0; z-index: 25;
  background: #fff; border-top: 1px solid #d0d5dd;
  border-top-left-radius: 16px; border-top-right-radius: 16px;
  box-shadow: 0 -6px 20px rgba(0,0,0,.28);
  max-height: 75vh; overflow-y: auto;
  transform: translateY(0); transition: transform .2s ease-out;
}
#pin-sheet.hidden { transform: translateY(100%); pointer-events: none; }
.pin-sheet-inner {
  padding: 16px 16px max(env(safe-area-inset-bottom), 16px);
  position: relative;
}
.pin-sheet-close {
  position: absolute; top: 8px; right: 8px;
  width: 40px; height: 40px; border: 0; background: transparent;
  font-size: 22px; color: #666; border-radius: 8px; cursor: pointer;
}
.pin-sheet-close:active { background: #f5f5f5; }
.pin-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 700; color: #222;
  padding-right: 40px; margin-bottom: 4px;
}
.pin-color-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.dot-red { background: #dd4b39; }
.dot-green { background: #34a853; }
.dot-blue { background: #4285f4; }
.dot-yellow { background: #f2b400; }
.pin-meta {
  font-size: 13px; color: #666; line-height: 1.5; margin-bottom: 14px;
  word-break: break-word;
}
.pin-meta .kv { display: block; }
.pin-meta .kv b { color: #333; font-weight: 600; }

.pin-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.pin-actions a, .pin-actions button {
  flex: 1; padding: 12px 8px; font: inherit; font-size: 14px; font-weight: 600;
  border-radius: 8px; text-align: center; text-decoration: none;
  min-height: 44px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.pin-actions .btn-directions { background: #1a73e8; color: #fff; border: 0; }
.pin-actions .btn-directions:active { background: #1558b0; }

.pin-details-block { margin-top: 10px; }
.pin-details-block h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .4px;
  color: #666; font-weight: 700; margin: 0 0 6px;
}
.pin-details-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pin-details-fields .field { padding: 8px 10px; background: #f5f7fa; border-radius: 6px; }
.pin-details-fields .field .label { font-size: 11px; color: #666; font-weight: 600; margin-bottom: 2px; }
.pin-details-fields .field .value { font-size: 13px; color: #222; word-break: break-word; white-space: pre-wrap; }
.pin-details-fields .field .value.empty { color: #aaa; }

.strat-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.strat-table th, .strat-table td { padding: 6px 8px; border: 1px solid #e5e7eb; text-align: left; }
.strat-table th { background: #f0f2f5; font-weight: 600; color: #333; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.strat-table td:first-child, .strat-table td:nth-child(2) { text-align: right; width: 60px; font-variant-numeric: tabular-nums; }
.strat-empty { padding: 12px; background: #f5f7fa; border-radius: 6px; font-size: 12px; color: #888; text-align: center; }

.pin-quote-fields { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; padding: 10px 12px; background: #fffbeb; border: 1px solid #f0d987; border-radius: 8px; }
.pin-quote-fields .field .label { font-size: 11px; color: #7a5900; font-weight: 700; margin-bottom: 2px; }
.pin-quote-fields .field .value { font-size: 14px; color: #222; font-weight: 500; }
.pin-quote-fields .field .value.empty { color: #aaa; font-weight: 400; }

.pin-sheet-loading { padding: 20px; text-align: center; color: #1a73e8; font-size: 13px; }
.pin-sheet-error { padding: 12px; background: #fff3cd; color: #856404; border-radius: 6px; font-size: 12px; }

#snapshot-note {
  position: fixed; left: 12px; bottom: max(env(safe-area-inset-bottom), 12px); z-index: 5;
  padding: 6px 10px; background: rgba(255,255,255,.92); color: #555;
  border-radius: 6px; font-size: 11px; box-shadow: 0 1px 3px rgba(0,0,0,.15);
  max-width: calc(100% - 100px);
}
#snapshot-note.hidden { display: none; }
