/* ============================================================
   MAP SHOWCASE — Readable, distinguishable (solid backgrounds, clear colors)
   Uses: var(--color-*), var(--font-*), var(--space-*), var(--radius-*)
   ============================================================ */

/* ── Section wrapper ── */
.map-showcase {
  background: var(--color-bg-main);
  padding: var(--space-12) 0 var(--space-10);
  position: relative;
  overflow: hidden;
}

.map-showcase::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--color-border-light);
  opacity: 0.6;
}

/* ── Header: aligned with other section titles ── */
.map-showcase__header {
  text-align: center;
  margin-bottom: var(--space-6);
  padding: 0;
}

.map-showcase__label {
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  color: var(--color-primary);
  text-transform: uppercase;
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-4);
}

.map-showcase__title {
  font-family: var(--font-display);
  font-size: clamp(var(--text-4xl), 5vw, var(--text-6xl));
  font-weight: var(--font-extrabold);
  color: var(--color-text-dark);
  margin: 0 0 var(--space-4);
  line-height: 1.1;
}

/* Match main content width */
.map-showcase-container {
  max-width: var(--container-xl);
  padding: 0 var(--space-4);
}

/* ── Layout: full-width map (no sidebar), explicit height so map fills ── */
.map-showcase__layout {
  display: block;
  width: 100%;
  margin: 0;
  height: 520px;
  min-height: 520px;
  border-radius: var(--radius-2xl);
  overflow: hidden;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  background: var(--color-bg);
}

/* ── Sidebar: solid background ── */
.map-showcase__sidebar {
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  padding: var(--space-5) var(--space-4);
  min-height: 520px;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* Sidebar blocks: solid + staggered entrance */
.map-sidebar__block {
  margin-bottom: var(--space-5);
  padding: var(--space-5);
  background: var(--color-bg);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border-light);
  box-shadow: var(--shadow-sm);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    border-color 0.3s ease;
  overflow: visible;
}
.map-showcase__layout.is-revealed .map-sidebar__block {
  opacity: 1;
  transform: translateY(0);
}
.map-showcase__layout.is-revealed .map-sidebar__block:nth-child(1) { transition-delay: 0.12s; }
.map-showcase__layout.is-revealed .map-sidebar__block:nth-child(2) { transition-delay: 0.22s; }
.map-showcase__layout.is-revealed .map-sidebar__block:nth-child(3) { transition-delay: 0.32s; }
.map-sidebar__block:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-border);
}
.map-sidebar__block:last-child {
  margin-bottom: 0;
}
.map-sidebar__label {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

/* Search: keep dropdown above Top Cities (glavni gradovi) */
.map-sidebar__search-wrap {
  position: relative;
  z-index: 30;
}
.map-sidebar__search {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.map-sidebar__search:hover {
  border-color: var(--color-border-strong);
}
.map-sidebar__search:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}
.map-sidebar__search-icon {
  flex-shrink: 0;
  padding: 0 var(--space-3);
  font-size: 1rem;
  opacity: 0.6;
  pointer-events: none;
}
.map-sidebar__search-input {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) var(--space-4) var(--space-3) 0;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
  background: none;
  border: none;
  outline: none;
}
.map-sidebar__search-input::placeholder {
  color: var(--color-text-muted);
}
.map-sidebar__suggestions {
  position: relative;
  margin-top: var(--space-2);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow-y: auto;
}
.map-sidebar__suggestions[hidden] {
  display: none;
}
.map-sidebar__suggestions-inner {
  padding: var(--space-2) 0;
}
.map-sidebar__suggestion-item {
  display: block;
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
  font-family: var(--font-sans);
}
.map-sidebar__suggestion-item:hover,
.map-sidebar__suggestion-item[aria-selected="true"] {
  background: var(--color-primary-lighter);
}

/* Top Cities */
.map-sidebar__title {
  font-size: var(--text-base);
  font-weight: var(--font-bold);
  color: var(--color-text-dark);
  margin: 0 0 var(--space-4);
  padding: 0 0 var(--space-3);
  letter-spacing: -0.01em;
  border-bottom: 2px solid var(--color-primary);
  display: inline-block;
  line-height: 1.2;
}

.map-sidebar__regions {
  list-style: none;
  padding: 0;
  margin: 0;
}

