/* =============================
   VARIABLES (branding)
============================= */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --accent: #22c55e;

  --bg: #f9fafb;
  --card: #ffffff;

  --text: #1f2933;
  --muted: #6b7280;

  --border: #e5e7eb;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.08);

  --radius: 10px;
}

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

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* =============================
   HEADER (PRODUCTION DESIGN)
============================= */
.header {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  align-items: center;
}

/* LOGO */
.brand {
  display: flex;
  justify-content: center;
  align-items: center;
}

.brand-logo {
  height: 100px;
  width: auto;
}

/* CONTROLS */
.controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* SEARCH ROW */
.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.search-input-wrap input {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 14px;
  outline: none;
  transition: 0.2s;
}

.search-input-wrap input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* BUTTONS */
.btn {
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  transition: 0.2s;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-ghost {
  background: #f3f4f6;
  border: 1px solid var(--border);
  width: 44px;
}

.btn-ghost:hover {
  background: #e5e7eb;
}

.btn-chip {
  background: #eef2ff;
  color: var(--primary);
  padding: 8px 12px;
  border-radius: 999px;
}

/* FILTERS */
.filters-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.chip {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.chip-value {
  font-weight: 700;
}

/* SLIDER */
#radiusSlider {
  width: 140px;
}

/* =============================
   MAIN LAYOUT (Desktop/Tablet)
============================= */
.container {
  display: flex;
  height: calc(100vh - 120px);
  gap: 12px;
  padding: 12px;
}

/* MAP */
#map {
  flex: 1;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  min-height: 400px;
}

/* SIDEBAR */
.sidebar {
  width: 320px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 16px;
  margin-bottom: 10px;
}

/* =============================
   LOCATION CARD
============================= */
.location-info {
  background: #eef2ff;
  border-left: 4px solid var(--primary);
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}

/* =============================
   SHOP LIST
============================= */
.cornershop-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.cornershop-item {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  transition: 0.2s;
}

.cornershop-item:hover {
  border-color: var(--primary);
  background: #f9fafb;
  transform: translateY(-2px);
}

.cornershop-item.active {
  border-color: var(--primary);
  background: #eef2ff;
}

.cornershop-item strong {
  display: block;
  font-size: 14px;
}

.cornershop-item small {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.cornershop-distance {
  margin-top: 6px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
}

/* NAV BUTTON (if you use class in JS later) */
.nav-btn {
  margin-top: 8px;
  width: 100%;
  padding: 9px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--primary-dark);
}

/* =============================
   STATES
============================= */
.loading,
.no-results {
  text-align: center;
  padding: 20px;
  color: var(--muted);
}

.error {
  background: #fee2e2;
  color: #b91c1c;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 10px;
}

/* =============================
   STATS
============================= */
.stats {
  font-size: 12px;
  color: var(--muted);
  padding: 10px 0;
  border-top: 1px solid var(--border);
}

/* =============================
   POPUP
============================= */
.popup-content {
  padding: 8px;
  max-width: 220px;
}

.popup-content h4 {
  margin-bottom: 6px;
  color: var(--primary);
  font-size: 14px;
}

.popup-content p {
  font-size: 12px;
  margin: 2px 0;
  color: var(--muted);
}

/* =========================================================
   OPTION A: MOBILE BOTTOM SHEET (Uber-like sidebar behaviour)
   ========================================================= */
@media (max-width: 768px) {
  /* Header stacks naturally */
  .header-inner {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    height: 65px;
  }

  .search-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "search search"
      "btn geo";
  }

  .search-input-wrap {
    grid-area: search;
  }

  #searchBtn {
    grid-area: btn;
    width: 100%;
  }

  #geolocationBtn {
    grid-area: geo;
  }

  /* Container becomes overlay-friendly */
  .container {
    position: relative;
    padding: 0;
    gap: 0;
    height: calc(100vh - 160px);
  }

  /* Map fills the screen behind the sheet */
  #map {
    height: 100%;
    width: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  /* Sidebar becomes bottom sheet overlay */
  .sidebar {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;

    height: 42vh;         /* collapsed height */
    max-height: 72vh;     /* expanded max */

    border-radius: 16px;
    overflow: hidden;
    padding: 0;           /* padding moved to sections */
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.18);
    z-index: 500;

    display: flex;
    flex-direction: column;
  }

  /* Grab handle */
  .sidebar::before {
    content: "";
    width: 46px;
    height: 5px;
    border-radius: 999px;
    background: #d1d5db;
    margin: 10px auto 6px auto;
    flex: 0 0 auto;
  }

  /* Sticky title in sheet */
  .sidebar h2 {
    position: sticky;
    top: 0;
    background: #ffffff;
    padding: 10px 14px;
    margin: 0;
    border-bottom: 1px solid var(--border);
    z-index: 2;
  }

  /* Pad info/error blocks */
  #locationInfo,
  #error {
    padding: 10px 14px;
  }

  /* List becomes scroll area */
  .cornershop-list {
    padding: 0 14px 14px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  /* Sticky stats footer */
  .stats {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    z-index: 2;
  }

  /* More tap-friendly items */
  .cornershop-item {
    padding: 12px;
    border-radius: 10px;
  }

  /* Expanded state (toggled by JS) */
  .sidebar.is-expanded {
    height: 72vh;
  }
}

/* Extra small phones */
@media (max-width: 420px) {
  .brand-logo {
    height: 58px;
  }

  .btn {
    padding: 11px 14px;
  }

  .sidebar {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}

/* =========================================
   NAV MODE: Hide header to focus on route
   ========================================= */
body.nav-mode .header {
  display: none;
}

/* When header is hidden, let the layout fill the screen */
body.nav-mode .container {
  height: 100vh;
}

/* Mobile bottom sheet mode: map should still fill */
@media (max-width: 768px) {
  body.nav-mode .container {
    height: 100vh;
  }

  /* Hide sidebar on mobile during navigation */
  body.nav-mode .sidebar {
    display: none;
  }

  /* Show mobile nav bar on mobile during navigation */
  body.nav-mode .mobile-nav-bar {
    display: flex;
  }
}

/* =========================================
   MOBILE NAVIGATION BAR (Google Maps style)
   ========================================= */
.mobile-nav-bar {
  display: none;
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  padding: 12px 16px 16px 16px;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
  z-index: 600;
}

.mobile-nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mobile-nav-info {
  flex: 1;
}

.mobile-nav-direction {
  font-weight: 700;
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 4px;
}

.mobile-nav-distance {
  font-size: 13px;
  color: var(--muted);
}

.mobile-nav-cancel {
  background: #f3f4f6;
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
  flex-shrink: 0;
}

.mobile-nav-cancel:active {
  background: #e5e7eb;
  transform: translateY(1px);
}
