:root {
  --ink: #16202c; --ink-soft: #4b5768; --ink-faint: #8a94a3;
  --line: #e6e9ee; --line-soft: #f0f2f5;
  --surface: #ffffff; --canvas: #f6f7f9;
  --brand: #1c3f57; --brand-dark: #12293a; --brand-tint: #eaf1f5;
  --land: #4a8a6f; --building: #2c4770; --premises: #b8683f;
  --radius: 10px; --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05);
  --shadow-md: 0 4px 14px rgba(16,24,40,.08);
  --gold: #c8922e; --gold-light: #e0ac4a; --gold-dark: #9c7020;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  display: flex; flex-direction: column; background: var(--canvas); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Shared top nav lives in navbar.css (.app-nav) - not styled here. */

/* Direct feedback: "I don't really like the filters" - a plain wall of
   uniform gray boxes read as an admin form, not a premium product. Redesign
   keeps every field visible (still no collapsed "advanced" section - a
   PRIOR round of direct feedback already established that hiding fields
   behind a toggle undersold how detailed filtering can get), but now reads
   as a floating card with four visually distinct zones (Vieta / Īpašums /
   Cena un izmērs / Datums) instead of one undifferentiated row. */
form.filters {
  background: var(--surface); border-radius: var(--radius); margin: 16px 24px 0;
  box-shadow: var(--shadow-md); border: 1px solid var(--line-soft); flex: none; z-index: 2;
}

/* A real grid (not flex-wrap groups sized to their own content) - the flex
   version let a 4-field group like Vieta balloon to 3x a 1-field group's
   width and wrap unevenly across rows depending on viewport width. Fixed
   column tracks keep all four zones a predictable, even width regardless
   of how many fields happen to be inside each one. */
.filters-grid {
  display: grid; grid-template-columns: 1.3fr 1.3fr 1.6fr 1fr; align-items: stretch; padding: 4px 4px 16px;
}

/* Each zone gets its own soft-divided column instead of every field looking
   identical - a small icon+label header names the group (Vieta/Īpašums/...)
   so the eye can jump straight to "where do I set the price" instead of
   scanning a dozen identically-styled boxes to find it. */
