/* ── Reset / base ─────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin:  0;
  padding: 0;
  height:  100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  color: #1a1a1a;
}

/* ── Map container ─────────────────────────────────────────────────────────── */

#map { width: 100%; height: 100%; }

/* ── Sidebar: positions search panel + answer card ─────────────────────────── */

.sidebar {
  position: absolute;
  top:  10px;
  left: 10px;
  width: 310px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* Prevent sidebar from growing taller than the viewport */
  max-height: calc(100vh - 20px);
}

/* ── Search + time panel ───────────────────────────────────────────────────── */

.panel {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  flex-shrink: 0;
}

/* ── Search row ────────────────────────────────────────────────────────────── */

.search-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 4px;
}

#address-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.88rem;
  outline: none;
  min-width: 0;
  background: #f9fafb;
}
#address-input:focus {
  border-color: #3b82f6;
  background: #fff;
}

#search-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 6px;
  background: #3b82f6;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#search-btn:hover  { background: #2563eb; }
#search-btn:active { background: #1d4ed8; }


/* ── Time row ──────────────────────────────────────────────────────────────── */

.time-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 10px;
}

.time-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
}

#time-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 5px 7px;
  font-size: 0.78rem;
  outline: none;
  min-width: 0;
  background: #f9fafb;
  color: #1a1a1a;
}
#time-input:focus { border-color: #3b82f6; background: #fff; }

.btn-now {
  flex-shrink: 0;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f3f4f6;
  color: #374151;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 8px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-now:hover { background: #e5e7eb; }

/* ── Spotlight bar ─────────────────────────────────────────────────────────── */

.spotlight-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 8px;
  font-size: 0.78rem;
  color: #555;
  border-top: 1px solid #f3f4f6;
}
.spotlight-bar.hidden { display: none; }

