/* ============================================
   Discovery Hub — Store Locator

   Self-contained: maps --td-* tokens to Bootstrap
   variables as defaults. If enhancements.css is
   loaded (TopDeck), it overrides these. On WL hubs,
   these fall back to each WL theme's --bs-* values.
   ============================================ */

:root {
  /* Accent — theme primary color */
  --td-accent: var(--bs-primary, #6ca6ea);
  --td-accent-subtle: rgba(var(--bs-primary-rgb, 108, 166, 234), 0.12);
  --td-accent-glow: rgba(var(--bs-primary-rgb, 108, 166, 234), 0.25);

  /* Surfaces — layered from darkest to lightest
     Note: Around/TopDeck theme inverts Bootstrap's gray scale
     (gray-100 = darkest, gray-900 = lightest) */
  --td-surface-1: var(--bs-body-bg, #0d1117);
  --td-surface-2: var(--bs-gray-100, #161b22);
  --td-surface-3: var(--bs-gray-200, #1c2128);
  --td-surface-elevated: var(--bs-gray-300, #21262d);

  /* Text hierarchy (inverted scale: gray-900 = lightest text) */
  --td-text-primary: var(--bs-gray-900, #f0f3f6);
  --td-text-secondary: var(--bs-body-color, #9ea7b3);
  --td-text-muted: var(--bs-gray-500, #656d76);

  /* Borders */
  --td-border-subtle: rgba(255, 255, 255, 0.06);
  --td-border-default: rgba(255, 255, 255, 0.10);

  /* Shadows */
  --td-shadow-sm: 0 1px 2px rgba(0,0,0,0.24), 0 0 1px rgba(0,0,0,0.12);
  --td-shadow-lg: 0 8px 24px rgba(0,0,0,0.40), 0 0 1px rgba(0,0,0,0.12);
  --td-glow-accent: 0 0 20px rgba(var(--bs-primary-rgb, 108, 166, 234), 0.15);

  /* Radius */
  --td-radius-sm: 5px;
  --td-radius-md: 8px;
  --td-radius-lg: 12px;

  /* Spacing */
  --td-space-2: 8px;
  --td-space-3: 12px;
  --td-space-4: 16px;
  --td-space-5: 24px;
  --td-space-8: 64px;

  /* Animation */
  --td-duration-fast: 120ms;
  --td-duration-base: 200ms;
  --td-ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);

  /* Focus */
  --td-focus-ring: 0 0 0 3px rgba(var(--bs-primary-rgb, 108, 166, 234), 0.35);
}

/* ── Page Layout — fill visible viewport ── */
.page-wrapper:has(.discover-layout) {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--discover-navbar-h, 0px));
}

/* ── Search Section ── */
.discover-search {
  background: var(--td-surface-2);
  border-bottom: 1px solid var(--td-border-subtle);
  padding: var(--td-space-3) var(--td-space-4);
}

.discover-search-input {
  position: relative;
  min-width: 240px;
}

.discover-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--td-text-muted);
  pointer-events: none;
  z-index: 2;
  transition: color var(--td-duration-fast);
}

.discover-search-input:focus-within .discover-search-icon {
  color: var(--td-accent);
}

.discover-search-input .form-control {
  padding-left: 40px;
  padding-right: 40px;
  background: var(--td-surface-3);
  border-color: var(--td-border-default);
}

.discover-search-input .form-control:focus {
  border-color: var(--td-accent);
  box-shadow: var(--td-focus-ring);
  background: var(--td-surface-elevated);
}

.discover-search-actions {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  z-index: 2;
}

.discover-search-actions .btn {
  color: var(--td-text-muted);
  padding: 4px 8px;
  font-size: 0.95rem;
  line-height: 1;
  border-radius: var(--td-radius-sm);
}

.discover-search-actions .btn:hover {
  color: var(--td-accent);
  background: var(--td-accent-subtle);
}

#useMyLocation.locating {
  animation: pulse-locate 1s ease infinite;
  color: var(--td-accent);
}

@keyframes pulse-locate {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Google Places Autocomplete dropdown */
.pac-container {
  z-index: 2000 !important;
  background: var(--td-surface-elevated) !important;
  border: 1px solid var(--td-border-default) !important;
  border-radius: var(--td-radius-lg) !important;
  box-shadow: var(--td-shadow-lg) !important;
  margin-top: 4px !important;
  font-family: inherit !important;
}

.pac-item {
  padding: 8px 14px !important;
  border-top-color: var(--td-border-subtle) !important;
  color: var(--td-text-primary) !important;
  cursor: pointer;
  line-height: 1.5 !important;
}

.pac-item:first-child {
  border-top: none !important;
}

.pac-item:hover,
.pac-item-selected {
  background: var(--td-surface-3) !important;
}

.pac-item-query {
  color: var(--td-text-primary) !important;
  font-size: 0.9rem !important;
}

.pac-matched {
  color: var(--td-accent) !important;
  font-weight: 600 !important;
}

.pac-icon {
  display: none !important;
}

.hdpi .pac-icon {
  display: none !important;
}

/* ── Distance Pills ── */
.discover-pill {
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 6px 16px;
  border-radius: 50rem;
  border: 1px solid var(--td-border-default);
  background: transparent;
  color: var(--td-text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition:
    background-color var(--td-duration-fast) var(--td-ease-out),
    border-color var(--td-duration-fast) var(--td-ease-out),
    color var(--td-duration-fast) var(--td-ease-out),
    box-shadow var(--td-duration-fast) var(--td-ease-out);
}

.discover-pill:hover {
  border-color: var(--td-accent);
  color: var(--td-text-primary);
  background: var(--td-accent-subtle);
}

.discover-pill.active {
  background: var(--td-accent);
  border-color: var(--td-accent);
  color: var(--td-surface-1);
  font-weight: 600;
  box-shadow: var(--td-glow-accent);
}

/* ── Split Layout ── */
.discover-layout {
  display: flex;
  flex: 1;
  min-height: 0; /* allow flex child to shrink below content size */
  overflow: hidden;
}

.discover-list-panel {
  width: 460px;
  flex-shrink: 0;
  overflow-y: auto;
  border-right: 1px solid var(--td-border-subtle);
  background: var(--td-surface-1);
}

.discover-list-header {
  padding: var(--td-space-3) var(--td-space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--td-surface-1);
  border-bottom: 1px solid var(--td-border-subtle);
  font-size: 0.85rem;
  font-weight: 500;
}

.discover-list-header strong {
  color: var(--td-accent);
}

/* ── Name Search ── */
.discover-name-search {
  position: relative;
  width: 150px;
  transition: width var(--td-duration-base) var(--td-ease-out);
}

.discover-name-search:focus-within {
  width: 200px;
}

.discover-name-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  color: var(--td-text-muted);
  pointer-events: none;
  z-index: 1;
}

.discover-name-search .form-control {
  padding-left: 28px;
  font-size: 0.8rem;
  background: var(--td-surface-2);
  border-color: var(--td-border-subtle);
  height: 32px;
}

.discover-name-search .form-control:focus {
  border-color: var(--td-accent);
  background: var(--td-surface-3);
}

/* ── Section Labels ── */
.discover-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--td-text-muted);
  padding: var(--td-space-3) var(--td-space-4) var(--td-space-2);
}

/* ── Store Cards ── */
.discover-store-list {
  padding: 0 var(--td-space-2);
}

.discover-store-card {
  display: flex;
  align-items: center;
  gap: var(--td-space-3);
  padding: var(--td-space-3) var(--td-space-3);
  margin: 2px 0;
  border-radius: var(--td-radius-md);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  transition:
    background-color var(--td-duration-base) var(--td-ease-out),
    box-shadow var(--td-duration-base) var(--td-ease-out);
}

.discover-store-card:hover {
  background: var(--td-surface-2);
  box-shadow: var(--td-shadow-sm);
  color: inherit;
  text-decoration: none;
}

.discover-store-card:hover .discover-avatar {
  border-color: var(--td-accent);
  box-shadow: var(--td-glow-accent);
}

.discover-store-card.highlighted {
  background: var(--td-accent-subtle);
}

/* ── Avatar ── */
.discover-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  color: white;
  overflow: hidden;
  border: 2px solid var(--td-border-default);
  background: var(--td-surface-3);
  transition:
    border-color var(--td-duration-base) var(--td-ease-out),
    box-shadow var(--td-duration-base) var(--td-ease-out);
}

