/* Map-page styles — base.css loaded first */

html, body { overflow: hidden; }

/* ── Map fills viewport ── */
#map { position: absolute; inset: 0; }

/* ── Design tokens ── */
:root {
  --line-2: oklch(0.955 0.005 250);
  --bg-tint: oklch(0.975 0.003 250);
}

/* ── Panel ── */
#panel {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1001;
  width: 15rem;
  max-height: calc(100vh - 1.5rem);
  background: oklch(0.985 0.002 250 / 0.92);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid oklch(1 0 0 / 0.4);
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 8px 32px oklch(0 0 0 / 0.14), 0 1px 0 oklch(1 0 0 / 0.6) inset;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 300ms cubic-bezier(.4,0,.2,1), opacity 300ms;
}

#panel.collapsed { transform: translateX(calc(100% + 0.75rem)); opacity: 0; pointer-events: none; }

/* ── Sheet handle (mobile only) ── */
.sheet-handle {
  display: none;
  width: 40px;
  height: 4px;
  background: #d6dbe4;
  border-radius: 2px;
  margin: 8px auto 0;
  flex-shrink: 0;
}

/* ── Panel header ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.panel-logo {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
  color: var(--foreground);
}
.panel-logo-icon {
  width: 1.5rem;
  height: 1.5rem;
  background: var(--primary);
  border-radius: calc(var(--radius) * 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.panel-logo-text { font-size: 0.875rem; font-weight: 700; letter-spacing: -0.02em; }
.panel-version {
  font-size: 0.56rem;
  font-weight: 400;
  line-height: 1;
  opacity: 0.5;
  letter-spacing: 0;
  margin-left: auto;
  cursor: pointer;
}
.panel-version:hover { opacity: 0.8; }
.panel-version:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: 2px;
}

.panel-title-mobile {
  display: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.01em;
  flex: 1;
  text-align: center;
}
.panel-close-btn {
  display: none;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 8px;
  color: var(--foreground);
  cursor: pointer;
  flex-shrink: 0;
}
.panel-close-btn:hover { background: var(--muted); }

/* ── Panel body ── */
.panel-body {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* ── Stats strip ── */
.stats-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-tint);
  border-radius: 14px;
  margin: 0.875rem 1rem 0;
  padding: 12px 4px;
  flex-shrink: 0;
}
.strip-stat {
  text-align: center;
  padding: 0 6px;
  border-right: 1px solid var(--border);
}
.strip-stat:last-child { border-right: none; }
.strip-stat-value {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.01em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.strip-stat-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-top: 2px;
}

/* ── Separator ── */
.sep { height: 1px; background: var(--border); flex-shrink: 0; }

/* ── Sheet sections ── */
.sheet-section {
  padding: 1rem 1rem 1rem;
}
.sheet-section--last {
  padding-bottom: 1.25rem;
}
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.75rem;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.01em;
  display: block;
  margin-bottom: 0.75rem;
}
/* When section-title is inside section-header, remove its bottom margin */
.section-header .section-title {
  margin-bottom: 0;
}
.section-title--caps {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-foreground);
}
.section-value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}
.section-help {
  margin-bottom: 0.625rem;
  font-size: 0.6rem;
  line-height: 1.35;
  color: var(--muted-foreground);
}
.section-header + .section-help {
  margin-top: -0.5rem;
}

/* ── Range sliders ── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  margin: 0;
  height: 4px;
  border-radius: 999px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--primary);
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.2);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--primary);
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.2);
  cursor: pointer;
}

/* ── Rooms ticks ── */
.freshness-ticks {
  position: relative;
  height: 1em;
  margin-top: 0.125rem;
}
.freshness-ticks > span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--muted-foreground);
  opacity: 0.6;
  white-space: nowrap;
}

.rooms-ticks {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.125rem;
  padding: 0 7px;
}
.rooms-ticks > span {
  font-size: 0.65rem;
  color: var(--muted-foreground);
  opacity: 0.6;
  text-align: center;
}
#rooms-filter { margin: 0; }

/* ── Price fields ── */
.price-vals-row {
  display: flex;
  justify-content: space-between;
  margin-top: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
}

/* ── Duration dual-range ── */
.dual-range {
  position: relative;
  padding: 8px 0;
}
.dual-range-track {
  position: absolute;
  top: 50%;
  left: 0; right: 0;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--border);
  pointer-events: none;
}
.dual-range-fill {
  position: absolute;
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
}
.dual-range input[type="range"] {
  display: block;
  width: 100%;
  height: 4px;
  background: transparent !important;
  pointer-events: none;
  margin: 0;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  position: relative;
}
.dual-range input[type="range"]:last-of-type {
  margin-top: -4px;
}
.dual-range input[type="range"]::-webkit-slider-runnable-track {
  background: transparent;
  height: 4px;
  border: none;
}
.dual-range input[type="range"]::-moz-range-track {
  background: transparent;
  height: 4px;
  border: none;
}
.dual-range input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--primary);
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.2);
  cursor: pointer;
  pointer-events: all;
  margin-top: -6px;
}
.dual-range input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  border: 1.5px solid var(--primary);
  box-shadow: 0 1px 3px oklch(0 0 0 / 0.2);
  cursor: pointer;
  pointer-events: all;
}
.duration-ticks {
  position: relative;
  height: 1em;
  margin-top: 0.125rem;
}
.duration-ticks > span {
  position: absolute;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--muted-foreground);
  opacity: 0.6;
  white-space: nowrap;
}

