/* ============================================================
   wedge-building-v4 / styles.css
   Dark modern theme — Leaflet version
   ============================================================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --header-height: 90px;
  --sidebar-width: 268px;
  --census-panel-width: 300px;
  --sidebar-collapsed-width: 32px;
  --bg-deep:    #141414;
  --bg-panel:   #1e1e1e;
  --bg-section: #272727;
  --bg-input:   #333333;
  --border:     rgba(255, 255, 255, 0.08);
  --accent:     #0078d4;
  --accent-hover: #106ebe;
  --text-primary:   #f0f0f0;
  --text-secondary: #8a8a8a;
  --transition: 0.22s ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-size: 13px;
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: linear-gradient(135deg, #252525 0%, #1a1a1a 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  position: relative;
  z-index: 1000;
}

.app-header h1 {
  font-size: 20px;
  font-weight: 300;
  letter-spacing: 0.03em;
  color: var(--text-primary);
  white-space: nowrap;
}

.header-logo-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.wedge-logo {
  height: 62px;
  width: 62px;
  border-radius: 50%;
  object-fit: cover;
  transition: transform var(--transition), box-shadow var(--transition);
}
.wedge-logo:hover {
  transform: scale(1.07);
  box-shadow: 0 0 14px rgba(255, 255, 255, 0.15);
}

.spatial-logo {
  height: 38px;
  width: auto;
  opacity: 0.85;
  transition: opacity var(--transition), transform var(--transition);
}
.spatial-logo:hover { opacity: 1; transform: scale(1.05); }

/* ── App body ────────────────────────────────────────────── */
.app-body {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* ── Map ─────────────────────────────────────────────────── */
#map {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--bg-deep);
  z-index: 1;
}

/* ── Floating selected-space card ───────────────────────── */
.map-selected-card {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;             /* above Leaflet overlays, below popups */
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(26, 26, 26, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 20px;
  padding: 6px 16px 6px 12px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 3px 14px rgba(0, 0, 0, 0.5);
  pointer-events: none;     /* don't block map interaction */
  white-space: nowrap;
  max-width: calc(100% - 40px);
  transition: opacity 0.2s ease;
}
.map-selected-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.map-selected-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Leaflet overrides ───────────────────────────────────── */
.leaflet-control-zoom {
  border: 1px solid var(--border) !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4) !important;
}
.leaflet-control-zoom a {
  background: var(--bg-panel) !important;
  color: var(--text-primary) !important;
  border-bottom: 1px solid var(--border) !important;
  line-height: 26px !important;
}
.leaflet-control-zoom a:hover {
  background: var(--bg-input) !important;
  color: #fff !important;
}
.leaflet-control-attribution {
  background: rgba(20, 20, 20, 0.75) !important;
  color: #666 !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: #666 !important; }

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  background: #232323 !important;
  color: var(--text-primary) !important;
  border-radius: 10px !important;
  padding: 0 !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.65) !important;
  border: 1px solid rgba(255, 255, 255, 0.07) !important;
}
.leaflet-popup-tip-container { margin-top: -1px; }
.leaflet-popup-tip { background: #232323 !important; }
.leaflet-popup-content {
  margin: 0 !important;
  font-family: 'Segoe UI', system-ui, sans-serif !important;
  font-size: 12px !important;
  line-height: 1.5 !important;
}
.leaflet-popup-close-button {
  color: var(--text-secondary) !important;
  font-size: 18px !important;
  top: 8px !important;
  right: 10px !important;
  padding: 0 !important;
  width: auto !important;
  height: auto !important;
}
.leaflet-popup-close-button:hover { color: var(--text-primary) !important; }

/* Popup inner content */
.popup-inner {
  padding: 14px 16px 14px 16px;
  min-width: 190px;
  max-width: 260px;
}
.popup-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 9px;
  padding-bottom: 7px;
  border-bottom: 1px solid var(--border);
  padding-right: 18px; /* space for close button */
}
.popup-type-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}
.popup-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.15);
}
.popup-type-label {
  color: var(--text-secondary);
  font-size: 11px;
}
.popup-row {
  display: flex;
  gap: 6px;
  margin: 4px 0;
  line-height: 1.45;
}
.popup-key {
  color: var(--text-secondary);
  min-width: 48px;
  flex-shrink: 0;
  font-size: 11px;
}
.popup-val {
  color: var(--text-primary);
  word-break: break-word;
}
.popup-val a {
  color: var(--accent);
  text-decoration: none;
}
.popup-val a:hover { text-decoration: underline; }

