/* ==========================================================
   FTM Reseller Locator — Design tokens
   Forest green + gold, tying into FTM's existing brand.
   Signature element: the "spark-pin" map marker — a location
   pin with a small bolt notch, echoing FTM's electrical trade.
   ========================================================== */
:root {
  --forest-900: #0f2a1e;
  --forest-700: #1b4332;
  --forest-600: #256845;
  --forest-100: #e6efe8;
  --gold-500: #c9a227;
  --gold-300: #e2c568;
  --cream-50: #f7f5ef;
  --ink-900: #1d2620;
  --ink-500: #5b6a5f;
  --line-200: #e2ded1;
  --white: #ffffff;
  --danger: #b3452f;

  --font-display: 'Space Grotesk', 'Noto Kufi Arabic', sans-serif;
  --font-body: 'IBM Plex Sans', 'Noto Sans Arabic', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-pin: 50% 50% 50% 0;
  --shadow-card: 0 2px 10px rgba(15, 42, 30, 0.08);
  --shadow-lift: 0 8px 24px rgba(15, 42, 30, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--cream-50);
  color: var(--ink-900);
  font-family: var(--font-body);
}

[dir="rtl"] body { font-family: 'Noto Sans Arabic', var(--font-body); }

h1, h2, h3, .display {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
}

a { color: inherit; }

button { font-family: inherit; cursor: pointer; }

/* ---------------- Top bar ---------------- */
.topbar {
  background: var(--forest-700);
  color: var(--white);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-card);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pin);
  background: var(--gold-500);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-45deg);
  flex-shrink: 0;
}
[dir="rtl"] .brand-mark { transform: rotate(45deg) scaleX(-1); }

.brand-mark svg { transform: rotate(45deg); width: 18px; height: 18px; }
[dir="rtl"] .brand-mark svg { transform: rotate(-45deg) scaleX(-1); }

.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}
.brand-name span { color: var(--gold-300); }

.lang-switch {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.08);
  padding: 4px;
  border-radius: 999px;
}
.lang-switch a {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  text-decoration: none;
  color: rgba(255,255,255,0.75);
}
.lang-switch a.active {
  background: var(--gold-500);
  color: var(--forest-900);
  font-weight: 600;
}

/* ---------------- Hero / search ---------------- */
.hero {
  padding: 28px 24px 20px;
  text-align: center;
  background: linear-gradient(180deg, var(--forest-700) 0%, var(--forest-900) 140%);
  color: var(--white);
}
.hero h1 { font-size: 1.6rem; margin-bottom: 6px; }
.hero p { margin: 0 0 18px; color: rgba(255,255,255,0.78); font-size: 0.95rem; }

.search-panel {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.search-input-wrap {
  position: relative;
  flex: 1 1 320px;
}

.search-input {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 0.95rem;
  background: var(--white);
  color: var(--ink-900);
}
.search-input:focus { outline: 3px solid var(--gold-300); }

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--white);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lift);
  max-height: 220px;
  overflow-y: auto;
  z-index: 30;
  text-align: start;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-list button {
  display: block;
  width: 100%;
  text-align: start;
  padding: 10px 14px;
  border: none;
  background: none;
  font-size: 0.9rem;
  color: var(--ink-900);
}
.autocomplete-list button:hover { background: var(--forest-100); }

.btn {
  padding: 13px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-gold { background: var(--gold-500); color: var(--forest-900); }
.btn-gold:hover { background: var(--gold-300); }
.btn-outline { background: rgba(255,255,255,0.08); color: var(--white); border: 1px solid rgba(255,255,255,0.35); }
.btn-outline:hover { background: rgba(255,255,255,0.18); }

.status-line {
  max-width: 720px;
  margin: 10px auto 0;
  font-size: 0.82rem;
  color: var(--gold-300);
  min-height: 18px;
}

/* ---------------- Layout: list + map ---------------- */
.locator-layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) 1fr;
  height: calc(100vh - 178px);
  min-height: 480px;
}

.results-pane {
  overflow-y: auto;
  padding: 16px;
  background: var(--white);
  border-inline-end: 1px solid var(--line-200);
}

.results-meta {
  font-size: 0.82rem;
  color: var(--ink-500);
  margin-bottom: 12px;
  padding: 0 4px;
}

.reseller-card {
  border: 1px solid var(--line-200);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 12px;
  background: var(--white);
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.reseller-card:hover, .reseller-card.active {
  box-shadow: var(--shadow-card);
  border-color: var(--forest-600);
}

.reseller-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.reseller-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  margin: 0 0 4px;
}

.tier-badge {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: var(--forest-100);
  color: var(--forest-700);
}
.tier-badge.premium { background: #fbeecb; color: #8a6a10; }
.tier-badge.flagship { background: var(--forest-700); color: var(--white); }

.distance-chip {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--forest-700);
  white-space: nowrap;
}

.reseller-address {
  font-size: 0.85rem;
  color: var(--ink-500);
  margin: 6px 0;
  line-height: 1.4;
}

.reseller-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.mini-btn {
  font-size: 0.78rem;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line-200);
  background: var(--cream-50);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-decoration: none;
  color: var(--ink-900);
}
.mini-btn.primary { background: var(--forest-700); color: var(--white); border-color: var(--forest-700); }
.mini-btn:hover { border-color: var(--forest-600); }

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-500);
}

.map-pane { position: relative; }
#map { height: 100%; width: 100%; }

/* Leaflet popup styling tweaks */
.leaflet-popup-content-wrapper { border-radius: var(--radius-sm); }
.popup-title { font-family: var(--font-display); font-weight: 600; margin-bottom: 4px; }
.popup-address { font-size: 0.82rem; color: var(--ink-500); margin-bottom: 6px; }

/* Custom marker */
.spark-pin {
  width: 30px; height: 30px;
  background: var(--forest-700);
  border: 2px solid var(--white);
  border-radius: var(--radius-pin);
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-card);
}
.spark-pin svg { transform: rotate(45deg); width: 15px; height: 15px; }
.spark-pin.flagship { background: var(--gold-500); }

footer.site-footer {
  text-align: center;
  padding: 14px;
  font-size: 0.78rem;
  color: var(--ink-500);
  background: var(--white);
  border-top: 1px solid var(--line-200);
}

/* Mobile toggle between list/map */
.mobile-toggle { display: none; }

@media (max-width: 860px) {
  .locator-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .results-pane { border-inline-end: none; border-bottom: 1px solid var(--line-200); max-height: none; }
  .map-pane { height: 360px; }
  .hero h1 { font-size: 1.3rem; }
  .mobile-toggle {
    display: flex;
    gap: 6px;
    padding: 10px 16px 0;
    justify-content: center;
  }
  .mobile-toggle button {
    flex: 1;
    padding: 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line-200);
    background: var(--white);
    font-size: 0.85rem;
    font-weight: 600;
  }
  .mobile-toggle button.active { background: var(--forest-700); color: var(--white); border-color: var(--forest-700); }
  .locator-layout.show-map .results-pane { display: none; }
  .locator-layout.show-list .map-pane { display: none; }
}

:focus-visible { outline: 3px solid var(--gold-500); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