/* ── Date input ── */
.date-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  margin-top: 0.625rem;
}
.date-icon {
  position: absolute;
  left: 12px;
  color: var(--muted-foreground);
  pointer-events: none;
  z-index: 1;
}
#avail-from-filter {
  width: 100%;
  padding: 11px 12px 11px 36px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.875rem;
  color: var(--foreground);
  background: var(--background);
  box-sizing: border-box;
  cursor: pointer;
  font-family: var(--font-sans);
}
#avail-from-filter:focus {
  outline: none;
  border-color: var(--primary);
}

/* ── Checkbox row (within-month) ── */
.checkbox-row {
  margin-top: 0.5rem;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  color: var(--muted-foreground);
  cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  cursor: pointer;
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

/* ── Toggle (sublet) row ── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem;
  gap: 12px;
}
.toggle-row-text { flex: 1; }
.toggle-row-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--foreground);
}
.toggle-row-sub {
  font-size: 0.72rem;
  color: var(--muted-foreground);
  margin-top: 2px;
}
.switch {
  position: relative;
  width: 2rem;
  height: 1.125rem;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 200ms;
}
.switch input:checked + .switch-track { background: var(--primary); }
.switch-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: calc(1.125rem - 4px);
  height: calc(1.125rem - 4px);
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 2px oklch(0 0 0 / 0.2);
  transition: transform 200ms;
}
.switch input:checked + .switch-track::after {
  transform: translateX(calc(2rem - 1.125rem));
}

/* ── Category cards ── */
.cat-cards-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 0.75rem;
}
.cat-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: oklch(1 0 0 / 0.6);
  cursor: pointer;
  user-select: none;
  transition: border-color 150ms, box-shadow 150ms;
}
.cat-card:hover { background: oklch(1 0 0 / 0.85); }
.cat-card input[type="checkbox"] { display: none; }
.cat-card-icon {
  flex-shrink: 0;
  color: var(--foreground);
}
.cat-card-text { flex: 1; min-width: 0; }
.cat-card-text > span:first-child {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-card-sub {
  display: block;
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cat-card-check {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 1.5px solid var(--border);
  background: #fff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms, border-color 150ms;
}
.cat-card-tick { display: none; }
.cat-card.checked {
  border: 2px solid var(--foreground);
  padding: 9px 11px;
  box-shadow: inset 0 0 0 1px var(--foreground);
}
.cat-card.checked .cat-card-check {
  background: var(--foreground);
  border-color: var(--foreground);
}
.cat-card.checked .cat-card-tick { display: block; color: #fff; }

/* ── Search ── */
.search-row { display: flex; gap: 0.375rem; }
.search-field {
  flex: 1;
  height: 2.125rem;
  padding: 0 0.625rem;
  font-size: 0.78rem;
  font-family: var(--font-sans);
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 150ms, box-shadow 150ms;
  min-width: 0;
}
.search-field:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px oklch(from var(--ring) l c h / 0.15);
}
.search-field::placeholder { color: var(--muted-foreground); }
.search-btn {
  width: 2.125rem;
  height: 2.125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 150ms;
}
.search-btn:hover { opacity: 0.9; }
.search-status {
  font-size: 0.68rem;
  color: var(--muted-foreground);
  min-height: 1rem;
  line-height: 1rem;
  margin-top: 0.375rem;
}

/* ── Legend ── */
.legend { display: flex; flex-direction: column; gap: 0.3rem; }
.legend-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 1rem;
  margin-top: 0.5rem;
}
.legend-item { display: flex; align-items: center; gap: 0.5rem; }
.legend-dot {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid oklch(0 0 0 / 0.1);
}
.legend-text { font-size: 0.72rem; color: var(--muted-foreground); white-space: nowrap; }

/* ── Panel footer (mobile only) ── */
.panel-footer {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0.875rem 1rem 1.125rem;
  border-top: 1px solid var(--border);
  background: var(--background);
  box-shadow: 0 -6px 20px oklch(0 0 0 / 0.04);
  flex-shrink: 0;
}
.reset-btn {
  border: none;
  background: transparent;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
  font-family: var(--font-sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
  padding: 8px 4px;
}
.apply-btn {
  border: none;
  background: var(--foreground);
  color: #fff;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: var(--font-sans);
  padding: 12px 18px;
  border-radius: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 150ms;
}
.apply-btn:hover { opacity: 0.85; }

/* ── Mobile toggle button ── */
#panel-toggle {
  display: none;
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1002;
  width: 2.5rem;
  height: 2.5rem;
  background: oklch(0.985 0.002 250 / 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid oklch(1 0 0 / 0.4);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.1);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
}

/* ── Mobile overrides ── */
@media (max-width: 600px) {
  #panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: calc(var(--radius) * 2) calc(var(--radius) * 2) 0 0;
    max-height: 80vh;
  }
  #panel.collapsed { transform: translateY(100%); opacity: 1; }
  #panel-toggle { display: flex; }

  .sheet-handle { display: block; }
  .panel-title-mobile { display: block; }
  .panel-close-btn { display: flex; }
  .panel-logo, .panel-version { display: none !important; }
  .panel-footer { display: flex; }

  .stats-strip {
    margin: 0.875rem 1.5rem 0;
    padding: 14px 4px;
  }
  .strip-stat-value { font-size: 1.125rem; }

  .sheet-section { padding: 1.25rem 1.5rem; }
  .sheet-section--last { padding-bottom: 1.5rem; }
  .toggle-row { padding: 1.25rem 1.5rem; }

  .section-title { font-size: 1.125rem; }
  .toggle-row-title { font-size: 1rem; }

  .cat-cards-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Leaflet popup ── */
.iw-popup .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: var(--radius);
  box-shadow: 0 4px 6px -1px oklch(0 0 0 / 0.1), 0 2px 4px -2px oklch(0 0 0 / 0.1);
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
}
.iw-popup .leaflet-popup-content {
  margin: 0;
  line-height: inherit;
}
.iw-popup .leaflet-popup-tip-container { display: none; }
.iw-popup a.leaflet-popup-close-button {
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: calc(var(--radius) * 0.5);
  background: var(--muted);
  color: var(--muted-foreground);
  font-size: 16px;
  line-height: 24px;
  text-align: center;
  text-decoration: none;
  padding: 0;
}
.iw-popup a.leaflet-popup-close-button:hover {
  background: var(--secondary);
  color: var(--foreground);
}

