@import url('https://fonts.googleapis.com/css2?family=Geist:wght@400;500;600;700&display=swap');

:root {
  --brand-blue: #0842ab;
  --brand-blue-dark: #063589;
  --brand-blue-light: #e8eef8;
  --brand-accent: #ffbd59;
  --brand-accent-dark: #e5a840;
  --brand-accent-light: #fff5e6;
  --surface: #ffffff;
  --surface-elevated: #ffffff;
  --text: #1c1c1a;
  --text-muted: #5c5c56;
  --border: #e8e8e8;
  --shadow: 0 4px 24px rgba(8, 66, 171, 0.1);
  --radius: 12px;
  --font: 'Geist', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */

.map-app {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100vh;
  overflow: hidden;
}

.map-app--embed {
  grid-template-columns: 1fr;
  height: 100%;
}

/* ── Sidebar ── */

.sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface-elevated);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 1000;
}

.sidebar__header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-dark) 100%);
  color: white;
}

.sidebar__header h1 {
  font-family: var(--font);
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.sidebar__header p {
  font-size: 0.8rem;
  opacity: 0.85;
}

.sidebar__search {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar__search input {
  width: 100%;
  padding: 0.6rem 0.85rem 0.6rem 2.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.875rem;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235c5c56' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") no-repeat 0.75rem center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.sidebar__search input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(8, 66, 171, 0.12);
}

.office-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  list-style: none;
}

.office-list::-webkit-scrollbar {
  width: 6px;
}

.office-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.office-card {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  border: 1px solid transparent;
  margin-bottom: 0.25rem;
}

.office-card:hover {
  background: var(--brand-blue-light);
}

.office-card--active {
  background: var(--brand-blue-light);
  border-color: var(--brand-blue);
}

.office-card__city {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--brand-blue);
  margin-bottom: 0.2rem;
}

.office-card__name {
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.office-card__address {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.office-card__badge {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--brand-accent);
  color: var(--text);
}

/* ── Map ── */

.map-container {
  position: relative;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* ── Leaflet overrides ── */

.leaflet-popup-content-wrapper {
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0;
  min-width: 240px;
}

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

.popup {
  font-family: var(--font);
}

.popup__header {
  background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-dark) 100%);
  color: white;
  padding: 0.85rem 1rem;
}

.popup__city {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

.popup__name {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0.15rem;
}

.popup__body {
  padding: 0.85rem 1rem;
}

.popup__row {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

.popup__row svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--brand-blue);
}

.popup__link {
  color: var(--brand-blue);
  text-decoration: none;
  font-weight: 500;
}

.popup__link:hover {
  text-decoration: underline;
}

.popup__actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 0.85rem;
}

.popup__btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
}

.popup__btn--primary,
.popup__btn--primary:hover,
.popup__btn--primary:visited,
.popup__btn--primary:focus {
  background: var(--brand-blue);
  color: #ffffff;
}

.popup__btn--primary:hover {
  background: var(--brand-blue-dark);
  color: #ffffff;
}

.leaflet-popup-content a.popup__btn--primary {
  color: #ffffff;
}

/* Custom marker */

.leaflet-marker-icon.office-marker {
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(8, 66, 171, 0.35);
  transition: transform 0.2s ease;
}

.leaflet-marker-icon.office-marker--primary {
  box-shadow: 0 3px 14px rgba(8, 66, 171, 0.45);
}

.leaflet-marker-icon.office-marker--active {
  transform: scale(1.2);
  z-index: 1000 !important;
  filter: drop-shadow(0 0 6px rgba(255, 189, 89, 0.7));
}

/* ── Mobile toggle ── */

.mobile-toggle {
  display: none;
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  padding: 0.65rem 1.25rem;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-blue);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: background 0.15s;
}

.mobile-toggle:hover {
  background: var(--brand-blue-light);
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .map-app:not(.map-app--embed) {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(340px, 90vw);
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow);
  }

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

  .mobile-toggle {
    display: block;
  }
}
