/* ============================================================
   Norwich GIS Portal – base stylesheet
   ============================================================ */

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

html, body {
  height: 100%;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: #222;
}

/* ---- Top bar ---- */
#topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 48px;
  background: #1a3a5c;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(0,0,0,.4);
}

#site-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  flex-shrink: 0;
}

#search-container {
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 460px;
  position: relative;
}

#search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 1001;
  max-height: 300px;
  overflow-y: auto;
}
#search-dropdown.hidden { display: none; }
.result-item {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}
.result-item:hover { background: #f5f8ff; }
.result-item:last-child { border-bottom: none; }

#search-input {
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 4px 0 0 4px;
  font-size: 13px;
  outline: none;
}

#search-btn {
  padding: 6px 12px;
  background: #2c6aad;
  color: #fff;
  border: none;
  border-radius: 0;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
#search-btn:hover { background: #1a3a5c; }

#advanced-search-btn { 
  padding: 0 10px; 
  border: solid #ccc; 
  border-left: none; 
  border-radius: 0 4px 4px 0; 
  background: white; 
  cursor: pointer; 
  font-size: 16px; 
  color: #555; 
}
#advanced-search-btn:hover { background: #f0f4ff; }

/* Search results in sidebar */
.search-results-header {
  padding: 8px 0 8px;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 6px;
  color: #555;
  font-size: 13px;
}

.search-results-list {
  overflow-y: auto;
}

