/* ==============================
   AZ Local First RAG Search
   Arizona Desert-Inspired Theme
   ============================== */

:root {
  --primary: #D97706;
  --primary-dark: #B45309;
  --primary-light: #F59E0B;
  --accent: #059669;
  --accent-light: #10B981;
  --bg: #FAFAF7;
  --card-bg: #ffffff;
  --text: #1C1917;
  --text-secondary: #57534E;
  --text-light: #78716C;
  --border: #E7E5E4;
  --border-warm: #D6D3D1;
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 4px 16px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 8px 32px rgba(28, 25, 23, 0.12);
  --shadow-xl: 0 16px 48px rgba(28, 25, 23, 0.16);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ==============================
   Hero Header
   ============================== */

.hero {
  background: linear-gradient(135deg, #DC2626 0%, #D97706 30%, #F59E0B 60%, #D97706 100%);
  color: white;
  padding: 3rem 1.5rem 4rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at 30% 80%, rgba(220, 38, 38, 0.3), transparent 60%),
              radial-gradient(ellipse at 70% 20%, rgba(245, 158, 11, 0.3), transparent 60%);
  pointer-events: none;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.hero-tagline {
  font-size: 1.05rem;
  opacity: 0.9;
  margin-bottom: 2rem;
  font-weight: 400;
}

.search-container {
  max-width: 640px;
  margin: 0 auto;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  transition: box-shadow 0.3s;
}

.search-box:focus-within {
  box-shadow: 0 16px 48px rgba(28, 25, 23, 0.2), 0 0 0 3px rgba(217, 119, 6, 0.3);
}

.search-icon {
  width: 22px;
  height: 22px;
  margin-left: 1.25rem;
  color: var(--text-light);
  flex-shrink: 0;
}

.search-box input {
  flex: 1;
  padding: 1.1rem 1rem;
  border: none;
  font-size: 1.05rem;
  outline: none;
  background: transparent;
  color: var(--text);
  min-width: 0;
}

.search-box input::placeholder {
  color: var(--text-light);
}

.search-box button {
  padding: 0.85rem 1.75rem;
  margin: 0.4rem 0.4rem 0.4rem 0;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  white-space: nowrap;
}

.search-box button:hover {
  background: var(--primary-dark);
}

.search-box button:active {
  transform: scale(0.97);
}

/* ==============================
   Members Toggle
   ============================== */

.search-options {
  display: flex;
  justify-content: center;
  margin-top: 0.75rem;
}

.members-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.members-toggle input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.members-toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.members-toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

/* ==============================
   Geo Filter
   ============================== */

.geo-filter {
  margin-top: 0.75rem;
}

.geo-filter-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.geo-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.geo-select {
  padding: 0.4rem 0.6rem;
  border: 1.5px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 0.82rem;
  font-family: var(--font);
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: border-color 0.2s, background 0.2s;
  appearance: auto;
}

.geo-select:hover,
.geo-select:focus {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.25);
  outline: none;
}

.geo-select option {
  background: var(--text);
  color: white;
}

.result-distance {
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

/* ==============================
   Mock Mode Banner
   ============================== */

.mock-banner {
  background: #FEF3C7;
  color: #92400E;
  text-align: center;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.mock-dot {
  width: 8px;
  height: 8px;
  background: #F59E0B;
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

/* ==============================
   Stats Banner
   ============================== */

.stats-banner {
  display: flex;
  justify-content: center;
  gap: 3rem;
  padding: 1.75rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
}

.stat {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.stat-icon {
  width: 24px;
  height: 24px;
  color: var(--primary);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
  line-height: 1;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

/* ==============================
   Toolbar (Filters + View Toggle)
   ============================== */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.5rem 1rem;
  gap: 1rem;
}

.filter-chips {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0.25rem 0;
  flex: 1;
  min-width: 0;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.chip {
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--border-warm);
  border-radius: 20px;
  background: var(--card-bg);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #FFFBEB;
}

.chip.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.view-toggle {
  display: flex;
  gap: 0.25rem;
  background: var(--card-bg);
  border: 1.5px solid var(--border-warm);
  border-radius: var(--radius-sm);
  padding: 3px;
  flex-shrink: 0;
}

.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:hover {
  color: var(--primary);
  background: #FFFBEB;
}

.toggle-btn.active {
  background: var(--primary);
  color: white;
}

/* ==============================
   Results Area
   ============================== */

.main-content {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  min-height: 300px;
}

.results-container {
  animation: fadeIn 0.3s ease;
}

.result-info {
  color: var(--text-light);
  font-size: 0.88rem;
  margin-bottom: 1rem;
  padding-left: 0.25rem;
}

/* ==============================
   Result Cards
   ============================== */

.result-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  transition: box-shadow 0.2s, border-color 0.2s;
  animation: fadeInUp 0.4s ease both;
}

.result-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-warm);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.result-business {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--primary-dark);
  line-height: 1.3;
}

.result-business a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}

.result-business a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Relevance bar */
.relevance-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.relevance-bar {
  width: 60px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.relevance-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.6s ease;
}

.relevance-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-light);
  white-space: nowrap;
}