.map-sidebar__region-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.25s ease;
  border: 1px solid var(--color-border-light);
  margin-bottom: var(--space-2);
  text-align: left;
  width: 100%;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-bg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  position: relative;
}
.map-sidebar__region-item:last-child {
  margin-bottom: 0;
}
.map-sidebar__region-item:hover {
  background: var(--color-primary-lighter);
  border-color: rgba(0, 106, 255, 0.25);
  box-shadow: var(--shadow-sm);
  transform: translateX(2px);
}
.map-sidebar__region-item.is-active {
  background: var(--color-primary-lighter);
  border-color: var(--color-primary);
  color: var(--color-text);
  box-shadow: 0 0 0 1px var(--color-primary-soft);
}
.map-sidebar__region-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  cursor: pointer;
}
.map-sidebar__region-name {
  font-weight: var(--font-semibold);
  color: var(--color-text-dark);
  flex: 1;
  min-width: 0;
}
.map-sidebar__region-count {
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
  color: #fff;
  background: var(--color-primary);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  margin-left: var(--space-2);
}
.map-sidebar__region-item.is-active .map-sidebar__region-count {
  background: var(--color-primary-dark);
  color: #fff;
}

/* View more: second action (opens city page), clearly distinct */
.map-sidebar__region-view-more {
  display: inline-block;
  margin-top: 0;
  padding: 0 var(--space-3);
  border-top: 1px solid transparent;
  font-size: 12px;
  font-weight: var(--font-semibold);
  color: var(--color-primary);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.2s ease, margin 0.2s ease, padding 0.2s ease, border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
  width: 100%;
  text-align: center;
  line-height: 1.2;
}
.map-sidebar__region-view-more:hover {
  color: var(--color-primary-dark);
  background: var(--color-primary-lighter);
  border-color: var(--color-primary);
  text-decoration: none;
}
.map-sidebar__region-item:hover .map-sidebar__region-view-more {
  opacity: 1;
  max-height: 4em;
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-top-color: var(--color-border);
}

/* Show on map: filter toggles stacked vertically, text forced visible */
.map-sidebar__legend-wrap .map-sidebar__label {
  display: block;
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  text-transform: none;
  letter-spacing: 0;
  color: #0f172a !important;
}
.map-sidebar__legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.map-sidebar__legend-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  font-weight: var(--font-semibold);
  color: var(--color-text) !important;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.map-sidebar__legend-btn:hover {
  background: var(--color-bg);
  border-color: var(--color-border-strong);
  color: var(--color-text-dark) !important;
}
.map-sidebar__legend-btn.is-active {
  background: var(--color-bg);
  box-shadow: var(--shadow-sm);
  border-color: var(--color-border);
  color: var(--color-text-dark) !important;
}
.map-sidebar__legend-btn--sell.is-active {
  color: #b91c1c !important;
  background: rgba(185, 28, 28, 0.1);
  border-color: rgba(185, 28, 28, 0.35);
}
.map-sidebar__legend-btn--sell.is-active .map-sidebar__legend-dot--sell {
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.3);
}
.map-sidebar__legend-btn--rent.is-active {
  color: #1d4ed8 !important;
  background: rgba(29, 78, 216, 0.1);
  border-color: rgba(29, 78, 216, 0.35);
}
.map-sidebar__legend-btn--rent.is-active .map-sidebar__legend-dot--rent {
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.3);
}
.map-sidebar__legend-btn:not(.is-active) .map-sidebar__legend-dot {
  opacity: 0.5;
}
.map-sidebar__legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
}
.map-sidebar__legend-dot--sell {
  background: #b91c1c;
}
.map-sidebar__legend-dot--rent {
  background: #1d4ed8;
}
.map-sidebar__legend-text {
  white-space: nowrap;
  color: inherit !important;
}

/* ── Map wrapper: fills layout so map can fill it ── */
.map-showcase__map-wrapper {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 520px;
  opacity: 1;
  transform: none;
}

.map-showcase__map-wrapper--ready {
  box-shadow: inset 0 0 0 1px rgba(0, 106, 255, 0.06);
}

/* Map div must have explicit height for Leaflet; fill wrapper */
.map-showcase__map {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 400px;
  z-index: 1;
  background: var(--color-bg-secondary);
}

/* Leaflet: fill map div and match site background */
.map-showcase .leaflet-container {
  height: 100% !important;
  background: var(--color-bg-secondary);
  font-family: var(--font-sans);
}
.map-showcase .leaflet-map-pane,
.map-showcase .leaflet-tile-pane {
  height: 100%;
}

/* No filter on tiles to avoid compositing flicker during load */
.map-showcase .leaflet-tile-pane img {
  opacity: 1;
}

/* ── Floating Property Preview Card ── */
.map-preview-card {
  position: absolute;
  bottom: var(--space-6);
  right: var(--space-6);
  width: 300px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 800;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.map-preview-card.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.map-preview-card__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--color-border);
  border-radius: 50%;
  color: var(--color-text);
  font-size: 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  line-height: 1;
  transition: background var(--transition);
}

