/* =============================================================
   facilities-map.css
   Ask Aunty Mimi — Youth Health Facility Map
   Modern, mobile-first, glassmorphism-tinged design system
   ============================================================= */

/* -------------------------------------------------------------
   1. Design tokens
   ------------------------------------------------------------- */
:root {
  /* Brand */
  --c-teal: #14B8A6;
  --c-teal-deep: #0D9488;
  --c-violet: #7C3AED;
  --c-violet-soft: #EDE9FE;

  /* Surfaces */
  --c-surface: #FFFFFF;
  --c-surface-2: #F8FAFC;
  --c-bg: #FAFAFA;

  /* Ink */
  --c-ink: #0F172A;
  --c-ink-2: #334155;
  --c-muted: #64748B;
  --c-muted-2: #94A3B8;

  /* Borders */
  --c-border: rgba(15, 23, 42, 0.08);
  --c-border-strong: rgba(15, 23, 42, 0.14);

  /* Status */
  --c-success: #10B981;
  --c-success-deep: #059669;
  --c-warn: #F59E0B;
  --c-danger: #EF4444;
  --c-info: #3B82F6;

  /* Radii */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --sh-md: 0 4px 12px rgba(15, 23, 42, .06), 0 2px 4px rgba(15, 23, 42, .04);
  --sh-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 4px 8px rgba(15, 23, 42, .05);
  --sh-glow-teal: 0 8px 24px rgba(20, 184, 166, .25);
  --sh-glow-violet: 0 8px 24px rgba(124, 58, 237, .25);

  /* Type */
  --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* -------------------------------------------------------------
   2. Base resets
   ------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* -------------------------------------------------------------
   3. App shell layout
   ------------------------------------------------------------- */
.fmap-app {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "nav nav"
    "sidebar main";
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* ── 3-column variant ── */
.fmap-app.fmap-3col {
  grid-template-columns: 260px 360px 1fr;
  grid-template-areas:
    "nav      nav   nav"
    "controls cards main";
}

.fmap-nav { grid-area: nav; }
.fmap-controls-panel { grid-area: controls; }
.fmap-cards-panel { grid-area: cards; }
.fmap-sidebar { grid-area: sidebar; }
.fmap-main { grid-area: main; }

.fmap-main {
  grid-area: main;
}

/* -------------------------------------------------------------
   4. Top nav
   ------------------------------------------------------------- */
.fmap-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 64px;
  padding: 0 20px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  position: relative;
  z-index: 50;
}

.fmap-nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.fmap-nav-logo-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.5px;
  border-radius: 12px;
  box-shadow: var(--sh-sm);
}

.fmap-nav-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.fmap-nav-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--c-ink);
}

.fmap-nav-sub {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 1px;
}

.fmap-nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fmap-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  background: var(--c-violet-soft);
  color: var(--c-violet);
  border-radius: 999px;
}

.fmap-icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  color: var(--c-ink-2);
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.fmap-icon-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
  border-color: var(--c-border-strong);
}

.fmap-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
  border-radius: 999px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.fmap-chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-glow-teal);
}

.fmap-mobile-toggle {
  display: none;
  width: 36px;
  height: 36px;
  place-items: center;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  color: var(--c-ink-2);
}

/* -------------------------------------------------------------
   4b. Controls Panel (3-col layout — Column 1)
   ------------------------------------------------------------- */
.fmap-controls-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  padding: 10px;
  position: relative;
  z-index: 20;
}

.fmap-controls-panel::-webkit-scrollbar { width: 4px; }
.fmap-controls-panel::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.12);
  border-radius: 999px;
}
.fmap-controls-panel::-webkit-scrollbar-track { background: transparent; }

.fmap-controls-panel .fmap-search-input {
  font-size: 12px;
  padding: 8px 10px 8px 32px;
}

.fmap-controls-panel .fmap-search-icon {
  left: 10px;
  font-size: 11px;
}

.fmap-controls-panel .fmap-ai-strip {
  padding: 8px 10px;
  gap: 8px;
}

.fmap-controls-panel .fmap-ai-strip-icon {
  width: 30px;
  height: 30px;
  font-size: 12px;
}

.fmap-controls-panel .fmap-ai-strip-title {
  font-size: 11px;
}

.fmap-controls-panel .fmap-ai-strip-sub {
  font-size: 10px;
}

.fmap-controls-panel .fmap-ai-strip-btn {
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.fmap-controls-panel .fmap-select {
  font-size: 11px;
  padding: 7px 10px;
}

.fmap-controls-panel .fmap-stats {
  gap: 4px;
}

.fmap-controls-panel .fmap-stat {
  padding: 6px 4px;
  border-radius: 8px;
}

.fmap-controls-panel .fmap-stat-num {
  font-size: 16px;
}

.fmap-controls-panel .fmap-stat-label {
  font-size: 8px;
}

.fmap-controls-panel .fmap-chips {
  gap: 3px;
  padding: 0;
}

.fmap-controls-panel .fmap-chip {
  font-size: 10px;
  padding: 4px 8px;
}

/* -------------------------------------------------------------
   4c. Cards Panel (3-col layout — Column 2)
   ------------------------------------------------------------- */
.fmap-cards-panel {
  display: flex;
  flex-direction: column;
  background: var(--c-surface-2);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  position: relative;
  z-index: 20;
}

.fmap-cards-panel::-webkit-scrollbar { width: 6px; }
.fmap-cards-panel::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.12);
  border-radius: 999px;
}
.fmap-cards-panel::-webkit-scrollbar-track { background: transparent; }

.fmap-cards-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border);
}

html.dark .fmap-cards-header {
  background: rgba(15, 23, 42, 0.92);
}

.fmap-cards-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--c-ink);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fmap-cards-title i {
  color: var(--c-teal);
  font-size: 14px;
}

.fmap-cards-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--c-muted);
  background: var(--c-surface);
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--c-border);
}

/* Card with image for 3-col layout */
.fmap-cards-panel .fmap-card {
  border-radius: 12px;
  margin: 0;
}

.fmap-card-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  border-bottom: 1px solid var(--c-border);
}

.fmap-cards-panel .fmap-card-body {
  padding: 10px 12px 8px;
}