.discover-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discover-avatar.color-0 { background: linear-gradient(135deg, #6ca6ea, #4a8ad4); }
.discover-avatar.color-1 { background: linear-gradient(135deg, #ec4899, #db2777); }
.discover-avatar.color-2 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.discover-avatar.color-3 { background: linear-gradient(135deg, #10b981, #059669); }
.discover-avatar.color-4 { background: linear-gradient(135deg, #ef4444, #dc2626); }
.discover-avatar.color-5 { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

/* ── Store Info ── */
.discover-store-info {
  flex: 1;
  min-width: 0;
}

.discover-store-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--td-text-primary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.discover-store-location {
  font-size: 0.8rem;
  color: var(--td-text-secondary);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.discover-store-location i {
  font-size: 0.7rem;
  opacity: 0.6;
}

/* ── Distance Badge ── */
.discover-distance {
  flex-shrink: 0;
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.discover-distance-val {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--td-accent);
}

.discover-distance-unit {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--td-text-muted);
}

/* ── Map Panel ── */
.discover-map-panel {
  flex: 1;
  position: relative;
  background: var(--td-surface-2);
}

.discover-map {
  width: 100%;
  height: 100%;
}

/* Search this area button */
.discover-search-area {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  background: var(--td-surface-2);
  color: var(--td-text-primary);
  border: 1px solid var(--td-border-default);
  border-radius: 50rem;
  padding: 8px 18px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--td-shadow-lg);
  transition:
    background-color var(--td-duration-fast) var(--td-ease-out),
    border-color var(--td-duration-fast) var(--td-ease-out);
}

.discover-search-area:hover {
  background: var(--td-accent);
  border-color: var(--td-accent);
  color: var(--td-surface-1);
}

/* Google Maps dark mode overrides */
.discover-map .gm-style {
  background: var(--td-surface-1) !important;
}

/* Map info window — dark theme overrides */
.gm-style-iw-d {
  overflow: hidden !important;
}

.gm-style .gm-style-iw-c {
  background: var(--td-surface-2) !important;
  border: 1px solid var(--td-border-default) !important;
  border-radius: var(--td-radius-md) !important;
  box-shadow: var(--td-shadow-lg) !important;
  padding: 0 !important;
  max-width: 260px !important;
}

/* Tail/arrow */
.gm-style .gm-style-iw-tc::after {
  background: var(--td-surface-2) !important;
  border-right: 1px solid var(--td-border-default) !important;
  border-bottom: 1px solid var(--td-border-default) !important;
}

/* Collapse the header row and close button entirely */
.gm-style .gm-style-iw-chr {
  display: none !important;
}

/* Info window content — compact horizontal card */
.discover-iw {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.discover-iw:hover .discover-iw-name {
  color: var(--td-accent);
}

.discover-iw-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--td-surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--td-border-default);
}

.discover-iw-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.discover-iw-avatar span {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--td-text-secondary);
}

.discover-iw-info {
  min-width: 0;
}

.discover-iw-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--td-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color var(--td-duration-fast);
}

.discover-iw-meta {
  font-size: 0.75rem;
  color: var(--td-text-muted);
  margin-top: 1px;
  white-space: nowrap;
}

/* ── Skeleton Loading ── */
.discover-skeleton {
  display: flex;
  align-items: center;
  gap: var(--td-space-3);
  padding: var(--td-space-3) var(--td-space-4);
}

.discover-skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--td-surface-3);
  flex-shrink: 0;
  animation: discover-shimmer 1.8s ease infinite;
}

.discover-skeleton-lines {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.discover-skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: var(--td-surface-3);
  animation: discover-shimmer 1.8s ease infinite;
}

.discover-skeleton-line.w-65 { width: 65%; height: 14px; }
.discover-skeleton-line.w-45 { width: 45%; }

.discover-skeleton-badge {
  width: 36px;
  height: 28px;
  border-radius: var(--td-radius-sm);
  background: var(--td-surface-3);
  flex-shrink: 0;
  animation: discover-shimmer 1.8s ease infinite;
}

.discover-skeleton:nth-child(2) * { animation-delay: 0.15s; }
.discover-skeleton:nth-child(3) * { animation-delay: 0.3s; }
.discover-skeleton:nth-child(4) * { animation-delay: 0.45s; }
.discover-skeleton:nth-child(5) * { animation-delay: 0.6s; }
.discover-skeleton:nth-child(6) * { animation-delay: 0.75s; }

@keyframes discover-shimmer {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; }
}

/* ── Empty State ── */
.discover-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--td-space-8) var(--td-space-5);
  text-align: center;
}