.btn-clear-radius {
  border: none;
  background: none;
  color: #3b82f6;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.btn-clear-radius:hover { background: #eff6ff; }

/* ── Answer card ───────────────────────────────────────────────────────────── */

.answer {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  overflow-y: auto;
  /* Scroll if content is taller than remaining viewport height */
  flex-shrink: 1;
  min-height: 0;
}
.answer.hidden { display: none; }

/* ── S6 answer panel inner elements ───────────────────────────────────────── */

.ans-headline {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 6px;
}

.ans-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 0.95rem;
  font-weight: 700;
  flex-shrink: 0;
}
.icon-green .ans-icon { background: #dcfce7; color: #16a34a; }
.icon-red   .ans-icon { background: #fee2e2; color: #dc2626; }
.icon-grey  .ans-icon { background: #f3f4f6; color: #6b7280; }

.ans-text {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  color: #111;
}

.ans-detail { padding: 2px 16px 4px; font-size: 0.85rem; color: #444; }
.ans-until  { padding: 4px 16px; font-size: 0.9rem; font-weight: 500; color: #1d4ed8; }

.ans-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  flex-wrap: wrap;
  gap: 6px;
}
.ans-dist { font-size: 0.78rem; color: #888; }

/* Confidence tier badges */
.badge-high   { background: #dcfce7; color: #166534; }
.badge-medium { background: #fef9c3; color: #854d0e; }
.badge-low    { background: #f3f4f6; color: #4b5563; }

/* ── Zoom prompt ───────────────────────────────────────────────────────────── */

.zoom-prompt {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  padding: 10px 18px;
  border-radius: 20px;
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}
.zoom-prompt.hidden { display: none; }

/* ── Legend ────────────────────────────────────────────────────────────────── */

.legend {
  position: absolute;
  bottom: 30px;
  left:   10px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 8px;
  padding: 10px 14px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  z-index: 10;
  font-size: 0.8rem;
  line-height: 1.7;
}

.legend-title {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin-bottom: 2px;
}

.legend-sub {
  font-size: 0.7rem;
  color: #888;
  margin-bottom: 5px;
}
.legend-sep {
  height: 1px;
  background: #e5e7eb;
  margin: 5px 0 3px;
}

.legend-toggle-row {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #374151;
  user-select: none;
  line-height: 1.7;
}
.legend-toggle-row input[type="checkbox"] {
  width: 13px;
  height: 13px;
  cursor: pointer;
  flex-shrink: 0;
  margin: 0;
}

.swatch {
  display: inline-block;
  width: 12px; height: 4px;
  border-radius: 2px;
  flex-shrink: 0;
}
/* Square swatch for polygon layers (parking lots) */
.swatch-square {
  height: 12px;
  border-radius: 2px;
}

/* ── MapLibre popup override ───────────────────────────────────────────────── */

.parking-popup .maplibregl-popup-tip { display: none; }

.parking-popup .maplibregl-popup-content {
  padding: 0;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  min-width: 220px;
}

.parking-popup .maplibregl-popup-close-button {
  font-size: 1.1rem;
  color: #666;
  padding: 8px 10px;
  line-height: 1;
}
.parking-popup .maplibregl-popup-close-button:hover { color: #111; }

/* ── Shared result elements (popup + answer panel) ─────────────────────────── */

.pu-loading,
.pu-error {
  padding: 16px;
  font-size: 0.9rem;
  color: #555;
}
.pu-error { color: #b91c1c; }

.pu-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px 4px;
}

.pu-dot { font-size: 1rem; line-height: 1; flex-shrink: 0; }
.dot-green { color: #16a34a; }
.dot-red   { color: #dc2626; }
.dot-grey  { color: #9ca3af; }

.pu-title { font-weight: 600; font-size: 1rem; line-height: 1.3; }
.pu-detail { padding: 2px 16px 4px; font-size: 0.85rem; color: #444; }
.pu-until  { padding: 4px 16px; font-size: 0.9rem; font-weight: 500; color: #1d4ed8; }
.pu-warn   { padding: 3px 16px; font-size: 0.82rem; color: #92400e; }

.pu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  flex-wrap: wrap;
  gap: 6px;
}
.pu-dist { font-size: 0.78rem; color: #888; }

/* ── Badges ────────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.badge-official   { background: #dcfce7; color: #166534; }
.badge-unverified { background: #fef9c3; color: #854d0e; }
.badge-unknown    { background: #f3f4f6; color: #4b5563; }

/* ── Copy link button ──────────────────────────────────────────────────────── */

.btn-copy {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: #f9fafb;
  color: #374151;
  font-size: 0.73rem;
  font-weight: 600;
  padding: 3px 9px;
  cursor: pointer;
  white-space: nowrap;
  margin-left: auto;
}
.btn-copy:hover    { background: #f3f4f6; border-color: #9ca3af; }
.btn-copy:disabled { color: #16a34a; border-color: #86efac; background: #f0fdf4; }

/* ── Mobile (≤ 480 px — iPhone 14 width is 390 px) ────────────────────────── */

@media (max-width: 480px) {
  /* Sidebar stretches full-width; children stack normally */
  .sidebar {
    top:   0;
    left:  0;
    right: 0;
    width: auto;
    max-height: none;
    gap: 0;
  }

  /* Search panel: rounded bottom corners only */
  .panel { border-radius: 0 0 10px 10px; }

  /* Answer card: detach from sidebar and become a fixed bottom sheet */
  .answer {
    position: fixed;
    bottom: 0;
    left:   0;
    right:  0;
    width:  auto;
    border-radius: 16px 16px 0 0;
    max-height: 45vh;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    /* Pull-tab indicator */
    padding-top: 8px;
  }
  .answer::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
    margin: 0 auto 4px;
  }

  .legend {
    bottom: 60px;
    left: 8px;
    padding: 8px 10px;
    font-size: 0.75rem;
  }

  .parking-popup .maplibregl-popup-content {
    max-width: calc(100vw - 32px) !important;
  }

  .pu-header { padding: 12px 12px 4px; }
  .pu-detail,
  .pu-until,
  .pu-warn   { padding-left: 12px; padding-right: 12px; }
  .pu-footer { padding: 6px 12px 10px; }
}