.fmap-cards-panel .fmap-card-title {
  font-size: 12px;
}

.fmap-cards-panel .fmap-service-tag {
  font-size: 9px;
  padding: 2px 6px;
}

.fmap-cards-panel .fmap-card-foot {
  margin-top: 6px;
  padding-top: 6px;
  font-size: 10px;
}

.fmap-cards-panel .fmap-list {
  padding: 8px 10px;
  gap: 8px;
}

/* -------------------------------------------------------------
   5. Sidebar (2-col fallback)
   ------------------------------------------------------------- */
.fmap-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  overflow-y: auto;
  position: relative;
  z-index: 20;
  padding-bottom: 20px;
}

.fmap-sidebar::-webkit-scrollbar {
  width: 8px;
}
.fmap-sidebar::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.12);
  border-radius: 999px;
}
.fmap-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

/* -------------------------------------------------------------
   6. Search header
   ------------------------------------------------------------- */
.fmap-search-header {
  position: sticky;
  top: 0;
  background: var(--c-surface);
  z-index: 5;
  padding: 14px;
  border-bottom: 1px solid var(--c-border);
}

.fmap-search-row {
  display: flex;
  gap: 8px;
}

.fmap-search-input {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-surface-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--c-ink);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.fmap-search-input::placeholder {
  color: var(--c-muted-2);
}

.fmap-search-input:focus {
  border-color: var(--c-teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
  background: var(--c-surface);
}

.fmap-locate-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--c-teal), var(--c-teal-deep));
  box-shadow: var(--sh-sm);
  transition: transform .2s ease, box-shadow .2s ease;
}

.fmap-locate-btn:hover {
  transform: scale(1.05);
  box-shadow: var(--sh-glow-teal);
}

/* -------------------------------------------------------------
   7. AI strip
   ------------------------------------------------------------- */
.fmap-ai-strip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 12px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(20, 184, 166, 0.08));
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 16px;
}

.fmap-ai-strip-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--c-violet), var(--c-teal));
  color: #fff;
  flex-shrink: 0;
}

.fmap-ai-strip-body {
  flex: 1;
  min-width: 0;
}

.fmap-ai-strip-title {
  font-weight: 800;
  font-size: 13px;
  color: var(--c-ink);
  line-height: 1.2;
}

.fmap-ai-strip-sub {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 2px;
  line-height: 1.3;
}

.fmap-ai-strip-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-surface);
  color: var(--c-violet);
  box-shadow: var(--sh-md);
  transition: transform .2s ease, box-shadow .2s ease;
  flex-shrink: 0;
}

.fmap-ai-strip-btn:hover {
  transform: translateX(2px);
  box-shadow: var(--sh-glow-violet);
}

/* -------------------------------------------------------------
   8. Selects
   ------------------------------------------------------------- */
.fmap-select-row {
  display: flex;
  gap: 8px;
  padding: 0 12px;
}

.fmap-select {
  flex: 1;
  height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--c-border);
  border-radius: 10px;
  background-color: var(--c-surface-2);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'></polyline></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink);
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.fmap-select:focus {
  border-color: var(--c-teal);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

/* -------------------------------------------------------------
   9. Stats grid
   ------------------------------------------------------------- */
.fmap-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 12px;
}

.fmap-stat {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 10px 6px;
  text-align: center;
}

.fmap-stat-num {
  font-size: clamp(16px, 1.8vw, 18px);
  font-weight: 800;
  color: var(--c-ink);
  line-height: 1;
}

.fmap-stat-label {
  font-size: 9px;
  font-weight: 700;
  color: var(--c-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* -------------------------------------------------------------
   10. View toggle
   ------------------------------------------------------------- */
.fmap-view-toggle {
  display: flex;
  gap: 6px;
  padding: 0 12px;
}

.fmap-view-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-muted);
  background: transparent;
  border: 1px solid var(--c-border);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
}

.fmap-view-btn:hover {
  color: var(--c-ink-2);
  border-color: var(--c-border-strong);
}

.fmap-view-btn.active {
  background: var(--c-ink);
  color: #fff;
  border-color: var(--c-ink);
}

/* -------------------------------------------------------------
   11. Filter chips
   ------------------------------------------------------------- */
.fmap-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.fmap-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-muted);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  white-space: nowrap;
  transition: all .2s ease;
}

.fmap-chip:hover {
  background: #fff;
  border-color: var(--c-border-strong);
  color: var(--c-ink-2);
}

.fmap-chip.active {
  background: var(--c-ink);
  color: #fff;
  border-color: var(--c-ink);
}

/* -------------------------------------------------------------
   12. Facility cards
   ------------------------------------------------------------- */
.fmap-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 12px;
}

.fmap-card {
  display: block;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: transform .25s cubic-bezier(.22,1,.36,1), box-shadow .25s ease, border-color .25s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.fmap-card:hover {
  transform: translateY(-3px) scale(1.005);
  box-shadow: 0 16px 40px rgba(20, 184, 166, .12), 0 6px 12px rgba(15, 23, 42, .06);
  border-color: rgba(20, 184, 166, 0.35);
}

.fmap-card.selected {
  border-color: var(--c-teal);
  box-shadow: var(--sh-glow-teal);
}

.fmap-card-strip {
  height: 3px;
  background: linear-gradient(90deg, var(--c-teal), var(--c-violet));
  width: 100%;
}

.fmap-card-strip.warn {
  background: var(--c-warn);
}

.fmap-card-strip.out {
  background: var(--c-danger);
}

.fmap-card-strip.info {
  background: var(--c-info);
}

.fmap-card-body {
  padding: 12px 14px 10px;
}

.fmap-card-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.fmap-card-title {
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
  flex: 1;
  color: var(--c-ink);
}

.fmap-verified {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: var(--c-teal-deep);
  background: rgba(20, 184, 166, 0.1);
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
}

.fmap-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 4px;
}

.fmap-card-meta .star {
  color: #F59E0B;
}

.fmap-card-meta .dot {
  width: 3px;
  height: 3px;
  background: var(--c-muted-2);
  border-radius: 50%;
  display: inline-block;
  align-self: center;
}

