/* Layout for the land-purchases report. Mobile-first — base styles for ~320-360px; tablet and
   desktop enhancements via min-width media queries. */

/* --- Summary --- */
#summary {
  padding: .75rem 1rem;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.25rem;
}
.stat { display: flex; flex-direction: column; min-width: 45%; }
.stat-label {
  font-size: .7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.stat-value {
  font-size: 1.05rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
/* --- Map --- */
#map-section {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
#map { width: 100%; height: 300px; }

.map-stats {
  padding: .4rem 1rem;
  font-size: .75rem;
  color: var(--muted);
  background: #fafafa;
}

.monitor-coverage {
  padding: .5rem 1rem;
  font-size: .8rem;
  background: #eef5ff;
  border-bottom: 1px solid var(--border);
  display: none;
  line-height: 1.4;
}
.monitor-coverage.active { display: block; }
.monitor-coverage strong { color: #1e3a8a; }
.overlay-legend { display: inline-flex; align-items: center; gap: .35rem; margin-left: .75rem; font-size: .75rem; color: var(--muted); }
.overlay-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.overlay-legend-dot.city        { background: #2c6bed; }
.overlay-legend-dot.government  { background: #0891b2; }
.overlay-legend-dot.institution { background: #7c3aed; }
.overlay-legend-dot.company     { background: #d97706; }
.overlay-legend-dot.private     { background: #d64545; }
.overlay-legend-dot.unknown     { background: #9ca3af; }
.overlay-legend-dot.other       { background: #d64545; } /* legacy alias */

.map-popup dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: .15rem .5rem;
  margin: .25rem 0 0;
  font-size: .8rem;
}
.map-popup dt { color: var(--muted); }
.map-popup dd { margin: 0; }
.map-popup .opis { font-size: .8rem; margin: .35rem 0; word-break: break-word; }
.map-popup .approx-note { font-size: .75rem; color: var(--muted); }
.map-popup abbr { text-decoration: none; font-weight: bold; color: #a16207; }

/* --- Filter controls (stacked on mobile, row on tablet+) --- */
.table-controls {
  padding: .5rem .75rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  align-items: stretch;
  border-bottom: 1px solid var(--border);
  background: #f8f8f8;
}
.table-controls label {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  font-size: .75rem;
  color: var(--muted);
}
.table-controls input[type="search"],
.table-controls select {
  padding: .5rem .55rem;
  font-size: .95rem;
  min-height: 38px;           /* touch target */
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.table-controls button {
  padding: .45rem .8rem;
  min-height: 38px;
  cursor: pointer;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  font-size: .9rem;
}
#filter-count {
  font-size: .8rem;
  color: var(--muted);
  padding-top: .1rem;
}

.taxonomy-stats {
  padding: .35rem 1rem;
  font-size: .75rem;
  color: var(--muted);
  background: #fafafa;
  border-bottom: 1px solid var(--border);
}

/* --- Table --- */
/* #table-section holds filters + table. The inner .table-scroll is the bounded, scrollable
   viewport for the table itself — lets the user browse rows without the map leaving view. */
#table-section { padding: 0; }
.table-scroll {
  overflow: auto;
  max-height: 60vh;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--border);
}
#purchases-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  background: #fff;
  table-layout: auto;
}
#purchases-table th, #purchases-table td {
  padding: .45rem .6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
#purchases-table th {
  font-weight: 600;
  font-size: .75rem;
  color: var(--muted);
  background: #f3f3f3;
  position: sticky;
  top: 0;
  white-space: nowrap;
}
#purchases-table th[data-sort] {
  cursor: pointer;
  user-select: none;
}
#purchases-table th[data-sort]:hover { color: var(--accent); }
#purchases-table th .sort-arrow { margin-left: .25rem; opacity: .5; }
#purchases-table th.sorted .sort-arrow { opacity: 1; color: var(--accent); }
#purchases-table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
#purchases-table .date { white-space: nowrap; font-variant-numeric: tabular-nums; }
#purchases-table .konto { font-size: .75rem; color: var(--muted); white-space: nowrap; text-align: center; }
#purchases-table .konto abbr { text-decoration: none; cursor: help; border-bottom: 1px dotted var(--muted); }
#purchases-table .zkc-cell { font-size: .8rem; font-variant-numeric: tabular-nums; min-width: 5rem; }
#purchases-table .opis-project { font-size: .85rem; min-width: 7rem; }
#purchases-table .opis-actions { font-size: .85rem; min-width: 6rem; }
.zkc-num { display: block; white-space: nowrap; }
.zkc-num.approx { color: var(--warn); }
.zkc-num.approx::before { content: '≈ '; }
.no-hit { color: var(--muted); font-size: .75rem; }
.no-actions { color: var(--muted); font-size: .75rem; }
#purchases-table tbody tr:hover { background: #f6f8ff; }
#purchases-table .empty { text-align: center; color: var(--muted); padding: 1rem; }

.action-tag {
  display: inline-block;
  font-size: .68rem;
  padding: .05rem .35rem;
  border-radius: 3px;
  background: #e0eaff;
  color: #1e3a8a;
  white-space: nowrap;
}
.opis-actions .action-tag { display: block; margin-bottom: .15rem; }
.project-tag { display: inline-block; font-size: .78rem; padding: .1rem .4rem; border-radius: 4px; background: #e8f5e9; color: #1b5e20; cursor: pointer; }
.project-tag:hover { background: #c8e6c9; }
.project-tag.unmapped { background: #f3f4f6; color: #6b7280; font-style: italic; cursor: default; }

#purchases-table tbody tr { cursor: pointer; }

/* Ephemeral toast for actions that have no target (e.g. clicking a row with no known parcel). */
.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: #1e293b;
  color: #fff;
  padding: .55rem 1rem;
  border-radius: 6px;
  font-size: .85rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 10000;
  max-width: calc(100% - 2rem);
}
.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* === Tablet (≥640px) === */
@media (min-width: 640px) {
  #summary { padding: 1rem; }
  .stat { min-width: 0; }
  .stat-value { font-size: 1.3rem; }
  .by-konto { font-size: .85rem; }

  #map { height: 380px; }

  .map-stats { font-size: .8rem; }
  .monitor-coverage { font-size: .85rem; }

  .table-controls {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1rem;
  }
  .table-controls label {
    flex-direction: row;
    align-items: center;
    gap: .4rem;
    font-size: .85rem;
    color: var(--fg);
  }
  .table-controls input[type="search"] { min-width: 14rem; }
  #filter-count { margin-left: auto; }

  #purchases-table { font-size: .9rem; min-width: 0; }
  #purchases-table th, #purchases-table td { padding: .55rem .7rem; }
  #purchases-table th { font-size: .85rem; }
  #table-section { padding: 0 .25rem; }
}

/* === Desktop (≥1024px) === */
@media (min-width: 1024px) {
  #map { height: 440px; }
}
