/* Map section styling - O! Lokalne */

body.map-page .nav-location-chk,
body.map-page .mobile-location-btn {
  display: none !important;
}

/* The map keeps the filter select in the DOM for its data/configuration, but
   does not show it beside the search field. The home page is unaffected. */
body.map-page .header-city-select-wrap {
  display: none !important;
}

body.map-page {
  overflow-x: hidden;
  min-height: 100vh;
  background: var(--bg-color) !important;
}

/* Fix main content position so it does NOT slide under the sidebar menu */
body.map-page .main-content.map-main {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  min-height: calc(100vh - 64px);
  padding: 0 !important;
  margin-top: 0 !important;
  position: relative;
  overflow: hidden;
  background: var(--bg-color) !important;
  box-sizing: border-box;
}

@media (min-width: 993px) {
  body.map-page .main-content.map-main {
    margin-left: var(--sidebar-width, 240px);
    width: calc(100% - var(--sidebar-width, 240px));
    transition: margin-left 0.2s ease, width 0.2s ease;
  }

  :root.sidebar-collapsed body.map-page .main-content.map-main {
    margin-left: var(--sidebar-collapsed-width, 72px);
    width: calc(100% - var(--sidebar-collapsed-width, 72px));
  }
}

@media (max-width: 992px) {
  body.map-page .main-content.map-main {
    margin-left: 0 !important;
    width: 100% !important;
  }
}

/* Keep categories aligned with the home page while the map fills the content column. */
body.map-page .top-categories-bar {
  position: relative;
  top: auto;
  flex: 0 0 auto;
  z-index: 15;
  background: var(--bg-color) !important;
  padding: 9px 24px !important;
  margin: 0 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.map-view-wrapper {
  position: relative;
  width: 100%;
  flex: 1 1 auto;
  min-height: 300px;
  min-width: 0;
  background-color: var(--bg-color);
  overflow: hidden;
}

.map-empty-state {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 8;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: color-mix(in srgb, var(--card-bg) 92%, transparent);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  text-align: center;
  font-size: 0.86rem;
  pointer-events: none;
}

.map-empty-state[hidden] {
  display: none;
}

.map-empty-state i {
  flex: 0 0 auto;
  color: var(--accent-color);
  font-size: 1.15rem;
}

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
}

/* Adjust MapLibre navigation buttons so they do not overlap top category bar */
.maplibregl-ctrl-top-right {
  top: 15px !important;
  right: 15px !important;
  z-index: 10 !important;
}

/* Floating "Szukaj w tym obszarze" button */
.search-in-area-btn {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12;
  background: color-mix(in srgb, var(--card-bg) 92%, transparent);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 22px;
  border-radius: 30px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.25s ease;
  opacity: 1;
  visibility: visible;
}

.search-in-area-btn:hover {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 12px 28px rgba(229, 9, 20, 0.45);
}

.search-in-area-btn.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateX(-50%) translateY(-10px);
}

/* Custom Map Markers & Clusters */
.olokalne-map-marker {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #ff6b00, #ff3300);
  border: 2px solid #ffffff;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(255, 107, 0, 0.4);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.olokalne-map-marker:hover {
  transform: rotate(-45deg) scale(1.18);
  z-index: 20;
}

.olokalne-cluster-marker {
  background: linear-gradient(135deg, #ff0055, #cc0033);
  color: #ffffff;
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(204, 0, 51, 0.45);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.olokalne-cluster-marker:hover {
  transform: scale(1.12);
}

/* Compact Scrollable Multi-item Popup (Desktop & Mobile) */
.maplibregl-popup {
  max-width: 320px !important;
  z-index: 25;
}

.maplibregl-popup-content {
  background: var(--card-bg) !important;
  color: var(--text-primary) !important;
  border-radius: 14px !important;
  padding: 12px !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border-color) !important;
}

/* Keep every text element inside map popups and the preview drawer at 500. */
.maplibregl-popup,
.maplibregl-popup *,
#adPreviewDrawer,
#adPreviewDrawer *,
.ad-preview-drawer,
.ad-preview-drawer * {
  font-weight: 500 !important;
}

.maplibregl-popup-close-button {
  color: var(--text-secondary);
  font-size: 1.2rem;
  padding: 3px 8px;
}

.maplibregl-popup-close-button:hover {
  background: transparent;
  color: var(--text-primary);
}

.map-popup-header {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-color);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.map-popup-list {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
  overscroll-behavior: contain;
}

.map-popup-list::-webkit-scrollbar {
  width: 5px;
}
.map-popup-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.map-popup-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease, transform 0.15s ease;
}