.map-preview-card__close:hover {
  background: var(--color-bg-secondary);
}

.map-preview-card__image-wrap {
  position: relative;
  height: 160px;
  overflow: hidden;
  background: var(--color-bg-secondary);
}

.map-preview-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.map-preview-card:hover .map-preview-card__image {
  transform: scale(1.04);
}

.map-preview-card__badge {
  position: absolute;
  bottom: var(--space-2);
  left: var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: var(--font-semibold);
}

.map-preview-card__badge--sell {
  background: #b91c1c;
  color: #fff;
}

.map-preview-card__badge--rent {
  background: #1d4ed8;
  color: #fff;
}

.map-preview-card__body {
  padding: var(--space-4) var(--space-5);
}

.map-preview-card__type {
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.map-preview-card__price {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--color-text);
  margin-bottom: var(--space-2);
  line-height: 1.1;
}

.map-preview-card__title {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
  line-height: 1.4;
}

.map-preview-card__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-4);
  display: flex;
  gap: var(--space-3);
}

.map-preview-card__cta {
  display: block;
  text-align: center;
  background: var(--color-primary);
  color: #fff;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  padding: var(--space-3) 0;
  border-radius: var(--radius);
  text-decoration: none;
  transition: background var(--transition), transform 0.15s ease;
}

.map-preview-card__cta:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* ── Region hover bubble ── */
.map-region-bubble {
  position: absolute;
  top: var(--space-5);
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.map-region-bubble.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.map-region-bubble strong {
  color: var(--color-primary);
}

/* ── Custom Leaflet pin markers (teardrop shape) ── */
.map-pin-wrap {
  background: none !important;
  border: none !important;
}

.map-pin {
  display: inline-block;
  cursor: pointer;
  transition: transform 0.2s ease, filter 0.2s ease;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)) drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

.map-pin:hover,
.map-pin.is-active {
  transform: scale(1.2);
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.4)) drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.map-pin__svg {
  display: block;
  pointer-events: none;
}

/* All pins blue (same as other maps on the site) */
.map-pin--sell .map-pin__svg path,
.map-pin--rent .map-pin__svg path {
  fill: #1d4ed8;
}

/* ── Cluster marker ── */
.map-cluster {
  background: var(--color-primary);
  color: #fff;
  border-radius: 50%;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  transition: transform 0.2s;
}

.map-cluster:hover {
  transform: scale(1.1);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .map-showcase__layout {
    height: clamp(360px, 55vmin, 520px);
    min-height: 360px;
    border-radius: var(--radius-xl);
  }

  .map-showcase__map-wrapper {
    border-radius: var(--radius-xl);
    min-height: 360px;
  }

  .map-preview-card {
    width: calc(100% - var(--space-12));
    right: var(--space-6);
    left: var(--space-6);
  }
}

@media (max-width: 768px) {
  .map-showcase-container {
    padding: 0 var(--space-3);
  }

  .map-showcase__layout {
    height: 60vh;
    min-height: 320px;
    max-height: 480px;
  }

  .map-showcase__map-wrapper {
    min-height: 320px;
  }

  .map-preview-card {
    width: calc(100% - var(--space-8));
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
  }
}

@media (max-width: 480px) {
  .map-showcase {
    padding: var(--space-8) 0 var(--space-6);
  }

  .map-showcase__layout {
    height: 60vh;
    min-height: 280px;
    max-height: 420px;
  }

  .map-showcase__title {
    font-size: var(--text-2xl);
  }
}

/* ── Scroll reveal animation ── */
.map-showcase__header {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 1s cubic-bezier(0.22, 1, 0.36, 1),
    transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.map-showcase__layout {
  opacity: 0;
  transform: translateY(32px) scale(0.98);
  transition: opacity 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.2s,
    transform 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.2s;
}

.map-showcase__header.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.map-showcase__layout.is-revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(0, 106, 255, 0.05);
}

/* Scoped Leaflet controls for homepage map */
#homepage-map .leaflet-popup-content-wrapper {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
}

#homepage-map .leaflet-popup-tip {
  background: var(--color-bg);
}

#homepage-map .leaflet-control-zoom a {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

#homepage-map .leaflet-control-zoom a:hover {
  background: var(--color-primary-lighter);
  color: var(--color-primary);
}

/* Map section: larger on big screens for country-level showcase */
@media (min-width: 1200px) {
  .map-showcase__layout {
    height: 560px;
    min-height: 560px;
  }
  .map-showcase__map-wrapper {
    min-height: 560px;
  }
}

/* Linter compatibility: use standard properties with vendor prefixes when needed.
   For transform: include both -webkit-transform and transform.
   For animation: include both -webkit-animation-* and animation-* (or shorthand). */