.fmap-card-services {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.fmap-service-tag {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 6px;
  background: var(--c-surface-2);
  color: var(--c-muted);
}

.fmap-service-tag.youth {
  background: rgba(20, 184, 166, 0.12);
  color: var(--c-teal-deep);
}

.fmap-service-tag.pep {
  background: rgba(245, 158, 11, 0.12);
  color: #B45309;
}

.fmap-service-tag.prep {
  background: rgba(59, 130, 246, 0.12);
  color: #1D4ED8;
}

.fmap-service-tag.srhr {
  background: rgba(124, 58, 237, 0.12);
  color: var(--c-violet);
}

.fmap-service-tag.gbv {
  background: rgba(244, 63, 94, 0.12);
  color: #BE123C;
}

.fmap-service-tag.lgbtiq {
  background: linear-gradient(90deg, #ef4444, #f59e0b, #84cc16, #14b8a6, #3b82f6, #7c3aed);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
}

.fmap-service-tag.mental {
  background: rgba(99, 102, 241, 0.12);
  color: #4338CA;
}

.fmap-service-tag.ec {
  background: rgba(236, 72, 153, 0.12);
  color: #BE185D;
}

.fmap-service-tag.art {
  background: rgba(217, 119, 6, 0.12);
  color: #92400E;
}

.fmap-card-foot {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--c-muted);
}

.fmap-card-foot .open-now {
  color: var(--c-success-deep);
  font-weight: 700;
}

.fmap-card-foot .closed {
  color: var(--c-danger);
  font-weight: 700;
}

.fmap-card-foot .distance {
  font-weight: 600;
  color: var(--c-ink-2);
}

/* AI insight inside card */
.fmap-ai-insight {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 11px;
  font-style: italic;
  color: var(--c-violet);
  background: rgba(124, 58, 237, 0.06);
  padding: 6px 8px;
  border-radius: 8px;
  margin-top: 8px;
  line-height: 1.35;
}

.fmap-ai-insight .sparkles {
  flex-shrink: 0;
  margin-top: 1px;
}

.fmap-ai-insight.loading {
  animation: pulseSubtle 1.4s ease-in-out infinite;
  color: var(--c-muted-2);
}

@keyframes pulseSubtle {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* -------------------------------------------------------------
   13. Map area
   ------------------------------------------------------------- */
.fmap-main {
  position: relative;
  background: var(--c-surface-2);
  overflow: hidden;
}

#facilityMap {
  width: 100%;
  height: 100%;
}

/* Floating map controls */
.fmap-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 500;
  display: flex;
  gap: 8px;
}

.fmap-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-ink-2);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  box-shadow: var(--sh-sm);
  transition: background .2s ease, transform .2s ease;
}

.fmap-pill:hover {
  background: #fff;
  transform: translateY(-1px);
}

/* -------------------------------------------------------------
   14. Detail drawer
   ------------------------------------------------------------- */
.fmap-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 550;
}

.fmap-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.fmap-detail {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 92vw);
  background: var(--c-surface);
  box-shadow: var(--sh-lg);
  transform: translateX(100%);
  transition: transform .3s ease;
  overflow-y: auto;
  z-index: 600;
  padding-bottom: 80px;
}

.fmap-detail.open {
  transform: translateX(0);
}

.fmap-detail-hero {
  position: relative;
  height: 100px;
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
}

.fmap-detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background .2s ease;
}

.fmap-detail-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.fmap-detail-name {
  font-size: clamp(20px, 2.4vw, 22px);
  font-weight: 800;
  padding: 16px 20px 4px;
  color: var(--c-ink);
  line-height: 1.2;
}

.fmap-detail-meta {
  padding: 0 20px 8px;
  font-size: 12px;
  color: var(--c-muted);
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.fmap-detail-section {
  padding: 14px 20px;
  border-top: 1px solid var(--c-border);
}

.fmap-detail-section:first-of-type {
  border-top: none;
}

.fmap-detail-section h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--c-muted);
  margin: 0 0 8px;
  font-weight: 800;
}

.fmap-detail-services {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}

.fmap-detail-service {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink-2);
}

.fmap-detail-service .check {
  color: var(--c-success);
  flex-shrink: 0;
}

.fmap-detail-actions {
  position: sticky;
  bottom: 0;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  z-index: 5;
}

.fmap-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 42px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid transparent;
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
}

.fmap-action-btn:hover {
  transform: translateY(-1px);
}

.fmap-action-btn.call {
  background: linear-gradient(135deg, var(--c-teal), var(--c-teal-deep));
  color: #fff;
  box-shadow: var(--sh-sm);
}

.fmap-action-btn.call:hover {
  box-shadow: var(--sh-glow-teal);
}

.fmap-action-btn.directions {
  background: var(--c-surface);
  color: var(--c-violet);
  border-color: var(--c-violet);
}

.fmap-action-btn.directions:hover {
  background: var(--c-violet-soft);
}

.fmap-action-btn.qr {
  background: var(--c-surface);
  color: var(--c-ink);
  border-color: var(--c-ink);
}

.fmap-action-btn.qr:hover {
  background: var(--c-ink);
  color: #fff;
}

.fmap-action-btn.share {
  background: transparent;
  color: var(--c-muted);
  border-color: var(--c-border);
}

.fmap-action-btn.share:hover {
  background: var(--c-surface-2);
  color: var(--c-ink-2);
}

/* AI summary card */
.fmap-ai-summary {
  background: linear-gradient(135deg, rgba(124, 58, 237, .06), rgba(20, 184, 166, .06));
  border: 1px solid rgba(124, 58, 237, 0.12);
  border-radius: 14px;
  padding: 14px;
}

.fmap-ai-summary-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-violet);
  margin-bottom: 8px;
}

.fmap-ai-summary-themes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.fmap-ai-theme-chip {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(124, 58, 237, 0.15);
  color: var(--c-violet);
  border-radius: 999px;
}

.fmap-ai-summary-body {
  font-size: 12px;
  line-height: 1.5;
  color: var(--c-ink-2);
}

