/* ==========================================================================
   AFRISOEK TOEP (APP) — DESIGN SYSTEM & TOKENS
   Features: Full Dark Mode & Light Mode, Glassmorphism, Micro-Animations
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* LIGHT MODE TOKENS (Default fallback) */
  --bg-app: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-card-hover: #F1F5F9;
  --bg-input: #F1F5F9;
  --bg-glass: rgba(255, 255, 255, 0.85);

  --text-main: #0F172A;
  --text-muted: #64748B;
  --text-sub: #475569;
  --text-inverse: #FFFFFF;

  --border-subtle: #E2E8F0;
  --border-focus: #3B82F6;

  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --primary-light: #EFF6FF;
  --primary-glow: rgba(37, 99, 235, 0.2);

  --accent-green: #059669;
  --accent-green-light: #ECFDF5;
  --accent-wa: #25D366;
  --accent-orange: #EA580C;
  --accent-red: #DC2626;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.25);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  /* DARK MODE TOKENS */
  --bg-app: #0B132B;
  --bg-surface: #111C3A;
  --bg-card: #152248;
  --bg-card-hover: #1E2D5A;
  --bg-input: #1C2B54;
  --bg-glass: rgba(17, 28, 58, 0.85);

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-sub: #CBD5E1;
  --text-inverse: #0F172A;

  --border-subtle: #1E2D5A;
  --border-focus: #38BDF8;

  --primary: #38BDF8;
  --primary-hover: #0EA5E9;
  --primary-light: rgba(56, 189, 248, 0.15);
  --primary-glow: rgba(56, 189, 248, 0.35);

  --accent-green: #10B981;
  --accent-green-light: rgba(16, 185, 129, 0.15);
  --accent-wa: #25D366;
  --accent-orange: #F59E0B;
  --accent-red: #EF4444;

  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 8px -1px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 24px -4px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px rgba(56, 189, 248, 0.3);
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  overflow-x: hidden;
}

h1, h2, h3, h4, .brand-title {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* App Container (Responsive Mobile-first wrapper) */
.app-container {
  width: 100%;
  max-width: 768px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--bg-surface);
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.15);
}

@media (min-width: 1024px) {
  .app-container {
    max-width: 1100px;
  }
}

/* Header & Navbar */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  cursor: pointer;
}

.beagle-logo-img {
  height: 40px;
  width: auto;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
  transition: transform var(--transition-fast);
}

.beagle-logo-img:hover {
  transform: scale(1.05) rotate(-3deg);
}

.brand-text-col {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 1.35rem;
  color: var(--text-main);
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.brand-title span {
  color: var(--primary);
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Icon Buttons */
.icon-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 1.1rem;
}

.icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.icon-btn.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-glow);
}

/* Main Content Area */
.app-content {
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 90px; /* Space for bottom nav */
}

/* Location Status Banner */
.location-banner {
  background: var(--primary-light);
  border: 1px solid var(--primary-glow);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-main);
}

.location-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.location-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.location-edit-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.location-edit-btn:hover {
  text-decoration: underline;
}

/* Search Box Container */
.search-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 4px 8px;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.search-input-wrapper:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: var(--shadow-glow);
}

.search-icon-left {
  padding-left: 8px;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.main-search-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 1rem;
  padding: 10px 12px;
  color: var(--text-main);
  font-family: inherit;
}

.main-search-input::placeholder {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.search-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all var(--transition-fast);
}

.search-action-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
}

.search-action-btn.recording {
  background: var(--accent-red);
  color: white;
  animation: pulse 1s infinite;
}

.search-submit-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
}

.search-submit-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 6px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 90;
  max-height: 280px;
  overflow-y: auto;
  display: none;
}

.autocomplete-dropdown.open {
  display: block;
}

.autocomplete-item {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color var(--transition-fast);
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover {
  background: var(--bg-card-hover);
}

.autocomplete-icon {
  color: var(--primary);
  font-size: 1.1rem;
}

.autocomplete-text {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.95rem;
}

.autocomplete-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: auto;
}

/* Quick Radius & Filter Pills */
.filter-pills-row {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.filter-pills-row::-webkit-scrollbar {
  display: none;
}

.pill-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-sub);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.pill-btn:hover {
  background: var(--bg-card-hover);
  color: var(--primary);
  border-color: var(--primary);
}

.pill-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 8px var(--primary-glow);
}

/* Category Grid (Home Screen) */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.section-title {
  font-size: 1.1rem;
  color: var(--text-main);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .category-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .category-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.category-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
}

.category-icon-bubble {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.category-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
}

.category-card-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.category-badge-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.65rem;
  font-weight: 700;
  background: var(--accent-orange);
  color: white;
  padding: 2px 6px;
  border-radius: var(--radius-full);
}

/* Results View */
.results-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.results-count-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.results-count-text b {
  color: var(--text-main);
}

.view-toggle-group {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.view-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.view-toggle-btn.active {
  background: var(--bg-surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* Results List */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.business-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

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

.bcard-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.bcard-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
}

.bcard-fav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.bcard-fav-btn.favorited {
  color: #F59E0B;
}

.bcard-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.bcard-type-tag {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

.bcard-distance-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-green);
  display: flex;
  align-items: center;
  gap: 4px;
}

.bcard-address {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.3;
}

.bcard-snippet {
  font-size: 0.85rem;
  color: var(--text-sub);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* 1-Click Action Buttons Strip */
.bcard-actions-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
}

.btn-action {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
  text-align: center;
}

.btn-call {
  background: var(--accent-green-light);
  color: var(--accent-green);
  border-color: rgba(16, 185, 129, 0.3);
}

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

.btn-wa {
  background: rgba(37, 211, 102, 0.15);
  color: #128C7E;
  border-color: rgba(37, 211, 102, 0.3);
}

[data-theme="dark"] .btn-wa {
  color: #25D366;
}

.btn-wa:hover {
  background: #25D366;
  color: white;
}

.btn-directions {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary-glow);
}

.btn-directions:hover {
  background: var(--primary);
  color: white;
}

/* Map Container */
.map-view-container {
  width: 100%;
  height: 480px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  display: none;
  box-shadow: var(--shadow-md);
}

.map-view-container.active {
  display: block;
}

/* Bottom Navigation Bar (Mobile Native Style) */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 768px;
  margin: 0 auto;
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  padding: 8px 16px;
  z-index: 100;
}

@media (min-width: 1024px) {
  .bottom-nav-bar {
    max-width: 1100px;
  }
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.nav-tab-btn i, .nav-tab-btn .nav-icon {
  font-size: 1.25rem;
}

.nav-tab-btn.active {
  color: var(--primary);
  font-weight: 700;
}

/* Loading & Empty States */
.state-container {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Modal Bottom Sheet */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-content {
  background: var(--bg-surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-close-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