.popup-status {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.popup-status.occupied {
  background: rgba(74, 222, 128, 0.18);
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
}
.popup-status.available {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.25);
}

.popup-tenants {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.popup-tenants-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.popup-tenant {
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.popup-tenant:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.popup-tenant-name { color: var(--text-primary); font-weight: 500; font-size: 12px; }
.popup-tenant-company { color: var(--text-secondary); font-size: 11px; }

/* ── Census Info Panel (left slide-out) ─────────────────── */
.census-panel {
  width: var(--census-panel-width);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 5;
}
.census-panel.collapsed { width: var(--sidebar-collapsed-width); }

.census-panel-toggle {
  position: absolute;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  width: var(--sidebar-collapsed-width);
  height: 52px;
  background: var(--bg-section);
  border: none;
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  border-radius: 5px 0 0 5px;
  transition: color var(--transition), background var(--transition), transform var(--transition);
  flex-shrink: 0;
  user-select: none;
}
.census-panel-toggle:hover { color: var(--text-primary); background: var(--bg-input); }

/* When expanded, rotate › → ‹ (collapse indicator) */
.census-panel:not(.collapsed) .census-panel-toggle {
  transform: translateY(-50%) rotate(180deg);
}

.census-panel-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 42px 14px 13px; /* right padding reserves space for toggle */
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
  opacity: 1;
  transition: opacity var(--transition);
  min-width: var(--census-panel-width);
}
.census-panel.collapsed .census-panel-content { opacity: 0; pointer-events: none; }

.census-panel-content::-webkit-scrollbar { width: 4px; }
.census-panel-content::-webkit-scrollbar-track { background: transparent; }
.census-panel-content::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

.census-panel-header {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* ── Census attribute display ────────────────────────────── */
.census-hint {
  color: var(--text-secondary);
  font-size: 11px;
  line-height: 1.6;
  font-style: italic;
}

.census-info-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.census-info-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 11px;
  align-items: baseline;
}
.census-info-row:last-child { border-bottom: none; }

.census-info-key {
  color: var(--text-secondary);
  line-height: 1.4;
}

.census-info-val {
  color: var(--text-primary);
  word-break: break-word;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: relative;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 5;
}
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar-toggle {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: var(--sidebar-collapsed-width);
  height: 52px;
  background: var(--bg-section);
  border: none;
  border-right: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  border-radius: 0 5px 5px 0;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
  user-select: none;
}
.sidebar-toggle:hover { color: var(--text-primary); background: var(--bg-input); }
.sidebar.collapsed .sidebar-toggle { transform: translateY(-50%) rotate(180deg); }

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 13px 14px 42px;
  scrollbar-width: thin;
  scrollbar-color: #444 transparent;
  opacity: 1;
  transition: opacity var(--transition);
}
.sidebar.collapsed .sidebar-content { opacity: 0; pointer-events: none; }

.sidebar-content::-webkit-scrollbar { width: 4px; }
.sidebar-content::-webkit-scrollbar-track { background: transparent; }
.sidebar-content::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }

/* ── Panel sections ──────────────────────────────────────── */
.panel-section {
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.panel-section:last-child { border-bottom: none; margin-bottom: 0; }

.section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.section-subtitle {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin: 10px 0 6px;
  opacity: 0.7;
}

/* ── Two-column panel layout ─────────────────────────────── */
.dual-panel {
  display: grid;
  grid-template-columns: 78px 1fr;
  gap: 10px;
  align-items: start;
}

.col-floors {
  display: flex;
  flex-direction: column;
}

.col-controls {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0; /* prevent grid blowout */
}

/* Sub-sections inside the right column */
.mini-section {
  margin-bottom: 10px;
}
.mini-section:last-of-type { margin-bottom: 8px; }
.mini-section .section-title { margin-bottom: 6px; }

/* ── Floor buttons ───────────────────────────────────────── */
.floor-buttons {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.floor-btn {
  width: 100%;
  padding: 7px 4px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 11px;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.floor-btn:hover { background: #424242; }
.floor-btn.active {
  background: var(--accent);
  border-color: var(--accent-hover);
  box-shadow: 0 2px 10px rgba(0, 120, 212, 0.4);
  font-weight: 600;
}

.zoom-btn {
  width: 100%;
  margin-top: 6px;
  padding: 5px 4px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-secondary);
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  text-align: center;
  white-space: nowrap;
}
.zoom-btn:hover {
  color: var(--text-primary);
  border-color: rgba(255, 255, 255, 0.22);
}

/* ── Toggle switch ───────────────────────────────────────── */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
  cursor: pointer;
  user-select: none;
}
.toggle-row:last-child { margin-bottom: 0; }
.toggle-label { color: var(--text-primary); font-size: 12px; }

.toggle-wrap { position: relative; flex-shrink: 0; }
.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  display: block;
  width: 34px;
  height: 18px;
  background: #484848;
  border-radius: 9px;
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  background: #9a9a9a;
  border-radius: 50%;
  transition: left var(--transition), background var(--transition);
}
.toggle-input:checked + .toggle-slider { background: var(--accent); }
.toggle-input:checked + .toggle-slider::after { left: 19px; background: #fff; }

/* ── Select / text inputs ────────────────────────────────── */
.select-input, .text-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 6px;
  color: var(--text-primary);
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.select-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238a8a8a'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}
.select-input:focus, .text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 120, 212, 0.18);
}
.select-input option { background: var(--bg-input); color: var(--text-primary); }

