/* ============ RESET & BASE ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Roboto Condensed', Arial, sans-serif;
  font-weight: 400;
  font-size: 13px;
  color: #333;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: 'Libre Baskerville', Georgia, serif;
  font-weight: 700;
  color: #1F3864;
}

a { color: #1F3864; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ HEADER ============ */
#site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
  padding: 0 16px;
  background: #fff;
  border-bottom: 2px solid #1F3864;
  z-index: 100;
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.header-logo {
  height: 36px;
  width: 36px;
  object-fit: contain;
  border-radius: 4px;
}
.header-title h1 {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.3px;
}
.header-subtitle {
  font-size: 11px;
  color: #666;
  font-weight: 300;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.header-search {
  flex: 0 1 380px;
  margin-left: auto;
  margin-right: 12px;
}
.search-container {
  position: relative;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
#property-search {
  width: 100%;
  height: 34px;
  padding: 0 12px 0 34px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}
#property-search:focus {
  border-color: #1F3864;
  box-shadow: 0 0 0 2px rgba(31,56,100,0.1);
}
.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-top: none;
  border-radius: 0 0 4px 4px;
  max-height: 280px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.search-results.active { display: block; }
.search-result-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}
.search-result-item:hover {
  background: #f0f4fa;
}
.search-result-item .result-owner {
  font-weight: 700;
  color: #1F3864;
}
.search-result-item .result-address {
  color: #666;
  font-size: 11px;
}
.search-result-item .result-lot {
  color: #999;
  font-size: 11px;
  float: right;
}
.header-right {
  display: flex;
  gap: 6px;
}
.header-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 6px 8px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  transition: background 0.15s;
}
.header-btn:hover { background: #f0f0f0; }

/* ============ APP CONTAINER ============ */
#app-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

/* ============ LAYER PANEL (LEFT) ============ */
.panel-left {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border-right: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  z-index: 50;
  transition: margin-left 0.25s ease;
}
.panel-left.collapsed {
  margin-left: -260px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid #e0e0e0;
  background: #fafafa;
}
.panel-header h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn-collapse, .btn-close {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #888;
  padding: 2px 6px;
  border-radius: 3px;
  line-height: 1;
}
.btn-collapse:hover, .btn-close:hover {
  background: #eee;
  color: #333;
}
.btn-expand-layers {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 60px;
  background: #fff;
  border: 1px solid #ddd;
  border-left: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  z-index: 40;
  font-size: 16px;
  color: #666;
  display: none;
  box-shadow: 2px 0 4px rgba(0,0,0,0.1);
}
.btn-expand-layers:hover { background: #f0f0f0; }
.panel-left.collapsed ~ .btn-expand-layers { display: block; }

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

/* Layer Groups */
.layer-group {
  border-bottom: 1px solid #eee;
}
.layer-group-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  color: #444;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  user-select: none;
}
.layer-group-header:hover { background: #f8f8f8; }
.layer-group-header .chevron {
  transition: transform 0.2s;
}
.layer-group.collapsed .chevron {
  transform: rotate(-90deg);
}
.layer-group.collapsed .layer-group-content {
  display: none;
}
.layer-group-content {
  padding: 2px 14px 8px 14px;
}

/* Layer Items */
.layer-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
  font-size: 12px;
}
.layer-item:hover { color: #1F3864; }
.layer-item input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: #1F3864;
  cursor: pointer;
}
.layer-swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  flex-shrink: 0;
}
.layer-name {
  flex: 1;
}
.layer-note {
  display: block;
  width: 100%;
  font-size: 10px;
  color: #999;
  font-style: italic;
  margin-left: 38px;
  margin-top: -4px;
  padding-bottom: 2px;
}

/* Basemap Cards */
.basemap-options {
  display: flex;
  gap: 8px;
  padding: 4px 0;
}
.basemap-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 4px;
  font-size: 11px;
  transition: border-color 0.15s;
}
.basemap-card:hover { border-color: #ccc; }
.basemap-card.active { border-color: #1F3864; }
.basemap-thumb {
  width: 56px;
  height: 40px;
  border-radius: 3px;
  border: 1px solid #ddd;
}

/* ============ MAP ============ */
#map-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
}
#map {
  flex: 1;
  width: 100%;
}

/* Toolbar */
#toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  z-index: 30;
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 12px;
  color: #555;
  transition: all 0.15s;
}
.tool-btn:hover {
  background: #f0f4fa;
  border-color: #d0d8e8;
  color: #1F3864;
}
.tool-btn.active {
  background: #e8eef8;
  border-color: #1F3864;
  color: #1F3864;
}
.tool-separator {
  width: 1px;
  height: 24px;
  background: #ddd;
  margin: 0 4px;
}

