@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');

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

:root {
  --red:       #E53935;
  --red-dark:  #d32f2f;
  --navy:      #192845;
  --gold:      #F4B942;
  --text:      #1a1a1a;
  --muted:     #6b7280;
  --border:    #e5e7eb;
  --bg:        #f9fafb;
  --white:     #ffffff;
  --header-h:  68px;
  --sidebar-w: 360px;
  --radius:    10px;
}

body {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ HEADER */
.site-header {
  background: var(--navy);
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  flex-shrink: 0;
  z-index: 10;
}

.header-logo img {
  height: 44px;
  width: auto;
  display: block;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ LAYOUT */
/*
  Desktop: [sidebar | map]  - sidebar left, map fills right
  Mobile:  [map on top, sidebar below] - DOM order is map first so this is natural
*/
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ MAP */
.map-pane {
  position: relative;
  overflow: hidden;
}

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

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SIDEBAR */
.sidebar-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
}

.sidebar {
  background: var(--white);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
}

.sidebar-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,0.95));
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 2;
}

.sidebar-fade.hidden {
  opacity: 0;
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--muted);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ SEARCH */
.search-section {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex-shrink: 0;
}

.input-row {
  position: relative;
}

#address-input {
  width: 100%;
  padding: 13px 44px 13px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; /* 16px prevents iOS Safari auto-zoom */
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.18s, background 0.18s;
  -webkit-appearance: none;
}

#address-input:focus {
  border-color: var(--red);
  background: var(--white);
}

.clear-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  touch-action: manipulation;
}

.clear-btn:hover {
  color: var(--red);
  background: #fef2f2;
}

#check-btn,
#clear-btn {
  -webkit-tap-highlight-color: transparent;
}

#check-btn {
  width: 100%;
  padding: 14px;
  background: var(--red);
  color: var(--white);
  border: none;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
  box-shadow: 0 3px 14px rgba(229,57,53,0.35);
  touch-action: manipulation;
  min-height: 48px;
}

#check-btn:hover  { background: var(--red-dark); }
#check-btn:active { transform: scale(0.97); }

#check-btn:disabled {
  background: #d1d5db;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.btn-spinner svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ERROR */
#error-msg {
  display: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--red);
  padding: 10px 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  line-height: 1.4;
}

#error-msg.show { display: block; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ RESULT CARD */
/*
  The result is the #1 output - make the price impossible to miss.
  Coloured top bar = zone colour, price is large and navy.
*/
#result-card {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  animation: slide-in 0.2s ease;
}

#result-card[hidden] { display: none; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-zone-bar {
  height: 6px;
}

.result-body {
  padding: 20px;
}

/* Price - the primary output, biggest thing on screen in this section */
.result-price-block {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.result-price {
  font-size: 3rem;
  font-weight: 700;
  line-height: 1;
  color: var(--navy);
  letter-spacing: -1px;
}

.result-charge-label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
}

.result-address {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  margin-bottom: 6px;
  font-weight: 500;
}

.result-distance {
  font-size: 12px;
  color: var(--muted);
}

/* Out of range */
#result-card.out-of-range .result-price {
  font-size: 1.25rem;
  color: #6b7280;
  letter-spacing: 0;
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ZONES LEGEND */
.zones-section {
  flex-shrink: 0;
}

.zones-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid var(--border);
  user-select: none;
  transition: background 0.15s;
}

.zones-toggle::-webkit-details-marker { display: none; }
.zones-toggle:hover { background: var(--bg); }

.chevron {
  transition: transform 0.2s ease;
  color: var(--muted);
  flex-shrink: 0;
}

details[open] .chevron { transform: rotate(180deg); }

.zones {
  padding: 8px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.zone-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 8px;
  border-radius: 8px;
  font-size: 13px;
  transition: background 0.12s;
}

.zone-item:hover { background: var(--bg); }

.zone-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid rgba(0,0,0,0.10);
}

.zone-label { flex: 1; color: var(--muted); font-weight: 500; }
.zone-price { font-weight: 700; color: var(--navy); }
.zone-price--none { color: #9ca3af; }

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ MOBILE
   Key goal on mobile: MAP is the primary visual, form is secondary.
   Layout: header → map (top, tall) → form + result (below, scrollable)
*/
@media (max-width: 768px) {
  :root { --header-h: 58px; }

  .header-logo img { height: 36px; }

  body { overflow: hidden; }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: calc(100dvh - var(--header-h));
  }

  .map-pane {
    min-height: 200px;
  }

  #map {
    height: 100%;
  }

  .sidebar-wrap {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar {
    overflow-y: auto;
  }

  /* Collapse zones on mobile - it's reference, not the primary task */
  .zones-section:not([open]) .zones { display: none; }

  .result-price { font-size: 2.4rem; }
}

@media (max-width: 400px) {
  .search-section { padding: 18px 16px 16px; }
  .result-body    { padding: 16px; }
  .result-price   { font-size: 2rem; }
}
