/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0a0a0a;
  --bg-secondary: #141414;
  --bg-tertiary: #1e1e1e;
  --bg-hover: #2a2a2a;
  --text-primary: #f0f0f0;
  --text-secondary: #999;
  --text-muted: #666;
  --border: #2a2a2a;
  --accent-green: #22c55e;
  --accent-green-dim: #16a34a;
  --accent-yellow: #eab308;
  --accent-red: #ef4444;
  --radius: 8px;
  --radius-lg: 12px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* === Header === */
#header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 56px;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
}

.logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--accent-green) 0%, #4ade80 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-center {
  flex: 1;
  max-width: 480px;
  margin: 0 24px;
}

.search-wrapper {
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

#search:focus {
  border-color: var(--accent-green-dim);
}

#search::placeholder {
  color: var(--text-muted);
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.search-results.hidden { display: none; }

.search-result-item {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.search-result-item:hover { background: var(--bg-hover); }
.search-result-item:last-child { border-bottom: none; }

.search-result-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.search-result-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.header-right {
  min-width: 120px;
  text-align: right;
}

.stats {
  font-size: 13px;
  color: var(--text-secondary);
}

.stats span {
  color: var(--accent-green);
  font-weight: 700;
}

/* === Filter Bar === */
#filter-bar {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: rgba(10, 10, 10, 0.75);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.filter-group {
  display: flex;
  gap: 8px;
}

.filter-selects {
  display: flex;
  gap: 8px;
}

.filter-selects select {
  padding: 5px 28px 5px 12px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  max-width: 220px;
  transition: border-color 0.15s;
}

.filter-selects select:hover {
  border-color: #444;
}

.filter-selects select:focus {
  border-color: var(--accent-green-dim);
}

.filter-btn {
  padding: 5px 14px;
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  color: var(--text-primary);
  border-color: #444;
}

.filter-btn.active {
  color: var(--bg-primary);
  background: var(--accent-green);
  border-color: var(--accent-green);
}

/* === Map === */
#map {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

/* === Leaflet Overrides === */
.dark-popup .leaflet-popup-content-wrapper {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  color: var(--text-primary);
}

.dark-popup .leaflet-popup-content {
  margin: 0;
  min-width: 240px;
}

.dark-popup .leaflet-popup-tip {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.dark-popup .leaflet-popup-close-button {
  color: var(--text-muted);
  font-size: 20px;
}

.dark-popup .leaflet-popup-close-button:hover {
  color: var(--text-primary);
}

/* Cluster markers */
.cluster-marker {
  background: var(--accent-green);
}

.cluster-marker div {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  font-family: var(--font);
  font-weight: 700;
  font-size: 13px;
  color: var(--bg-primary);
  background: var(--accent-green);
  border: 2px solid rgba(34, 197, 94, 0.3);
}

.cluster-md div { background: var(--accent-green-dim); }
.cluster-lg div { background: #15803d; }
.cluster-xl div { background: #166534; }

.leaflet-marker-icon.cluster-marker {
  background: transparent !important;
  border: none !important;
}

/* === Popup Card === */
.popup-card {
  padding: 16px;
}

.popup-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.popup-status.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}

.popup-status.renewal {
  background: rgba(234, 179, 8, 0.15);
  color: var(--accent-yellow);
}

.popup-name {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
  line-height: 1.3;
}

.popup-dba {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.popup-tag {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.popup-address {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.popup-license {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.popup-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-green);
  text-decoration: none;
  transition: opacity 0.15s;
}

.popup-link:hover { opacity: 0.8; }

/* === Grower Profile Page === */
.profile-page {
  min-height: 100vh;
  padding-top: 56px;
  overflow-y: auto;
}

.profile-hero {
  position: relative;
  height: 280px;
  overflow: hidden;
}

.profile-hero #profile-map {
  width: 100%;
  height: 100%;
}

.profile-hero-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 40px 24px;
  background: linear-gradient(transparent, rgba(10,10,10,0.95));
}

.profile-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.profile-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--accent-green);
}

.profile-badge.renewal {
  background: rgba(234, 179, 8, 0.15);
  color: var(--accent-yellow);
}

.profile-name {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-top: 8px;
  line-height: 1.2;
}

.profile-dba {
  font-size: 16px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 32px;
}

.profile-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.profile-card-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.profile-card-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  word-break: break-word;
}

.profile-card-value a {
  color: var(--accent-green);
  text-decoration: none;
}

.profile-card-value a:hover { text-decoration: underline; }

.profile-section {
  margin-top: 32px;
}

.profile-section h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  margin-bottom: 24px;
  transition: color 0.15s;
}

.back-link:hover { color: var(--text-primary); }


/* === County Heatmap Labels === */
.county-label {
  background: transparent !important;
  border: none !important;
  text-align: center;
  pointer-events: none;
}

.county-label-name {
  font-family: var(--font);
  font-size: 10px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.2;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.county-label-count {
  font-family: var(--font);
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.9);
  line-height: 1.2;
}

/* County tooltip */
.county-tooltip {
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  color: var(--text-primary) !important;
  font-family: var(--font) !important;
  font-size: 13px !important;
  font-weight: 600 !important;
  padding: 6px 12px !important;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}

.county-tooltip::before {
  border-top-color: var(--bg-secondary) !important;
}

/* === Loading state === */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  transition: opacity 0.3s;
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

/* === Responsive === */
@media (max-width: 768px) {
  .header-left .tagline { display: none; }
  .header-center { margin: 0 12px; }
  .header-right { min-width: auto; }
  .stats { font-size: 12px; }
  #filter-bar { padding: 8px 12px; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-name { font-size: 24px; }
  .profile-hero-overlay { padding: 24px 20px 16px; }
  .profile-content { padding: 24px 16px 48px; }
}