/* Measurement Info */
.measure-info {
  position: absolute;
  top: 50px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(31,56,100,0.9);
  color: #fff;
  padding: 6px 30px 6px 14px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  z-index: 25;
  white-space: nowrap;
}
.measure-close {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.measure-close:hover { color: #fff; }

/* ============ RIGHT PANELS ============ */
.panel-right {
  width: 340px;
  min-width: 340px;
  background: #fff;
  border-left: 1px solid #ddd;
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow: hidden;
}
.panel-right .panel-content {
  padding: 12px 14px;
}

/* Property Info */
.prop-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 12px;
}
.prop-row:last-child { border-bottom: none; }
.prop-label {
  color: #777;
  font-weight: 400;
  flex-shrink: 0;
  width: 120px;
}
.prop-value {
  text-align: right;
  font-weight: 700;
  color: #333;
  word-break: break-word;
}
.prop-section-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1F3864;
  margin: 12px 0 6px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid #1F3864;
}
.prop-section-title:first-child { margin-top: 0; }
.btn-vision-link {
  display: block;
  text-align: center;
  padding: 8px;
  margin-top: 12px;
  background: #1F3864;
  color: #fff;
  border-radius: 4px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-vision-link:hover { background: #2a4f8a; text-decoration: none; }

/* Abutters */
.abutters-selected {
  padding: 8px 0;
  font-size: 12px;
}
.abutters-selected strong { color: #1F3864; }
.abutters-buffer-control {
  padding: 8px 0;
}
.abutters-buffer-control label {
  font-size: 12px;
  font-weight: 700;
  color: #555;
  display: block;
  margin-bottom: 4px;
}
.buffer-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
#buffer-distance {
  flex: 1;
  accent-color: #1F3864;
}
#buffer-distance-label {
  font-weight: 700;
  font-size: 13px;
  color: #1F3864;
  min-width: 60px;
  text-align: right;
}
.btn-primary {
  display: block;
  width: 100%;
  padding: 10px;
  background: #1F3864;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.15s;
}
.btn-primary:hover { background: #2a4f8a; }
.btn-secondary {
  padding: 6px 12px;
  background: #fff;
  color: #1F3864;
  border: 1px solid #1F3864;
  border-radius: 4px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-secondary:hover { background: #f0f4fa; }
.abutters-summary {
  padding: 8px 0;
  font-size: 13px;
  font-weight: 700;
  color: #1F3864;
}
.abutters-export-btns {
  display: flex;
  gap: 6px;
  padding: 4px 0 10px 0;
}
#abutters-table-container {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
}
#abutters-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
#abutters-table th {
  background: #f5f7fa;
  padding: 6px 8px;
  text-align: left;
  font-weight: 700;
  color: #1F3864;
  border-bottom: 1px solid #ddd;
  position: sticky;
  top: 0;
}
#abutters-table td {
  padding: 5px 8px;
  border-bottom: 1px solid #f0f0f0;
}
#abutters-table tr:hover td { background: #f8f9fc; }

/* CSV Upload */
.csv-instructions {
  font-size: 12px;
  color: #666;
  margin-bottom: 12px;
}
.csv-upload-area {
  border: 2px dashed #ccc;
  border-radius: 6px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: #999;
}
.csv-upload-area:hover, .csv-upload-area.dragover {
  border-color: #1F3864;
  background: #f8f9fc;
}
.csv-upload-area p { font-size: 12px; margin-top: 8px; }
.csv-summary {
  padding: 10px 0;
  font-size: 13px;
  font-weight: 700;
  color: #1F3864;
}

/* ============ FOOTER ============ */
#site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 26px;
  padding: 0 16px;
  background: #fff;
  border-top: 1px solid #e0e0e0;
  font-size: 11px;
  color: #888;
  flex-shrink: 0;
}
.footer-sep { color: #ddd; }
#site-footer a { color: #666; }
#site-footer a:hover { color: #1F3864; }

/* ============ MAP POPUP ============ */
.maplibregl-popup-content {
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.maplibregl-popup-close-button {
  font-size: 16px;
  padding: 2px 6px;
}
.popup-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 12px;
  font-weight: 700;
  color: #1F3864;
  margin-bottom: 4px;
}
.popup-line { color: #555; font-size: 11px; }

/* ============ MAPLIBRE OVERRIDES ============ */
.maplibregl-ctrl-group button {
  width: 30px;
  height: 30px;
}
.maplibregl-ctrl-attrib {
  font-size: 10px;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
  .panel-left { width: 220px; min-width: 220px; }
  .panel-right { width: 300px; min-width: 300px; }
}
@media (max-width: 768px) {
  .panel-left { position: absolute; left: 0; top: 0; bottom: 0; width: 260px; box-shadow: 2px 0 8px rgba(0,0,0,0.2); }
  .panel-right { position: absolute; right: 0; top: 0; bottom: 0; width: 300px; box-shadow: -2px 0 8px rgba(0,0,0,0.2); }
  .header-search { flex: 0 1 200px; }
  .header-title h1 { font-size: 14px; }
  .tool-btn span { display: none; }
}

/* Print-specific styles */
@media print {
  #site-header, #toolbar, #site-footer, .panel-left, .panel-right, .btn-expand-layers { display: none !important; }
  #map-wrapper { position: absolute; top: 0; left: 0; right: 0; bottom: 0; }
}