.fmap-ai-summary.loading .fmap-ai-summary-body {
  background: linear-gradient(90deg, rgba(124, 58, 237, .08) 0%, rgba(124, 58, 237, .18) 50%, rgba(124, 58, 237, .08) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  color: transparent;
  border-radius: 6px;
  min-height: 48px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Reviews */
.fmap-review-list {
  display: flex;
  flex-direction: column;
}

.fmap-review {
  display: flex;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--c-border);
}

.fmap-review:last-child {
  border-bottom: none;
}

.fmap-review-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--c-violet-soft), #DBEAFE);
  color: var(--c-violet);
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.fmap-review-body {
  flex: 1;
  min-width: 0;
}

.fmap-review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.fmap-review-stars {
  color: #F59E0B;
  font-size: 12px;
  letter-spacing: 1px;
}

.fmap-review-date {
  font-size: 10px;
  color: var(--c-muted-2);
}

.fmap-review-text {
  font-size: 12px;
  color: var(--c-ink-2);
  line-height: 1.4;
}

.fmap-review-vibes {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}

.fmap-vibe-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  color: var(--c-muted);
}

.fmap-vibe-bar-track {
  flex: 1;
  height: 4px;
  background: var(--c-surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.fmap-vibe-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--c-teal), var(--c-violet));
  border-radius: 999px;
}

/* Review form */
.fmap-review-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fmap-review-stars-input {
  display: inline-flex;
  gap: 4px;
}

.fmap-star-btn {
  background: none;
  border: none;
  font-size: 22px;
  color: #E5E7EB;
  cursor: pointer;
  transition: transform .15s ease, color .15s ease;
}

.fmap-star-btn:hover,
.fmap-star-btn.active {
  color: #F59E0B;
  transform: scale(1.1);
}

.fmap-review-textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-surface-2);
  font-size: 13px;
  resize: vertical;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.fmap-review-textarea:focus {
  border-color: var(--c-teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
  background: var(--c-surface);
}

.fmap-review-submit {
  align-self: flex-end;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  border-radius: 10px;
  transition: box-shadow .2s ease, transform .15s ease;
}

.fmap-review-submit:hover {
  box-shadow: var(--sh-glow-teal);
  transform: translateY(-1px);
}

/* -------------------------------------------------------------
   15. Modals
   ------------------------------------------------------------- */
.fmap-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9999;
  display: none;
  place-items: center;
  padding: 16px;
}

.fmap-modal.open,
.fmap-modal.show {
  display: grid;
}

.fmap-modal-card {
  background: var(--c-surface);
  border-radius: 20px;
  padding: 24px;
  max-width: 460px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--sh-lg);
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.fmap-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--c-surface-2);
  color: var(--c-muted);
  transition: background .2s ease, color .2s ease;
}

.fmap-modal-close:hover {
  background: var(--c-ink);
  color: #fff;
}

.fmap-modal-title {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 8px;
  color: var(--c-ink);
}

.fmap-modal-sub {
  font-size: 13px;
  color: var(--c-muted);
  margin: 0 0 16px;
  line-height: 1.4;
}

/* -------------------------------------------------------------
   16. Floating action buttons
   ------------------------------------------------------------- */
.fmap-fab-stack {
  position: fixed;
  bottom: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.fmap-fab {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  box-shadow: var(--sh-lg);
  transition: transform .2s ease, box-shadow .2s ease;
}

.fmap-fab:hover {
  transform: scale(1.08);
}

.fmap-fab.chat {
  background: linear-gradient(135deg, var(--c-violet), var(--c-teal));
  box-shadow: 0 8px 24px rgba(124, 58, 237, .35);
}

.fmap-fab.chat:hover {
  box-shadow: 0 12px 32px rgba(124, 58, 237, .45);
}

.fmap-fab.whatsapp {
  background: linear-gradient(135deg, #25D366, #128C7E);
  box-shadow: 0 8px 24px rgba(37, 211, 102, .35);
}

.fmap-fab.whatsapp:hover {
  box-shadow: 0 12px 32px rgba(37, 211, 102, .45);
}

/* -------------------------------------------------------------
   17. Loading & empty states
   ------------------------------------------------------------- */
.fmap-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: grid;
  place-items: center;
  z-index: 800;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.fmap-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--c-violet-soft);
  border-top-color: var(--c-violet);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.fmap-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--c-muted);
}

.fmap-empty.hidden {
  display: none;
}

.fmap-empty-icon {
  width: 60px;
  height: 60px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  background: var(--c-surface-2);
  color: var(--c-muted-2);
  border-radius: 999px;
}

.fmap-empty-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--c-ink);
  margin: 0 0 4px;
}

.fmap-empty-sub {
  font-size: 12px;
  margin: 0 0 14px;
  color: var(--c-muted);
}

.fmap-empty-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-teal-deep);
  background: transparent;
  border: 1.5px solid var(--c-teal);
  border-radius: 999px;
  transition: background .2s ease, color .2s ease;
}

.fmap-empty-btn:hover {
  background: var(--c-teal);
  color: #fff;
}

/* -------------------------------------------------------------
   17b. Floating map controls
   ------------------------------------------------------------- */
.fmap-floating-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 500;
  display: flex;
  gap: 8px;
}

.fmap-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-ink-2);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--c-border);
  border-radius: 999px;
  box-shadow: var(--sh-sm);
  cursor: pointer;
  transition: background .2s ease, transform .2s ease;
}

.fmap-pill-btn:hover {
  background: #fff;
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}

html.dark .fmap-pill-btn {
  background: rgba(15, 23, 42, 0.85);
  color: var(--c-ink);
}

html.dark .fmap-pill-btn:hover {
  background: rgba(15, 23, 42, 1);
}

/* -------------------------------------------------------------
   17c. View toggle: list mode
   ------------------------------------------------------------- */
body.fmap-view-list .fmap-main {
  display: none;
}

body.fmap-view-list .fmap-app {
  grid-template-columns: 1fr;
  grid-template-areas:
    "nav"
    "sidebar";
}

body.fmap-view-list .fmap-sidebar {
  max-width: 100%;
  border-right: none;
}

body.fmap-view-list .fmap-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
  padding: 16px 24px;
}

body.fmap-view-list .fmap-card {
  border-radius: 16px;
  box-shadow: var(--sh-sm);
}

body.fmap-view-list .fmap-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 20px 48px rgba(20, 184, 166, .14), 0 8px 16px rgba(15, 23, 42, .07);
}