.discover-empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--td-accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--td-space-4);
}

.discover-empty-icon i {
  font-size: 1.25rem;
  color: var(--td-accent);
}

/* ── Mobile View Toggle ── */
.discover-mobile-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--td-surface-2);
  border: 1px solid var(--td-border-default);
  border-radius: 50rem;
  padding: 3px;
  box-shadow: var(--td-shadow-lg);
}

.discover-toggle-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 20px;
  border: none;
  border-radius: 50rem;
  background: transparent;
  color: var(--td-text-secondary);
  cursor: pointer;
  transition:
    background-color var(--td-duration-fast),
    color var(--td-duration-fast);
}

.discover-toggle-btn.active {
  background: var(--td-accent);
  color: var(--td-surface-1);
  font-weight: 600;
}

/* ── Responsive ── */
@media (max-width: 991px) {
  .discover-layout {
    flex-direction: column;
  }

  .discover-list-panel {
    width: 100%;
    flex: 1;
    border-right: none;
  }

  .discover-map-panel {
    display: none;
    width: 100%;
    flex: 1;
  }

  .discover-map-panel.mobile-visible {
    display: block;
  }

  .discover-list-panel.mobile-hidden {
    display: none;
  }

  .discover-mobile-toggle {
    display: flex;
  }

  .discover-search {
    padding: var(--td-space-2) var(--td-space-3);
  }

  .discover-pills {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .discover-pills::-webkit-scrollbar {
    display: none;
  }
}

@media (min-width: 1400px) {
  .discover-list-panel {
    width: 520px;
  }
}

@media (max-width: 575px) {
  .discover-search .flex-wrap {
    gap: var(--td-space-2) !important;
  }

  .discover-pill {
    padding: 5px 12px;
    font-size: 0.75rem;
  }
}