.map-popup-item:hover {
  background: rgba(255, 255, 255, 0.14);
  transform: translateX(2px);
}

.map-popup-thumb {
  width: 46px;
  height: 46px;
  border-radius: 6px;
  object-fit: cover;
  background: #2a2a2a;
  flex-shrink: 0;
}

.map-popup-info {
  flex: 1;
  min-width: 0;
}

.map-popup-title {
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.map-popup-price {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--accent-color);
}

.map-popup-city {
  font-size: 0.72rem;
  color: var(--text-secondary, #aaaaaa);
}

.map-popup-footer {
  font-size: 0.72rem;
  color: var(--text-secondary);
  text-align: center;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-color);
  cursor: pointer;
}

.map-popup-footer.is-loading {
  opacity: 0.7;
  cursor: wait;
}

/* Ad Preview Drawer / Modal Panel */
.ad-preview-drawer {
  position: absolute;
  z-index: 30;
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-color);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  overflow: hidden;
}

/* Mobile: Bottom Sheet */
@media (max-width: 767.98px) {
  .ad-preview-drawer {
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    opacity: 0;
    pointer-events: none;
  }

  .ad-preview-drawer.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }
}

/* Desktop: Side Panel or Floating Card */
@media (min-width: 768px) {
  .ad-preview-drawer {
    top: 20px;
    bottom: 20px;
    right: 20px;
    width: 380px;
    border-radius: 16px;
    transform: translateX(120%);
    opacity: 0;
    pointer-events: none;
  }

  .ad-preview-drawer.is-open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }
}

.ad-preview-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
}

.ad-preview-drawer__title {
  font-size: 1rem;
  font-weight: 500;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ad-preview-drawer__close {
  background: transparent;
  border: none;
  color: var(--text-secondary, #aaaaaa);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s ease;
}

.ad-preview-drawer__close:hover {
  color: #ffffff;
}

.ad-preview-drawer__body {
  padding: 16px;
  overflow-y: auto;
  max-height: calc(100% - 60px);
}

.ad-preview-media {
  width: 100%;
  max-height: 260px;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-preview-media video,
.ad-preview-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  max-height: 260px;
}

.ad-preview-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ad-preview-price-tag {
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--accent-color);
  text-align: center;
}

.ad-preview-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.ad-preview-description {
  padding-top: 4px;
  line-height: 1.45;
}

.ad-preview-description__label {
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-bottom: 3px;
}

.ad-preview-description__text {
  font-size: 0.88rem;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.ad-preview-noimage {
  width: 100%;
  min-height: 180px;
  padding: 24px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
  line-height: 1.45;
}

.ad-preview-actions {
  width: 100%;
  margin-top: 4px;
}

.ad-preview-actions .ad-btn {
  min-height: 40px;
}

.ad-preview-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 6px 18px;
  margin-top: 14px;
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 500;
  border-radius: 30px;
  text-decoration: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.ad-preview-action-btn:hover {
  color: #ffffff;
  opacity: 0.92;
  transform: translateY(-1px);
}

@media (max-width: 767.98px) {
  body.map-page .main-content.map-main {
    height: calc(100svh - 64px);
    min-height: calc(100svh - 64px);
  }

  body.map-page .top-categories-bar {
    padding: 9px 12px !important;
  }

  .maplibregl-ctrl-top-right {
    top: 10px !important;
    right: 10px !important;
  }

  .search-in-area-btn {
    top: 10px;
    max-width: calc(100% - 96px);
    padding: 9px 14px;
    font-size: 0.82rem;
    white-space: nowrap;
  }
}
