/* ── Reset & Variables ──────────────────────────────────────────────────────── */
:root {
  --primary:       #2563eb;
  --primary-dark:  #1d4ed8;
  --primary-light: #eff6ff;
  --accent:        #f59e0b;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --surface:       #ffffff;
  --bg:            #f8fafc;
  --error:         #ef4444;
  --radius:        12px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:     0 10px 25px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(155deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%) fixed;
  min-height: 100vh;
  color: var(--text);
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.site-header {
  padding: 2rem 1rem 1.5rem;
  text-align: center;
}
.site-logo {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
}
.site-logo-icon {
  width: 52px; height: 52px;
  background: rgba(255,255,255,.18);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.6rem;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.25);
}
.site-logo-text {
  font-size: 1.9rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.5px;
}
.site-logo-text span { color: var(--accent); }
.site-tagline {
  margin-top: .5rem;
  font-size: .9rem;
  color: rgba(255,255,255,.75);
}

/* ── Main container ─────────────────────────────────────────────────────────── */
.main-container {
  max-width: 1100px;
  margin: 0 auto 3rem;
  padding: 0 1rem;
}

/* ── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: visible;
}

/* ── Tabs ───────────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: var(--radius) var(--radius) 0 0;
  overflow: hidden;
}
.tab-btn {
  flex: 1;
  padding: 1rem 1.5rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: color .2s, background .2s, border-color .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  font-family: inherit;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--surface);
  font-weight: 600;
}
.tab-icon { font-size: 1.1rem; }

/* ── Tab panels ─────────────────────────────────────────────────────────────── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Search layout (form + map side by side) ─────────────────────────────────── */
.search-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 2rem;
  align-items: start;
}
.form-area { min-width: 0; }
.map-area  { min-width: 0; }

/* ── Form groups ────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .4rem;
}
.required { color: var(--error); margin-left: .2rem; }

.form-control {
  width: 100%;
  padding: .65rem 1rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-control.error {
  border-color: var(--error);
  box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}
.form-error {
  font-size: .8rem;
  color: var(--error);
  margin-top: .3rem;
  min-height: 1.1rem;
}

select.form-control {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.5rem;
}
select.form-control:disabled {
  opacity: .55;
  cursor: not-allowed;
  background-color: var(--bg);
}

/* ── Autocomplete ───────────────────────────────────────────────────────────── */
.autocomplete-wrapper { position: relative; }
.autocomplete-list {
  position: absolute;
  top: calc(100% - 1px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  max-height: 220px;
  overflow-y: auto;
  z-index: 1000;
  box-shadow: var(--shadow-md);
  list-style: none;
  padding: 0;
}
.autocomplete-list:empty { display: none; }
.autocomplete-list li {
  padding: .6rem 1rem;
  font-size: .9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s, color .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover,
.autocomplete-list li.ac-active {
  background: var(--primary-light);
  color: var(--primary);
}

/* ── Submit button ──────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  width: 100%;
  padding: .8rem 1.5rem;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .2s, transform .1s, box-shadow .2s;
  text-decoration: none;
  margin-top: .5rem;
  box-shadow: 0 2px 8px rgba(37,99,235,.35);
}
.btn-primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px rgba(37,99,235,.45);
}
.btn-primary:active { transform: scale(.98); }

/* ── Map ────────────────────────────────────────────────────────────────────── */
.map-section h3 {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: .5rem;
  text-transform: uppercase;
  letter-spacing: .6px;
}
#search-map {
  width: 100%;
  height: 340px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: #e8f4f8;
  overflow: hidden;
}
.map-hint {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .4rem;
}

/* ── Results ────────────────────────────────────────────────────────────────── */
.results-section {
  padding: 0 2rem 2rem;
}
.results-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem 0 .85rem;
  border-top: 1px solid var(--border);
}
.results-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}
.results-header h2 span { font-style: italic; color: var(--primary); }
.results-count {
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg);
  padding: .2rem .65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  margin-left: auto;
}

/* ── Results table ──────────────────────────────────────────────────────────── */
.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.results-table thead th {
  background: var(--bg);
  padding: .7rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
.results-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .12s;
  cursor: pointer;
}
.results-table tbody tr:last-child { border-bottom: none; }
.results-table tbody tr:hover { background: var(--primary-light); }
.results-table td { padding: .65rem 1rem; color: var(--text); }
.results-table td.county-badge span {
  display: inline-block;
  padding: .15rem .55rem;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 600;
}
.results-table td.postal-code {
  font-weight: 700;
  color: var(--primary);
  font-size: 1rem;
  white-space: nowrap;
}
.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: .2rem .3rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
  font-size: .85rem;
  vertical-align: middle;
  margin-left: .3rem;
  font-family: inherit;
}
.copy-btn:hover { color: var(--primary); background: var(--primary-light); }

/* ── Alert messages ─────────────────────────────────────────────────────────── */
.alert {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  font-size: .9rem;
  margin: 1rem 0;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
}
.alert-icon { font-size: 1.1rem; flex-shrink: 0; }

/* ── Description paragraph ──────────────────────────────────────────────────── */
.site-description {
  max-width: 680px;
  margin: 1.5rem auto 0;
  font-size: .85rem;
  color: rgba(255,255,255,.7);
  text-align: center;
  line-height: 1.7;
  padding: 0 1rem;
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 1.5rem 1rem 2.5rem;
  color: rgba(255,255,255,.55);
  font-size: .8rem;
}
.site-footer a { color: rgba(255,255,255,.75); }
.site-footer a:hover { color: #fff; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .search-layout {
    grid-template-columns: 1fr;
    padding: 1.5rem;
    gap: 1.5rem;
  }
  .results-section { padding: 0 1.5rem 1.5rem; }
  #search-map { height: 260px; }
}

@media (max-width: 640px) {
  .site-logo-text { font-size: 1.5rem; }
  .tab-btn { padding: .8rem; font-size: .85rem; }

  /* Mobile card table */
  .results-table thead { display: none; }
  .results-table, .results-table tbody,
  .results-table tr, .results-table td { display: block; width: 100%; }
  .results-table tbody tr {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: .2rem .5rem;
    cursor: pointer;
  }
  .results-table td { padding: 0; }
  .results-table td::before {
    content: attr(data-label);
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    display: block;
    margin-bottom: .15rem;
  }
  .results-table td.postal-code {
    grid-column: 2;
    grid-row: 1 / 4;
    align-self: center;
    justify-self: end;
    font-size: 1.1rem;
  }
  .results-table td.postal-code::before { display: none; }
}