.filter-group {
  display: flex; flex-direction: column; gap: 8px; padding: 16px 18px; min-width: 0;
  border-right: 1px solid var(--line-soft);
}
.filter-group:last-of-type { border-right: none; }
.filter-group-label {
  display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700;
  color: var(--gold-dark); text-transform: uppercase; letter-spacing: .05em;
}
.filter-group-label svg { flex: none; opacity: .85; }
.filter-group-fields { display: flex; flex-wrap: wrap; align-items: start; gap: 10px 12px; }
.filter-group-fields .field { flex: 1 1 110px; min-width: 0; }
.filter-group-fields .field select,
.filter-group-fields .field input:not([type="checkbox"]) { width: 100%; }
.filter-group-fields .field-street,
.filter-group-fields .field-kind { flex-basis: 100%; }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.filters-actions {
  grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; gap: 12px;
  padding: 12px 20px 4px; margin-top: 4px; border-top: 1px solid var(--line-soft);
}
.filters label {
  font-size: 10.5px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em;
}
.filters input, .filters select {
  padding: 8px 11px; font-size: 13.5px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--canvas); color: var(--ink); transition: border-color .12s, background .12s, box-shadow .12s;
  min-width: 0;
}
.filters input:focus, .filters select:focus {
  outline: none; border-color: var(--brand); background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-tint);
}
.filters input:hover, .filters select:hover { border-color: #c7cedb; }

/* Paired min/max fields presented as one visual unit (a bordered pill with
   a dash between two plain sub-inputs) instead of two separate labeled
   fields - reads as "one range control", not "two unrelated numbers",
   and is compact enough to keep price/rooms/area/year on one row. */
.field-range .range-inputs {
  display: flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--canvas); padding: 0 10px; transition: border-color .12s, box-shadow .12s;
}
.field-range .range-inputs:hover { border-color: #c7cedb; }
.field-range .range-inputs:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
.field-range .range-inputs input {
  border: none; background: none; padding: 8px 2px; width: 5.5em; text-align: center;
}
.field-range .range-inputs.narrow input { width: 3em; }
.field-range .range-inputs input:focus { outline: none; box-shadow: none; }
.field-range .range-inputs span { color: var(--ink-faint); font-size: 12px; }

.btn-search {
  padding: 10px 28px; background: linear-gradient(135deg, var(--gold-light), var(--gold-dark)); color: #1a1204;
  border: none; border-radius: 20px; box-shadow: 0 3px 10px rgba(200,146,46,.35);
  cursor: pointer; font-size: 13.5px; font-weight: 700; transition: filter .12s, transform .12s, box-shadow .12s; white-space: nowrap;
}
.btn-search:hover { filter: brightness(1.08); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(200,146,46,.45); }

.reset-link {
  font-size: 12.5px; color: var(--ink-faint); text-decoration: none; align-self: center; padding: 9px 4px;
}
.reset-link:hover { color: var(--ink-soft); text-decoration: underline; }

.field-kind { min-width: 0; }
.kind-checks {
  display: flex; gap: 10px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--canvas); padding: 8px 10px; white-space: nowrap;
}
.kind-check { display: flex; align-items: center; gap: 5px; font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.kind-check input { margin: 0; accent-color: var(--brand); cursor: pointer; }

@media (max-width: 900px) {
  .filters-grid { grid-template-columns: 1fr 1fr; }
  .filter-group:nth-child(2n) { border-right: none; }
  .filter-group:nth-last-child(-n+2) { border-bottom: none; }
  .filter-group { border-bottom: 1px solid var(--line-soft); }
}
@media (max-width: 620px) {
  .filters-grid { grid-template-columns: 1fr; }
  .filter-group { border-right: none !important; border-bottom: 1px solid var(--line-soft); }
  .filter-group:last-of-type { border-bottom: none; }
  .filters-actions { justify-content: stretch; }
  .filters-actions .btn-search { flex: 1; }
}

.field-street { position: relative; }
#street-suggestions {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 5; margin-top: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md); max-height: 260px; overflow-y: auto;
}
.street-suggestion {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.street-suggestion:hover { background: var(--canvas); }
.street-suggestion .activity-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.street-suggestion .activity-dot.high { background: #0a7a4e; }
.street-suggestion .activity-dot.medium { background: #c98a1f; }
.street-suggestion .activity-dot.low { background: var(--ink-faint); }
.street-suggestion strong { color: var(--ink); font-weight: 700; }
.street-suggestion .name { color: var(--ink-soft); }
.street-suggestion-empty { padding: 10px 12px; font-size: 12.5px; color: var(--ink-faint); }

.field-date { position: relative; }
.date-presets { display: flex; gap: 4px; margin-top: 4px; }
.date-presets button {
  padding: 3px 8px; font-size: 11px; font-weight: 600; color: var(--brand); background: var(--brand-tint);
  border: none; border-radius: 20px; cursor: pointer; transition: background .12s;
}
.date-presets button:hover { background: #dcebf3; }
.date-presets button.active { background: var(--brand); color: #fff; }

#explore-body { flex: 1; display: flex; min-height: 0; }
#card-list { flex: 1; overflow-y: auto; padding: 18px 24px; }
#card-list-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
#card-list-status { font-size: 13px; color: var(--ink-faint); font-weight: 500; }

.view-toggle { display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; flex: none; }
.view-toggle button {
  padding: 6px 14px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); background: var(--surface);
  border: none; cursor: pointer; font-family: inherit; transition: background .12s, color .12s;
}
.view-toggle button + button { border-left: 1px solid var(--line); }
.view-toggle button:hover { background: var(--canvas); }
.view-toggle button.active { background: var(--brand); color: #fff; }

/* Default (and only, once #results-grid.view-table is set) grid layout for
   the card view - table view below overrides this with display:block. */
#results-grid.view-cards, #results-grid:not(.view-table):not(.view-cards) {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}

/* ---------- Table view ---------- */
#results-grid.view-table { display: block; overflow-x: auto; }
.results-table {
  width: 100%; border-collapse: collapse; font-size: 13px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
}
.results-table th, .results-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.results-table th {
  background: var(--canvas); font-weight: 600; color: var(--ink-faint); font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}
.results-table th.sortable { cursor: pointer; user-select: none; }
.results-table th.sortable:hover { color: var(--ink-soft); }
.results-table th.sort-asc::after { content: ' \25B2'; }
.results-table th.sort-desc::after { content: ' \25BC'; }
.results-table tbody tr.results-row { cursor: pointer; transition: background .12s; }
.results-table tbody tr.results-row:hover { background: var(--canvas); }
.results-table tbody tr.results-row.active { background: var(--brand-tint); }
.results-table tbody tr:last-child td { border-bottom: none; }
.results-table .addr-cell { font-weight: 600; color: var(--ink); }

.results-table tr.results-row-locked td {
  filter: blur(3px); opacity: .55; pointer-events: none; user-select: none;
}
.results-table tr.paywall-teaser-row td { padding: 0; border-bottom: none; }
.results-table tr.paywall-teaser-row .paywall-teaser { margin-top: 0; }

#map-panel {
  width: 400px; flex: none; padding: 18px 20px 18px 0; display: flex; flex-direction: column;
}
#map-panel .map-label {
  font-size: 11px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase;
  letter-spacing: .04em; margin-bottom: 8px;
}
/* #map-wrap and #map itself are styled in map-tools.css, shared with the
   fullscreen toggle. */

.explore-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: box-shadow .15s, transform .15s, border-color .15s;
  border-left: 3px solid transparent;
}
.explore-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.explore-card.active { border-color: var(--brand); border-left-color: var(--brand); background: var(--brand-tint); }
.explore-card.kind-land { border-left-color: var(--land); }
.explore-card.kind-building { border-left-color: var(--building); }
.explore-card.kind-premises { border-left-color: var(--premises); }

/* Used by both the card grid and the table view rows - not scoped to
   .explore-card alone. */
.kind-tag {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 4px; color: #fff;
}
.explore-card .kind-tag { margin-bottom: 8px; }
.kind-tag.land { background: var(--land); }
.kind-tag.building { background: var(--building); }
.kind-tag.premises { background: var(--premises); }
.explore-card .addr { font-size: 14px; font-weight: 600; color: var(--ink); line-height: 1.35; }
.explore-card .subline { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.explore-card-era:empty { display: none; }
.explore-card-era { margin-top: 8px; }
.explore-card .fact-chips { margin-top: 8px; padding: 6px 10px; }
.explore-card .fact-chip { font-size: 11.5px; }

/* Same compact "Par ēku" table-cell pattern used in Search's results table
   (search.css) - duplicated here rather than shared since Explore's table
   view and Search load different stylesheets; kept in sync deliberately. */
.row-building-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-fact { font-size: 11.5px; color: #6b7280; white-space: nowrap; }

.explore-card .stats-block-label {
  font-size: 10.5px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase;
  letter-spacing: .03em; margin-top: 10px;
}
.explore-card .stats-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 4px; }
.explore-card .stats-row .stat-value.rent { color: #0a7a4e; }

.explore-card .meta { color: var(--ink-faint); font-size: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }

#restricted-banner {
  display:none; padding: 10px 24px; background:#fdf6e3; border-bottom:1px solid #f3e3b0; font-size:13px;
  color: #7a5c00; flex: none;
}
#restricted-banner a { color: var(--brand-dark); font-weight: 600; cursor: pointer; }

/* Fake blurred cards signaling "more results exist" without ever shipping
   real hidden rows to a restricted browser (see explore.js's
   renderPlaceholderCard) - blur + reduced opacity + no pointer events reads
   as "locked content", not a broken card. */
.explore-card-locked {
  cursor: default; filter: blur(3px); opacity: .55; pointer-events: none; user-select: none;
}
.explore-card-locked:hover { box-shadow: var(--shadow-sm); transform: none; }
.placeholder-bar {
  display: inline-block; height: .9em; border-radius: 4px; background: var(--line);
  color: transparent !important;
}
.explore-card-locked .stats-row { margin-top: 8px; }

.paywall-teaser {
  grid-column: 1 / -1; text-align: center; padding: 28px 20px; margin-top: -60px;
  background: linear-gradient(180deg, rgba(246,247,249,0) 0%, var(--canvas) 40%);
  position: relative; z-index: 1;
}
.paywall-teaser-count { font-size: 20px; font-weight: 800; color: var(--ink); }
.paywall-teaser-sub { font-size: 13px; color: var(--ink-faint); margin-top: 4px; max-width: 420px; margin-left: auto; margin-right: auto; }
.paywall-teaser-btn {
  margin-top: 14px; padding: 10px 26px; background: var(--brand); color: #fff; border: none;
  border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: background .12s, transform .12s; box-shadow: var(--shadow-md);
}
.paywall-teaser-btn:hover { background: var(--brand-dark); transform: translateY(-1px); }

#load-more-btn {
  grid-column: 1 / -1; justify-self: center; margin: 8px 0 4px;
  padding: 10px 24px; background: var(--surface); color: var(--brand-dark); border: 1px solid var(--line);
  border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 700; cursor: pointer;
  transition: background .12s, border-color .12s;
}
#load-more-btn:hover { background: var(--brand-tint); border-color: var(--brand); }
#load-more-btn:disabled { opacity: .6; cursor: default; }
.view-table #load-more-btn { display: block; width: fit-content; margin-left: auto; margin-right: auto; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-faint); font-size: 14px; }
.trust-footnote { text-align: center; font-size: 11.5px; color: var(--ink-faint); margin-top: 20px; }

.loading-state { grid-column: 1 / -1; display: flex; justify-content: center; padding: 80px 20px; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