body.fmap-view-list .fmap-show-more {
  grid-column: 1 / -1;
}

/* -------------------------------------------------------------
   17d. Detail panel inner elements
   ------------------------------------------------------------- */
.fmap-detail-hero-inner {
  position: absolute;
  bottom: 12px;
  left: 20px;
  right: 60px;
  color: #fff;
}

.fmap-detail-hero-inner h2 {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  text-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.fmap-detail-hero-inner .fmap-verified {
  margin-top: 4px;
  background: rgba(255,255,255,.2);
  color: #fff;
}

.fmap-detail-loc {
  font-size: 12px;
  color: rgba(255,255,255,.85);
  margin-top: 2px;
}

.fmap-detail-stats {
  display: flex;
  gap: 16px;
  padding: 12px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-ink-2);
  border-bottom: 1px solid var(--c-border);
}

.fmap-detail-stats .open-now {
  color: var(--c-success-deep);
  font-weight: 700;
}

.fmap-detail-stats .closed {
  color: var(--c-danger);
  font-weight: 700;
}

.fmap-services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}

.fmap-service-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink-2);
}

.fmap-service-row i {
  color: var(--c-success);
  flex-shrink: 0;
}

.fmap-service-row.muted {
  color: var(--c-muted);
  background: transparent;
  border-color: transparent;
}

.fmap-detail-section h3 {
  font-size: 13px;
  font-weight: 800;
  color: var(--c-ink);
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.fmap-detail-section h3 i {
  color: var(--c-violet);
}

.fmap-detail-section p {
  font-size: 13px;
  color: var(--c-ink-2);
  line-height: 1.5;
  margin: 0;
}

.fmap-detail-section p.muted {
  color: var(--c-muted);
}

.fmap-action-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-teal-deep);
  background: rgba(20, 184, 166, 0.08);
  border-radius: 10px;
  margin-right: 8px;
  margin-bottom: 6px;
  transition: background .2s ease;
}

.fmap-action-link:hover {
  background: rgba(20, 184, 166, 0.16);
}

/* Star picker in review form */
.fmap-star-picker {
  display: inline-flex;
  gap: 4px;
  margin-bottom: 8px;
}

.fmap-review-star {
  background: none;
  border: none;
  font-size: 22px;
  color: #E5E7EB;
  cursor: pointer;
  transition: transform .15s ease, color .15s ease;
  padding: 2px;
}

.fmap-review-star:hover {
  transform: scale(1.15);
}

/* Review textarea */
.fmap-detail-section textarea {
  width: 100%;
  min-height: 80px;
  padding: 10px 12px;
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-surface-2);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  outline: none;
  margin-bottom: 8px;
  color: var(--c-ink);
  transition: border-color .2s ease, box-shadow .2s ease;
}

.fmap-detail-section textarea:focus {
  border-color: var(--c-teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
  background: var(--c-surface);
}

/* Submit review button */
.fmap-submit-review {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: box-shadow .2s ease, transform .15s ease;
}

.fmap-submit-review:hover {
  box-shadow: var(--sh-glow-teal);
  transform: translateY(-1px);
}

/* AI shimmer loading */
.fmap-ai-shimmer {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fmap-ai-shimmer > div {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(124, 58, 237, .08) 0%, rgba(124, 58, 237, .18) 50%, rgba(124, 58, 237, .08) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.fmap-ai-shimmer > div:nth-child(1) { width: 100%; }
.fmap-ai-shimmer > div:nth-child(2) { width: 85%; }
.fmap-ai-shimmer > div:nth-child(3) { width: 60%; }

/* AI themes & chips */
.fmap-ai-themes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.fmap-ai-chip {
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(124, 58, 237, 0.08);
  border: 1px solid rgba(124, 58, 237, 0.15);
  color: var(--c-violet);
  border-radius: 999px;
}

html.dark .fmap-ai-chip {
  background: rgba(124, 58, 237, 0.18);
  color: #C4B5FD;
}

/* AI summary text (reused class) */
p.fmap-ai-summary {
  font-size: 13px;
  line-height: 1.5;
  color: var(--c-ink-2);
  margin: 0;
}

/* AI Recommend modal elements */
.fmap-ai-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
}

.fmap-ai-quick button {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-violet);
  background: var(--c-violet-soft);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 999px;
  cursor: pointer;
  transition: all .2s ease;
}

.fmap-ai-quick button:hover {
  background: var(--c-violet);
  color: #fff;
}

.fmap-ai-go {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--c-violet), var(--c-teal));
  border: none;
  border-radius: 12px;
  cursor: pointer;
  margin-bottom: 16px;
  transition: box-shadow .2s ease, transform .15s ease;
}

.fmap-ai-go:hover {
  box-shadow: var(--sh-glow-violet);
  transform: translateY(-1px);
}

.fmap-modal-card h2 {
  font-size: 20px;
  font-weight: 800;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.fmap-modal-card h2 i {
  color: var(--c-violet);
}

.fmap-modal-card p.muted {
  font-size: 13px;
  color: var(--c-muted);
  margin: 0 0 14px;
  line-height: 1.4;
}

.fmap-modal-card textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px 12px;
  border: 1.5px solid var(--c-border);
  border-radius: 12px;
  background: var(--c-surface-2);
  font-size: 13px;
  font-family: inherit;
  color: var(--c-ink);
  resize: vertical;
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.fmap-modal-card textarea:focus {
  border-color: var(--c-teal);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.12);
  background: var(--c-surface);
}

/* AI pick cards */
.fmap-ai-overall {
  font-size: 13px;
  color: var(--c-ink-2);
  margin: 0 0 14px;
  line-height: 1.5;
}

.fmap-ai-picks {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fmap-ai-pick {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  padding: 14px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.fmap-ai-pick:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}

.fmap-ai-pick-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.fmap-ai-pick-head strong {
  font-size: 14px;
  font-weight: 800;
  color: var(--c-ink);
}

.fmap-ai-pick-meta {
  font-size: 11px;
  color: var(--c-muted);
  margin-bottom: 6px;
}

.fmap-ai-pick-why {
  font-size: 12px;
  color: var(--c-ink-2);
  line-height: 1.4;
  font-style: italic;
  margin: 0 0 8px;
}

.fmap-ai-pick-view {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 700;
  color: var(--c-teal-deep);
  background: rgba(20, 184, 166, 0.1);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: all .2s ease;
}

.fmap-ai-pick-view:hover {
  background: var(--c-teal);
  color: #fff;
}

/* QR Modal */
.fmap-modal-card h3 {
  font-size: 16px;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--c-ink);
}