.search-result-item {
  padding: 12px 10px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.search-result-item:hover { background: #f0f4f8; }

.result-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.result-label { font-weight: 600; color: #222; flex: 1; font-size: 15px; }
.result-sub { font-size: 12px; color: #888; margin-top: 3px; }
.result-type {
  font-size: 10px;
  color: #fff;
  background: #2c6aad;
  padding: 2px 6px;
  border-radius: 10px;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}

.no-results { padding: 12px 0; color: #666; }

#topbar-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

#topbar-actions button {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}
#topbar-actions button:hover { background: rgba(255,255,255,.28); }

/* ---- Map ---- */
#map {
  position: fixed;
  top: 48px; bottom: 28px; left: 0; right: 0;
  z-index: 0;
}

/* ---- Sidebar ---- */
#sidebar {
  position: fixed;
  top: 48px; bottom: 28px; right: 0;
  width: 440px;
  background: #fff;
  border-left: 1px solid #d0d7de;
  overflow-y: auto;
  z-index: 900;
  box-shadow: -3px 0 10px rgba(0,0,0,.12);
  padding: 12px;
  transition: transform .2s ease;
}

#sidebar.hidden { transform: translateX(100%); }

#sidebar-close {
  position: absolute;
  top: 8px; right: 10px;
  background: none; border: none;
  font-size: 20px; cursor: pointer; color: #666;
}
#sidebar-close:hover { color: #000; }

#sidebar-content { margin-top: 24px; }

/* Parcel card */
.parcel-card h2 {
  font-size: 15px;
  margin-bottom: 10px;
  color: #1a3a5c;
}
.parcel-card .field { margin-bottom: 6px; }
.parcel-card .field-label {
  font-weight: 600;
  color: #555;
  font-size: 11px;
  text-transform: uppercase;
  display: block;
}
.parcel-card .field-value { color: #222; }
.parcel-card .card-links { margin-top: 12px; }
.parcel-card .card-links a {
  display: inline-block;
  margin-right: 10px;
  color: #1a5276;
  text-decoration: none;
  font-size: 13px;
}
.parcel-card .card-links a:hover { text-decoration: underline; }

/* Identify results */
.identify-section h3 {
  font-size: 13px;
  font-weight: 700;
  color: #444;
  margin-bottom: 8px;
  border-bottom: 1px solid #eee;
  padding-bottom: 4px;
}
.identify-feature { margin-bottom: 8px; }
.identify-feature .feat-prop { margin-bottom: 3px; font-size: 13px; }
.identify-feature .feat-label { color: #888; font-size: 11px; }

/* ---- Share modal ---- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal.hidden { display: none; }
.modal-box {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  width: 380px;
  max-width: 95vw;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.modal-box h3 { margin-bottom: 14px; color: #1a3a5c; }
.modal-box input[type="text"] {
  width: 100%; padding: 7px 10px;
  border: 1px solid #ccc; border-radius: 4px;
  font-size: 13px; margin-bottom: 10px;
}
.modal-box button {
  padding: 7px 14px;
  border-radius: 4px; border: none; cursor: pointer;
  font-size: 13px; margin-right: 8px;
}
#share-copy-btn { background: #1a3a5c; color: #fff; }
#share-copy-btn:hover { background: #22527a; }
#share-close-btn { background: #eee; color: #333; }

/* ---- Toast ---- */
#toast {
  position: fixed;
  bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #1a3a5c; color: #fff;
  padding: 10px 20px; border-radius: 6px;
  font-size: 13px; z-index: 4000;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
#toast.show { opacity: 1; pointer-events: auto; }

/* ---- Utilities ---- */
.hidden { display: none !important; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
  #site-title { display: none; }
  #share-btn span, #print-btn span { display: none; }

  /* Sidebar slides up from the bottom, occupying the lower half */
  #sidebar {
    width: 100%;
    height: 50vh;
    top: auto;
    bottom: 28px;
    left: 0;
    right: 0;
    border-left: none;
    border-top: 2px solid #d0d7de;
    box-shadow: 0 -3px 10px rgba(0,0,0,.12);
    transform: translateY(0);
  }
  #sidebar.hidden { transform: translateY(100%); }

  /* Map fills the upper half when sidebar is open */
  #map {
    transition: height 0.2s ease;
  }
}

/* ---- Print ---- */
@media print {
  #topbar, #sidebar, #share-modal, #toast { display: none !important; }
  #map {
    position: static !important;
    width: 100vw !important;
    height: 100vh !important;
  }
  .leaflet-control-container { display: none !important; }
}

/* ---- Search filter bar ---- */
.search-filter-bar {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid #e0e0e0;
  background: #f9f9f9;
  flex-wrap: wrap;
}
.filter-btn {
  padding: 3px 10px;
  border: 1px solid #ccc;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  color: #444;
}
.filter-btn.active {
  background: #3a7abf;
  color: white;
  border-color: #3a7abf;
}
.filter-btn:hover:not(.active) { background: #f0f4ff; }
.reset-filter-btn {
  margin-left: auto;
  font-size: 11px;
  color: #888;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

/* ---- Advanced Search panel ---- */
.advanced-search-panel { padding: 16px; }
.panel-title { margin: 0 0 14px; font-size: 16px; font-weight: 600; color: #333; }
.adv-field { margin-bottom: 12px; }
.adv-field label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; font-weight: 500; }
.adv-input { width: 100%; padding: 7px 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; box-sizing: border-box; }
.adv-num { width: calc(100% - 4px); }
.adv-row { display: flex; gap: 10px; }
.adv-row > div { flex: 1; }
.adv-checkboxes { display: flex; gap: 12px; flex-wrap: wrap; }
.adv-checkboxes label { font-size: 13px; color: #444; font-weight: normal; display: flex; align-items: center; gap: 4px; }
.adv-submit-btn { width: 100%; padding: 9px; background: #3a7abf; color: white; border: none; border-radius: 4px; font-size: 14px; cursor: pointer; margin-top: 4px; }
.adv-submit-btn:hover { background: #2d62a0; }

/* ---- Abutters ---- */
.abutters-section {
  margin-top: 16px;
  border-top: 1px solid #e0e0e0;
  padding-top: 12px;
}
.abutters-section h3 { font-size: 13px; color: #555; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.abutters-controls { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.abutters-controls label { font-size: 13px; color: #555; white-space: nowrap; }
.abut-input { width: 70px; padding: 5px 7px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; }
.abut-btn { padding: 5px 12px; background: #3a7abf; color: #fff; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; }
.abut-btn:hover { background: #2c6aad; }
.abut-header { display: flex; justify-content: space-between; align-items: center; font-size: 13px; color: #555; margin-bottom: 6px; }
.abut-download { font-size: 12px; color: #3a7abf; text-decoration: none; }
.abut-download:hover { text-decoration: underline; }
.abut-list { border: 1px solid #eee; border-radius: 4px; overflow: hidden; max-height: 280px; overflow-y: auto; }
.abut-item { padding: 8px 10px; border-bottom: 1px solid #eee; cursor: pointer; }
.abut-item:last-child { border-bottom: none; }
.abut-item:hover { background: #f5f8ff; }
.abut-address { font-weight: 600; font-size: 13px; color: #222; }
.abut-owner { font-size: 12px; color: #777; }
.abut-loading, .abut-error, .abut-empty { font-size: 13px; color: #888; padding: 8px 0; }
.abut-error { color: #c0392b; }

/* ---- Multi-select / selection panel ---- */
#selection-panel { margin-top: 4px; }
.sel-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 0 6px; border-top: 2px solid #3a7abf; font-size: 13px; font-weight: 600; color: #3a7abf; }
.sel-clear-btn { font-size: 11px; background: none; border: 1px solid #aaa; border-radius: 3px; color: #666; cursor: pointer; padding: 2px 7px; }
.sel-clear-btn:hover { background: #f5f5f5; }
.sel-card { border: 1px solid #d0d8e8; border-radius: 5px; margin-bottom: 6px; overflow: hidden; }
.sel-card-header { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; background: #f0f5ff; cursor: pointer; font-size: 13px; font-weight: 600; color: #222; list-style: none; }
.sel-card-header::-webkit-details-marker { display: none; }
.sel-card-header:hover { background: #e4eeff; }
.sel-remove-btn { background: none; border: none; color: #999; cursor: pointer; font-size: 12px; padding: 0 2px; line-height: 1; }
.sel-remove-btn:hover { color: #c0392b; }
.sel-card-body { padding: 6px 10px 8px; background: #fff; }
.sel-card-body .field { margin-bottom: 4px; }
.sel-card-body .field-label { font-size: 11px; }
.sel-card-body .field-value { font-size: 12px; }

/* abutter list items — hint that shift-click is possible */
.abut-item[data-shift-hint]::after { content: ' (shift to add)'; font-size: 10px; color: #aaa; }
.abut-hint { font-size: 10px; color: #aaa; align-self: center; flex: 1; text-align: center; }

/* abutter item selected state */
.abut-item { user-select: none; }
.abut-item--selected { background: #e8f0fe !important; border-left: 3px solid #3a7abf; padding-left: 7px; }
.abut-item--selected .abut-address { color: #1a4fa0; }

/* ---- Abutter target parcels ---- */
#abut-targets-info { margin-bottom: 6px; min-height: 18px; }
.abut-target-hint { font-size: 11px; color: #aaa; font-style: italic; }
.abut-target-count { font-size: 12px; font-weight: 600; color: #1a8c3a; }
.abut-target-clear { font-size: 11px; background: none; border: 1px solid #aaa; border-radius: 3px; color: #666; cursor: pointer; padding: 1px 6px; margin-left: 8px; }
.abut-target-clear:hover { background: #f5f5f5; }

/* ---- Footer ---- */
#app-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 28px;
  background: #1a3a5c;
  color: rgba(255,255,255,.75);
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  z-index: 1000;
  padding: 0 16px;
}

#app-footer a {
  color: rgba(255,255,255,.9);
  text-decoration: none;
}

#app-footer a:hover { text-decoration: underline; }

.footer-sep { opacity: .4; }

@media print { #app-footer { display: none !important; } }
