/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "Segoe UI", Tahoma, "Arial", system-ui, sans-serif;
  font-size: 15px;
  color: #1a2332;
  background: #f0f3f7;
  direction: rtl;
}

/* ── Layout: 50/50 vertical split ─────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: 400px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ── Left panel ───────────────────────────────────────────── */
.panel {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-left: 1px solid #d4dbe6;
  overflow: hidden;
  z-index: 10;
  box-shadow: -2px 0 12px rgba(0,0,0,0.06);
}

.panel-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid #e8edf3;
  background: #f7f9fc;
  flex-shrink: 0;
}

.panel-title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 700;
  color: #0f1f35;
  line-height: 1.3;
}

.panel-subtitle {
  margin: 0;
  font-size: 12.5px;
  color: #5a6a7e;
  line-height: 1.5;
}

/* ── Source selector ──────────────────────────────────────── */
.source-selector {
  padding: 14px 20px 12px;
  border-bottom: 1px solid #e8edf3;
  flex-shrink: 0;
  background: #fff;
}

.source-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: #7a8a9e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.source-select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #c8d3df;
  border-radius: 7px;
  background: #f7f9fc;
  font-size: 14px;
  font-family: inherit;
  color: #1a2332;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235a6a7e' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 32px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  direction: rtl;
}

.source-select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.source-note {
  margin-top: 7px;
  font-size: 11.5px;
  color: #8a9ab0;
  line-height: 1.45;
}

/* ── Types list ───────────────────────────────────────────── */
.types-area {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  scroll-behavior: smooth;
}

.types-area::-webkit-scrollbar { width: 5px; }
.types-area::-webkit-scrollbar-track { background: transparent; }
.types-area::-webkit-scrollbar-thumb { background: #d0d8e4; border-radius: 99px; }

.types-heading {
  font-size: 11px;
  font-weight: 700;
  color: #9aaabb;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 10px 0;
}

.type-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 13px;
  margin-bottom: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  text-align: right;
}

.type-card:hover {
  border-color: #94b4d6;
  background: #f4f8fd;
  box-shadow: 0 2px 8px rgba(59,130,246,0.08);
}

.type-card.active {
  border-color: #3b82f6;
  background: #eff6ff;
  box-shadow: 0 2px 10px rgba(59,130,246,0.14);
}

.type-card-body {
  flex: 1;
  min-width: 0;
}

.type-card-label {
  font-size: 14px;
  font-weight: 600;
  color: #1a2332;
  margin-bottom: 3px;
  line-height: 1.3;
}

.type-card.active .type-card-label {
  color: #1d4ed8;
}

.type-card-desc {
  font-size: 12px;
  color: #6a7e96;
  line-height: 1.5;
}

.kind-badge {
  flex-shrink: 0;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 1px;
}

.kind-badge.spatial {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.kind-badge.report {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #93c5fd;
}

/* ── Empty / placeholder states ───────────────────────────── */
.empty-state {
  padding: 24px 16px;
  text-align: center;
  color: #8a9ab0;
  font-size: 13px;
  line-height: 1.6;
}

.empty-state-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* ── Right pane ───────────────────────────────────────────── */
.right-pane {
  position: relative;
  overflow: hidden;
  background: #e8ecf1;
}

/* Map */
#map {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

/* Report viewer */
#report-pane {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  background: #f0f3f7;
  padding: 28px 32px;
  display: none;
}

#report-pane::-webkit-scrollbar { width: 6px; }
#report-pane::-webkit-scrollbar-track { background: transparent; }
#report-pane::-webkit-scrollbar-thumb { background: #c8d3df; border-radius: 99px; }

.report-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f1f35;
  margin: 0 0 4px;
}

.report-subtitle {
  font-size: 13px;
  color: #6a7e96;
  margin: 0 0 22px;
}

/* Table for arrays */
.report-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13.5px;
}

.report-table th {
  background: #f1f5f9;
  padding: 10px 14px;
  text-align: right;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

.report-table td {
  padding: 9px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #374151;
  vertical-align: top;
}

.report-table tr:last-child td { border-bottom: none; }

.report-table tr:hover td { background: #f8fafc; }

/* KV cards for single objects */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.kv-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  padding: 14px 16px;
}

.kv-key {
  font-size: 11.5px;
  font-weight: 600;
  color: #7a8a9e;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 5px;
}

.kv-value {
  font-size: 15px;
  font-weight: 600;
  color: #1a2332;
}

/* Loading / error / missing states */
.pane-message {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px;
  background: #f0f3f7;
  color: #6a7e96;
  font-size: 14px;
  line-height: 1.7;
  gap: 10px;
}

.pane-message-icon {
  font-size: 36px;
  opacity: 0.4;
}

.pane-message-title {
  font-size: 16px;
  font-weight: 600;
  color: #4a5a6e;
}

/* Welcome state */
.welcome-pane {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  background: #f0f3f7;
  text-align: center;
  color: #8a9ab0;
}

.welcome-pane-icon {
  font-size: 48px;
  opacity: 0.3;
}

.welcome-pane-title {
  font-size: 17px;
  font-weight: 600;
  color: #5a6a7e;
  margin: 0;
}

.welcome-pane-hint {
  font-size: 13px;
  margin: 0;
  line-height: 1.6;
}

/* ── Responsive: narrow screens ───────────────────────────── */
@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100vh;
  }

  .panel {
    border-left: none;
    border-bottom: 1px solid #d4dbe6;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    max-height: 50vh;
    overflow-y: auto;
  }

  .right-pane {
    height: 55vh;
    position: relative;
  }

  #map, #report-pane {
    position: absolute;
    inset: 0;
  }
}

/* ── Leaflet popup overrides ──────────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 9px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15) !important;
  font-family: "Segoe UI", Tahoma, system-ui, sans-serif !important;
}

.leaflet-popup-content {
  margin: 12px 14px !important;
  min-width: 180px;
}

.popup-props-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 12.5px;
  direction: rtl;
}

.popup-props-table tr:not(:last-child) td {
  border-bottom: 1px solid #f1f5f9;
}

.popup-props-table td {
  padding: 4px 6px;
  vertical-align: top;
  color: #374151;
}

.popup-props-table td:first-child {
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  padding-left: 14px;
}