.fmap-modal-card img {
  display: block;
  margin: 14px auto;
  border-radius: 12px;
  border: 1px solid var(--c-border);
}

.fmap-qr-url {
  font-size: 11px;
  color: var(--c-muted);
  word-break: break-all;
  text-align: center;
  margin: 0 0 12px;
}

.fmap-qr-save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--c-teal), var(--c-teal-deep));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin: 0 auto;
  width: 100%;
  justify-content: center;
  transition: box-shadow .2s ease, transform .15s ease;
}

.fmap-qr-save:hover {
  box-shadow: var(--sh-glow-teal);
  transform: translateY(-1px);
}

/* Map legend */
.fmap-legend {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--c-border);
  box-shadow: var(--sh-sm);
  font-size: 11px;
  font-weight: 600;
  color: var(--c-ink-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

html.dark .fmap-legend {
  background: rgba(15, 23, 42, 0.9);
  color: var(--c-ink);
}

.fmap-legend-title {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-muted);
  margin-bottom: 2px;
}

.fmap-legend > div {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fmap-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.fmap-legend-dot.pin-instock {
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
}

.fmap-legend-dot.pin-low {
  background: linear-gradient(135deg, var(--c-warn), #B45309);
}

.fmap-legend-dot.pin-out {
  background: linear-gradient(135deg, var(--c-danger), #B91C1C);
}

.fmap-legend-dot.fmap-pin-verified {
  background: var(--c-teal);
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--c-teal);
}

/* User location pulse */
.fmap-user-wrapper {
  background: transparent !important;
  border: none !important;
}

.fmap-user-pulse {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.35);
  border: 3px solid #3B82F6;
  position: relative;
  animation: userPulse 2s ease-in-out infinite;
}

.fmap-user-pulse::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: #3B82F6;
}

@keyframes userPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, .4); }
  50% { box-shadow: 0 0 0 12px rgba(59, 130, 246, 0); }
}

/* Show more button */
.fmap-show-more {
  display: block;
  width: 100%;
  padding: 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--c-teal-deep);
  background: transparent;
  border: 1.5px dashed var(--c-teal);
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  transition: background .2s ease, color .2s ease;
}

.fmap-show-more:hover {
  background: var(--c-teal);
  color: #fff;
}

/* Pin wrapper for leaflet */
.fmap-pin-wrapper {
  background: transparent !important;
  border: none !important;
}

.fmap-pin-verified {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c-teal), 0 4px 10px rgba(15, 23, 42, .25) !important;
}

.pin-instock { background: linear-gradient(135deg, var(--c-teal), var(--c-violet)); }
.pin-low { background: linear-gradient(135deg, var(--c-warn), #B45309); }
.pin-out { background: linear-gradient(135deg, var(--c-danger), #B91C1C); }

/* Detail action bar at bottom */
.fmap-detail-actions a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 10px;
  text-align: center;
  color: var(--c-ink-2);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  transition: all .2s ease;
}

.fmap-detail-actions a:first-child {
  background: linear-gradient(135deg, var(--c-teal), var(--c-teal-deep));
  color: #fff;
  border-color: transparent;
}

.fmap-detail-actions a:hover {
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}

/* Search icon */
.fmap-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--c-muted-2);
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}

.fmap-search-header .fmap-search-row {
  position: relative;
}

.fmap-search-header .fmap-search-input {
  padding-left: 36px;
}

/* Nav link */
.fmap-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-ink-2);
  border-radius: 10px;
  transition: color .2s ease;
}

.fmap-nav-link:hover {
  color: var(--c-teal);
}

/* Marker cluster custom override */
.marker-cluster-custom {
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-cluster-custom > div {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* -------------------------------------------------------------
   18. Leaflet overrides

   ------------------------------------------------------------- */
.leaflet-popup-content-wrapper {
  border-radius: 14px;
  padding: 0;
  box-shadow: var(--sh-lg);
}

.leaflet-popup-content {
  margin: 0;
  padding: 12px;
  font-family: inherit;
  font-size: 12px;
  color: var(--c-ink-2);
  line-height: 1.4;
}

.leaflet-popup-tip {
  box-shadow: var(--sh-sm);
}

.leaflet-control-zoom a {
  border-radius: 10px !important;
  border: 1px solid var(--c-border) !important;
  background: rgba(255, 255, 255, 0.95) !important;
  color: var(--c-ink-2) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.leaflet-control-zoom a:hover {
  background: #fff !important;
  color: var(--c-teal) !important;
}

/* Cluster markers */
.marker-cluster {
  background: transparent !important;
}

.marker-cluster div {
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet)) !important;
  color: #fff !important;
  font-weight: 800 !important;
  font-family: var(--font-sans) !important;
  border: 3px solid #fff !important;
  box-shadow: 0 6px 18px rgba(20, 184, 166, .35), 0 2px 6px rgba(124, 58, 237, .25) !important;
}

.marker-cluster-small div { width: 34px; height: 34px; line-height: 28px; font-size: 12px; }
.marker-cluster-medium div { width: 40px; height: 40px; line-height: 34px; font-size: 13px; }
.marker-cluster-large div { width: 48px; height: 48px; line-height: 42px; font-size: 14px; }

/* Custom pin marker */
.fmap-pin {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 0;
  background: linear-gradient(135deg, var(--c-teal), var(--c-violet));
  border: 3px solid #fff;
  transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(15, 23, 42, .25);
  position: relative;
}

.fmap-pin::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}

