/* ============================================
   Mobile-First Store Locator Styles
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
  --primary: #f96302;
  --primary-dark: #e55a00;
  --primary-light: #ff8534;
  --bg-dark: #1a1a2e;
  --bg-card: #ffffff;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-light: #9ca3af;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 999px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
}

/* ---------- Map ---------- */
#map {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0;
}

.leaflet-popup-content {
  margin: 14px 16px;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

.leaflet-popup-content strong {
  color: var(--primary);
  font-weight: 600;
}

/* ---------- Loading Overlay ---------- */
#loading {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 46, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

#loading.hidden {
  opacity: 0;
  visibility: hidden;
}

#loading p {
  color: white;
  font-size: 14px;
  font-weight: 500;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Bottom Navigation (Mobile) ---------- */
#bottomNav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  padding-bottom: var(--safe-bottom);
  background: white;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  border-top: 1px solid var(--border-color);
}

.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 8px 20px;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: var(--radius-md);
}

.nav-btn svg {
  width: 24px;
  height: 24px;
  transition: transform 0.2s ease;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn:active {
  transform: scale(0.95);
  background: rgba(249, 99, 2, 0.1);
}

/* ---------- Store Panel (Bottom Sheet) ---------- */
#panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 85vh;
  max-height: calc(100vh - 80px);
  background: white;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  transform: translateY(calc(100% - 64px));
  transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.12);
  will-change: transform;
}

#panel.peek {
  transform: translateY(calc(100% - 180px));
}

#panel.open {
  transform: translateY(0);
}

/* Drag Handle */
#panelDragHandle {
  width: 36px;
  height: 5px;
  background: #d1d5db;
  border-radius: var(--radius-full);
  margin: 10px auto 6px;
  cursor: grab;
}

#panelDragHandle:active {
  cursor: grabbing;
  background: #9ca3af;
}

/* Panel Header */
#panelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.header-text h1 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

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

#closePanel {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

#closePanel:active {
  transform: scale(0.95);
  background: #e5e7eb;
}

/* Search Container */
#searchContainer {
  position: relative;
  padding: 12px 16px;
  flex-shrink: 0;
}

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

#searchInput {
  width: 100%;
  padding: 14px 44px;
  font-size: 16px;
  font-family: inherit;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-full);
  background: #f9fafb;
  color: var(--text-primary);
  transition: all 0.2s ease;
  -webkit-appearance: none;
}

#searchInput::placeholder {
  color: var(--text-light);
}

#searchInput:focus {
  outline: none;
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 4px rgba(249, 99, 2, 0.1);
}

#clearSearch {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#clearSearch:active {
  color: var(--text-secondary);
}

/* Store List */
#storeList {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}

.store-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  margin: 0 12px 8px;
  background: #f9fafb;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.store-item:active {
  transform: scale(0.98);
  background: #f3f4f6;
  border-color: var(--border-color);
}

.store-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.store-info {
  flex: 1;
  min-width: 0;
}

.store-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-location {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.store-address {
  font-size: 12px;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.store-arrow {
  color: var(--text-light);
  flex-shrink: 0;
  margin-top: 12px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-secondary);
  text-align: center;
}

.empty-state svg {
  color: var(--text-light);
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 14px;
}

/* ============================================
   Tablet & Desktop Enhancements
   ============================================ */

@media (min-width: 768px) {
  /* Hide bottom nav on larger screens */
  #bottomNav {
    display: none;
  }

  /* Convert panel to side panel */
  #panel {
    left: 0;
    right: auto;
    top: 0;
    bottom: 0;
    width: 380px;
    height: 100vh;
    max-height: none;
    border-radius: 0;
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }

  #panel.peek,
  #panel.open {
    transform: translateX(0);
  }

  #panelDragHandle {
    display: none;
  }

  #closePanel {
    display: none;
  }

  #map {
    left: 380px;
  }

  .store-item:hover {
    background: #f3f4f6;
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
  }

  .nav-btn:hover {
    background: rgba(249, 99, 2, 0.1);
    color: var(--primary);
  }

  .nav-btn:hover svg {
    transform: scale(1.1);
  }
}

/* Large Desktop */
@media (min-width: 1200px) {
  #panel {
    width: 420px;
  }

  #map {
    left: 420px;
  }

  .store-item {
    padding: 18px;
    margin: 0 16px 10px;
  }
}