/* ── Tenant search results ───────────────────────────────── */
.tenant-results {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.tenant-result-item {
  padding: 7px 9px;
  background: var(--bg-section);
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}
.tenant-result-item:hover {
  background: var(--bg-input);
  border-color: var(--accent);
}
.tenant-result-name { color: var(--text-primary); font-size: 12px; font-weight: 500; }
.tenant-result-meta { color: var(--text-secondary); font-size: 11px; margin-top: 1px; }

/* ── Stats panel ─────────────────────────────────────────── */
.info-panel {
  background: var(--bg-section);
  border-radius: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 5px;
  font-size: 12px;
}
.stat-row:last-child { margin-bottom: 0; }
.stat-label { color: var(--text-secondary); }
.stat-value {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Collapsible legend ──────────────────────────────────── */
.legend-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-bottom: 8px;
  user-select: none;
}
.legend-toggle-btn:hover .section-title { color: var(--text-primary); }

.legend-chevron {
  font-size: 9px;
  color: var(--text-secondary);
  transition: transform var(--transition);
  flex-shrink: 0;
}
.legend-chevron.collapsed { transform: rotate(180deg); }

.legend-body {
  overflow: hidden;
  transition: max-height 0.25s ease, opacity 0.2s ease;
  max-height: 600px;
  opacity: 1;
}
.legend-body.collapsed {
  max-height: 0;
  opacity: 0;
}

/* ── Legend ──────────────────────────────────────────────── */
.legend-spaces {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}
.legend-exits {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-primary);
}
.legend-swatch {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
}
.legend-line {
  display: inline-block;
  width: 18px;
  height: 2px;
  border-radius: 1px;
  flex-shrink: 0;
}

/* ── Loading overlay ─────────────────────────────────────── */
.map-loading {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 14, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--text-primary);
  font-size: 14px;
  z-index: 9999;
  transition: opacity 0.4s ease;
}
.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid #2e2e2e;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 680px) {
  .dual-panel {
    grid-template-columns: 1fr;
  }

  .app-body { flex-direction: column; }

  /* Census panel stacks above the map on mobile */
  .census-panel {
    width: 100% !important;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .census-panel.collapsed {
    height: var(--sidebar-collapsed-width);
    width: 100% !important;
  }
  .census-panel-toggle {
    top: 0;
    right: 50%;
    transform: translateX(50%);
    width: 52px;
    height: var(--sidebar-collapsed-width);
    border-left: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 5px 5px;
  }
  .census-panel:not(.collapsed) .census-panel-toggle {
    transform: translateX(50%) rotate(180deg);
  }
  .census-panel-content { padding: 40px 13px 13px 13px; min-width: 0; }

  .sidebar {
    width: 100% !important;
    height: auto;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .sidebar.collapsed {
    height: var(--sidebar-collapsed-width);
    width: 100% !important;
  }

  .sidebar-toggle {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 52px;
    height: var(--sidebar-collapsed-width);
    border-right: none;
    border-bottom: 1px solid var(--border);
    border-radius: 0 0 5px 5px;
  }
  .sidebar.collapsed .sidebar-toggle {
    transform: translateX(-50%) rotate(90deg);
  }

  .sidebar-content { padding: 40px 13px 13px 13px; }
  #map { height: 50vh; }
  .app-header h1 { font-size: 16px; }
}