.fmap-pin.warn { background: linear-gradient(135deg, var(--c-warn), #B45309); }
.fmap-pin.danger { background: linear-gradient(135deg, var(--c-danger), #B91C1C); }
.fmap-pin.success { background: linear-gradient(135deg, var(--c-success), var(--c-success-deep)); }

/* -------------------------------------------------------------
   19. Accessibility & motion
   ------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--c-teal);
  outline-offset: 2px;
  border-radius: 4px;
}

.fmap-card:focus-visible,
.fmap-fab:focus-visible {
  outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visually hidden helper */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------------------------------------------------
   20. Responsive — Tablet (768px–1023px)
   ------------------------------------------------------------- */
@media (max-width: 1023px) {
  .fmap-app {
    grid-template-columns: 1fr 1fr;
  }
  .fmap-app.fmap-3col {
    grid-template-columns: 300px 1fr;
    grid-template-areas:
      "nav    nav"
      "cards  main";
  }
  .fmap-app.fmap-3col .fmap-controls-panel {
    display: none;
  }

  .fmap-nav-link span { display: none; }
  .fmap-chat-btn span { display: none; }
  .fmap-chat-btn { padding: 8px 12px; }
}

/* -------------------------------------------------------------
   21. Responsive — Mobile (< 768px)
   ------------------------------------------------------------- */
@media (max-width: 767px) {
  .fmap-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "nav"
      "main";
  }

  /* 3-col variant also collapses to single column */
  .fmap-app.fmap-3col {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "nav"
      "main";
  }

  .fmap-main {
    grid-area: main;
    position: relative;
  }

  .fmap-mobile-toggle {
    display: grid;
  }

  /* Cards panel becomes a bottom-sheet drawer on mobile */
  .fmap-cards-panel {
    position: fixed;
    inset: auto 0 0 0;
    max-height: 75vh;
    width: 100%;
    border-right: none;
    border-radius: 24px 24px 0 0;
    transform: translateY(calc(100% - 72px));
    transition: transform .35s cubic-bezier(.22, 1, .36, 1);
    box-shadow: 0 -12px 40px rgba(15, 23, 42, .15);
    z-index: 700;
    padding-top: 8px;
  }

  .fmap-cards-panel::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--c-border-strong);
    z-index: 10;
  }

  .fmap-cards-panel.open {
    transform: translateY(0);
  }

  .fmap-cards-header {
    border-radius: 24px 24px 0 0;
    padding-top: 16px;
    cursor: pointer;
  }

  /* Sidebar also becomes a bottom-sheet drawer */
  .fmap-sidebar {
    position: fixed;
    inset: auto 0 0 0;
    max-height: 80vh;
    width: 100%;
    border-right: none;
    border-radius: 24px 24px 0 0;
    transform: translateY(calc(100% - 88px));
    transition: transform .35s cubic-bezier(.22, 1, .36, 1);
    box-shadow: 0 -12px 40px rgba(15, 23, 42, .15);
    z-index: 700;
    padding-top: 14px;
  }

  .fmap-sidebar::before {
    content: '';
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: var(--c-border-strong);
  }

  .fmap-sidebar.open {
    transform: translateY(0);
  }

  .fmap-search-header {
    border-radius: 24px 24px 0 0;
    padding-top: 18px;
  }

  /* Detail drawer becomes a full-width bottom sheet on mobile */
  .fmap-detail {
    width: 100%;
    height: 90vh;
    top: auto;
    bottom: 0;
    border-radius: 24px 24px 0 0;
    transform: translateY(100%);
  }

  .fmap-detail.open {
    transform: translateY(0);
  }

  /* Detail panel services grid — 2 columns on mobile */
  .fmap-detail-services,
  .fmap-services-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Detail action buttons stack on mobile */
  .fmap-detail-actions {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px;
  }

  .fmap-fab {
    width: 48px;
    height: 48px;
  }

  .fmap-fab-stack {
    bottom: 86px; /* keep clear of the peeking sheet */
    right: 12px;
  }

  .fmap-stats {
    gap: 6px;
    grid-template-columns: repeat(4, 1fr);
  }

  .fmap-stat {
    padding: 8px 4px;
  }

  .fmap-stat-num {
    font-size: 16px;
  }

  .fmap-chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 12px;
    gap: 6px;
    scrollbar-width: none;
  }
  .fmap-chips::-webkit-scrollbar { display: none; }

  .fmap-chip {
    flex-shrink: 0;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
  }

  /* Floating controls - reposition on mobile */
  .fmap-floating-controls {
    top: 10px;
    right: 10px;
    gap: 6px;
  }

  .fmap-pill-btn {
    padding: 6px 10px;
    font-size: 10px;
  }

  /* Modal fullscreen on mobile */
  .fmap-modal-card {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    max-height: 92vh;
    margin-top: auto;
  }

  .fmap-modal {
    align-items: flex-end;
    padding: 0;
  }

  /* Nav adjustments */
  .fmap-nav {
    height: 56px;
    padding: 0 12px;
    gap: 8px;
  }

  .fmap-nav-logo-icon {
    width: 34px;
    height: 34px;
    font-size: 11px;
    border-radius: 10px;
  }

  .fmap-nav-title {
    font-size: 13px;
  }

  .fmap-count-badge {
    padding: 4px 8px;
    font-size: 10px;
  }

  .fmap-nav-link span { display: none; }
  .fmap-chat-btn span { display: none; }
  .fmap-chat-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
  }

  /* Card images smaller on mobile */
  .fmap-card-img {
    height: 90px;
  }

  .fmap-list {
    padding: 6px 8px;
    gap: 6px;
  }
}

/* -------------------------------------------------------------
   22. Responsive — small phones (< 480px)
   ------------------------------------------------------------- */