/* ── Single listing card ── */
.iw-card {
  width: 280px;
  padding: 16px;
  font-family: var(--font-sans);
}
.iw-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--card-foreground);
  line-height: 1.4;
  margin-bottom: 12px;
  padding-right: 28px;
}
.iw-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}
.iw-table tr + tr td { border-top: 1px solid var(--border); }
.iw-table td {
  padding: 5px 0;
  font-size: 12px;
  line-height: 1.4;
  vertical-align: middle;
}
.iw-table td:first-child {
  color: var(--muted-foreground);
  width: 72px;
  font-weight: 400;
}
.iw-table td:last-child {
  color: var(--card-foreground);
  font-weight: 500;
}
.iw-price-badge {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}
.iw-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: background 150ms, border-color 150ms;
  line-height: 1;
}
.iw-link:hover {
  background: var(--secondary);
  border-color: oklch(from var(--border) calc(l - 0.05) c h);
}

/* ── Cluster listing list ── */
.iw-cluster {
  width: 300px;
  font-family: var(--font-sans);
  max-height: 340px;
  display: flex;
  flex-direction: column;
}
.iw-cluster-header {
  padding: 12px 40px 10px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.iw-cluster-count {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted-foreground);
}
.iw-cluster-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}
.iw-cluster-body::-webkit-scrollbar { width: 4px; }
.iw-cluster-body::-webkit-scrollbar-track { background: transparent; }
.iw-cluster-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
.iw-cluster-row {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
}
.iw-cluster-row:last-child { border-bottom: none; }
.iw-cluster-row-title {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--card-foreground);
  margin-bottom: 3px;
  line-height: 1.35;
}
.iw-cluster-row-meta {
  font-size: 11.5px;
  color: var(--muted-foreground);
  margin-bottom: 6px;
  line-height: 1.4;
}
.iw-cluster-row-meta strong {
  color: var(--foreground);
  font-weight: 600;
}

/* ── Loading & error ── */
#loading {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: oklch(0.985 0.002 250 / 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.625rem 1rem;
  border-radius: calc(var(--radius) * 1.5);
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.1);
  z-index: 1010;
  border: 1px solid var(--border);
}
#loading.visible { display: flex; align-items: center; gap: 0.5rem; }
.spinner {
  width: 0.875rem;
  height: 0.875rem;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

#error-msg {
  display: none;
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: oklch(0.97 0.015 20);
  border: 1px solid oklch(0.85 0.06 20);
  padding: 0.625rem 1rem;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  color: var(--destructive);
  box-shadow: 0 4px 16px oklch(0 0 0 / 0.1);
  z-index: 1010;
  white-space: nowrap;
}
#error-msg.visible { display: block; }