.result-location {
  font-size: 0.82rem;
  color: var(--text-light);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.result-title {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.result-title a {
  color: var(--accent);
  text-decoration: none;
}

.result-title a:hover {
  text-decoration: underline;
}

.result-text {
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text);
}

.result-text mark {
  background: #FEF08A;
  color: inherit;
  padding: 1px 3px;
  border-radius: 3px;
}

.result-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.result-contact {
  font-size: 0.8rem;
  color: var(--text-light);
}

.similar-btn {
  padding: 0.35rem 0.85rem;
  border: 1.5px solid var(--accent);
  border-radius: 16px;
  background: transparent;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.similar-btn:hover {
  background: var(--accent);
  color: white;
}

/* Stagger animation for cards */
.result-card:nth-child(1) { animation-delay: 0s; }
.result-card:nth-child(2) { animation-delay: 0.05s; }
.result-card:nth-child(3) { animation-delay: 0.1s; }
.result-card:nth-child(4) { animation-delay: 0.15s; }
.result-card:nth-child(5) { animation-delay: 0.2s; }
.result-card:nth-child(6) { animation-delay: 0.25s; }
.result-card:nth-child(7) { animation-delay: 0.3s; }
.result-card:nth-child(8) { animation-delay: 0.35s; }
.result-card:nth-child(9) { animation-delay: 0.4s; }
.result-card:nth-child(10) { animation-delay: 0.45s; }

/* ==============================
   Empty / Loading / Error States
   ============================== */

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-light);
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.empty-state p {
  font-size: 0.95rem;
  max-width: 400px;
  margin: 0 auto;
}

.loading {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
  font-size: 0.95rem;
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.error-state {
  text-align: center;
  padding: 2rem 1rem;
  color: #DC2626;
  font-size: 0.92rem;
}

/* ==============================
   Map View
   ============================== */

.map-container {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

#map {
  height: 500px;
  width: 100%;
  background: #E5E3DF;
}

/* ==============================
   Modal
   ============================== */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(28, 25, 23, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.3s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  color: var(--text-light);
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close:hover {
  background: var(--border);
  color: var(--text);
}

.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}

.modal-card {
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
  transition: box-shadow 0.2s;
}

.modal-card:last-child {
  margin-bottom: 0;
}

.modal-card:hover {
  box-shadow: var(--shadow-sm);
}

.modal-card-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--primary-dark);
  margin-bottom: 0.25rem;
}

.modal-card-name a {
  color: inherit;
  text-decoration: none;
}

.modal-card-name a:hover {
  text-decoration: underline;
}

.modal-card-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-card-location {
  font-size: 0.78rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

/* ==============================
   Footer
   ============================== */

.footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-light);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

.footer strong {
  color: var(--primary);
  font-weight: 600;
}

/* ==============================
   Animations
   ============================== */

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ==============================
   Responsive
   ============================== */

@media (max-width: 640px) {
  .hero {
    padding: 2rem 1rem 3rem;
  }

  .hero-title {
    font-size: 1.6rem;
  }

  .hero-tagline {
    font-size: 0.92rem;
  }

  .search-box button {
    padding: 0.75rem 1.25rem;
    font-size: 0.88rem;
  }

  .geo-select {
    font-size: 0.78rem;
    padding: 0.35rem 0.5rem;
  }

  .stats-banner {
    gap: 1.5rem;
    padding: 1.25rem 1rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .toolbar {
    padding: 0 1rem 0.75rem;
  }

  .main-content {
    padding: 0 1rem 2rem;
  }

  .result-card {
    padding: 1rem;
  }

  .result-header {
    flex-direction: column;
    gap: 0.4rem;
  }

  .relevance-wrap {
    align-self: flex-start;
  }

  #map {
    height: 350px;
  }

  .modal {
    max-height: 90vh;
    margin: 0.5rem;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .hero {
    padding: 2.5rem 1.5rem 3.5rem;
  }

  .hero-title {
    font-size: 2rem;
  }
}

@media (min-width: 1025px) {
  .hero-title {
    font-size: 2.5rem;
  }

  .result-card {
    padding: 1.5rem;
  }

  #map {
    height: 550px;
  }
}