@media (max-width: 479px) {
  .fmap-nav {
    padding: 0 10px;
    gap: 6px;
    height: 52px;
  }

  .fmap-nav-sub {
    display: none;
  }

  .fmap-nav-logo-text {
    max-width: 120px;
  }

  .fmap-nav-title {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .fmap-icon-btn {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .fmap-count-badge { display: none; }

  .fmap-stat-num {
    font-size: 14px;
  }

  .fmap-stat-label {
    font-size: 7px;
  }

  .fmap-card-title {
    font-size: 12px;
  }

  .fmap-card-body {
    padding: 10px 10px 8px;
  }

  .fmap-card-meta {
    font-size: 10px;
    gap: 6px;
  }

  .fmap-service-tag {
    font-size: 8px;
    padding: 2px 5px;
  }

  /* Detail panel adjustments */
  .fmap-detail-name {
    font-size: 18px;
    padding: 14px 16px 4px;
  }

  .fmap-detail-section {
    padding: 12px 16px;
  }

  .fmap-detail-services,
  .fmap-services-grid {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .fmap-service-row {
    font-size: 11px;
    padding: 6px 8px;
  }

  .fmap-action-btn {
    height: 38px;
    font-size: 11px;
  }

  /* AI strip compact */
  .fmap-ai-strip {
    margin: 8px;
    padding: 8px 10px;
    gap: 8px;
  }

  .fmap-ai-strip-icon {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  .fmap-ai-strip-title { font-size: 11px; }
  .fmap-ai-strip-sub { font-size: 9px; }

  /* Select dropdowns */
  .fmap-select-row { padding: 0 8px; }
  .fmap-select { font-size: 11px; height: 34px; }
}

/* -------------------------------------------------------------
   23. Dark mode
   ------------------------------------------------------------- */
html.dark {
  --c-surface: #0F172A;
  --c-surface-2: #1E293B;
  --c-bg: #020617;
  --c-ink: #E2E8F0;
  --c-ink-2: #CBD5E1;
  --c-muted: #94A3B8;
  --c-muted-2: #64748B;
  --c-border: rgba(255, 255, 255, 0.08);
  --c-border-strong: rgba(255, 255, 255, 0.16);
  --c-violet-soft: rgba(124, 58, 237, 0.18);

  --sh-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 1px 3px rgba(0, 0, 0, .35);
  --sh-md: 0 4px 12px rgba(0, 0, 0, .35), 0 2px 4px rgba(0, 0, 0, .25);
  --sh-lg: 0 12px 32px rgba(0, 0, 0, .55), 0 4px 8px rgba(0, 0, 0, .35);
}

html.dark body {
  background: var(--c-bg);
  color: var(--c-ink);
}

html.dark .fmap-nav,
html.dark .fmap-sidebar,
html.dark .fmap-card,
html.dark .fmap-detail,
html.dark .fmap-modal-card,
html.dark .fmap-search-header,
html.dark .fmap-detail-actions {
  background: var(--c-surface);
}

html.dark .fmap-icon-btn,
html.dark .fmap-mobile-toggle {
  background: var(--c-surface-2);
}

html.dark .fmap-search-input,
html.dark .fmap-select,
html.dark .fmap-stat,
html.dark .fmap-detail-service,
html.dark .fmap-review-textarea,
html.dark .fmap-chip {
  background: var(--c-surface-2);
  color: var(--c-ink);
}

html.dark .fmap-chip:hover {
  background: #2A3A52;
}

html.dark .fmap-count-badge {
  background: rgba(124, 58, 237, 0.18);
  color: #C4B5FD;
}

html.dark .fmap-ai-strip {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(20, 184, 166, 0.15));
  border-color: rgba(124, 58, 237, 0.25);
}

html.dark .fmap-ai-summary {
  background: linear-gradient(135deg, rgba(124, 58, 237, .12), rgba(20, 184, 166, .12));
  border-color: rgba(124, 58, 237, 0.2);
}

html.dark .fmap-ai-theme-chip {
  background: rgba(255, 255, 255, 0.06);
  color: #C4B5FD;
}

html.dark .fmap-ai-insight {
  color: #C4B5FD;
  background: rgba(124, 58, 237, 0.12);
}

html.dark .fmap-pill {
  background: rgba(15, 23, 42, 0.85);
  color: var(--c-ink);
}

html.dark .fmap-pill:hover {
  background: rgba(15, 23, 42, 1);
}

html.dark .fmap-loading {
  background: rgba(2, 6, 23, 0.8);
}

html.dark .fmap-modal {
  background: rgba(2, 6, 23, 0.7);
}

html.dark .leaflet-control-zoom a {
  background: rgba(15, 23, 42, 0.85) !important;
  color: var(--c-ink) !important;
  border-color: var(--c-border) !important;
}

html.dark .leaflet-popup-content-wrapper,
html.dark .leaflet-popup-tip {
  background: var(--c-surface);
  color: var(--c-ink);
}

html.dark .fmap-action-btn.qr {
  background: var(--c-surface-2);
  color: var(--c-ink);
  border-color: var(--c-border-strong);
}

html.dark .fmap-action-btn.qr:hover {
  background: var(--c-ink);
  color: var(--c-surface);
}

html.dark .fmap-star-btn {
  color: #334155;
}

/* Leaflet tile inversion for dark mode */
html.dark .leaflet-tile {
  filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9);
}

html.dark .leaflet-container {
  background: #020617;
}

/* Service tag dark adjustments — keep readable */
html.dark .fmap-service-tag {
  background: rgba(255, 255, 255, 0.06);
  color: var(--c-ink-2);
}

html.dark .fmap-service-tag.youth { background: rgba(20, 184, 166, 0.18); color: #5EEAD4; }
html.dark .fmap-service-tag.pep { background: rgba(245, 158, 11, 0.18); color: #FCD34D; }
html.dark .fmap-service-tag.prep { background: rgba(59, 130, 246, 0.2); color: #93C5FD; }
html.dark .fmap-service-tag.srhr { background: rgba(124, 58, 237, 0.22); color: #C4B5FD; }
html.dark .fmap-service-tag.gbv { background: rgba(244, 63, 94, 0.2); color: #FDA4AF; }
html.dark .fmap-service-tag.mental { background: rgba(99, 102, 241, 0.22); color: #A5B4FC; }
html.dark .fmap-service-tag.ec { background: rgba(236, 72, 153, 0.2); color: #F9A8D4; }
html.dark .fmap-service-tag.art { background: rgba(217, 119, 6, 0.22); color: #FCD34D; }

/* -------------------------------------------------------------
   24. Print
   ------------------------------------------------------------- */
@media print {
  .fmap-nav,
  .fmap-fab-stack,
  .fmap-controls,
  .fmap-mobile-toggle {
    display: none !important;
  }

  .fmap-app {
    display: block;
    height: auto;
  }

  .fmap-sidebar {
    border-right: none;
    height: auto;
    overflow: visible;
  }

  .fmap-card {
    break-inside: avoid;
  }
}
