/* ===================================================================
   Property Wharf - Demographic View (Municipal Census & District Intelligence)
   =================================================================== */

.demographic-view-container {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: calc(100vh - 160px);
}

/* ===================================================================
   SCREEN 1: SELECT PROPERTY & CONFIRMATION
   =================================================================== */
.demo-header-hero {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.demo-header-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: linear-gradient(180deg, var(--accent-blue), var(--accent-teal));
}

.demo-hero-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.demo-hero-desc {
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 760px;
  line-height: 1.5;
  margin: 0;
}

/* Property Selection Grid in Demographic View */
.demo-property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.demo-prop-card {
  background-color: var(--bg-surface);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.demo-prop-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  background-color: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
}

.demo-prop-card.selected {
  border-color: var(--accent-blue);
  background-color: rgba(56, 189, 248, 0.05);
  box-shadow: 0 0 24px rgba(56, 189, 248, 0.25);
}

/* Selection Confirmation Modal */
.demo-confirm-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(6, 13, 23, 0.82);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
  animation: fadeIn 0.2s ease-out;
}

.demo-confirm-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-lg);
  max-width: 540px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 32px rgba(56, 189, 248, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalScale 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.demo-confirm-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(56, 189, 248, 0.06);
}

.demo-confirm-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.demo-confirm-icon-badge {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background-color: var(--accent-blue-subtle);
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.demo-confirm-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.demo-confirm-prop-box {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.confirm-prop-name {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.confirm-prop-addr {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.demo-confirm-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-card);
}

.btn-confirm-analyze {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-display);
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.4);
  transition: all var(--transition-fast);
}

.btn-confirm-analyze:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(56, 189, 248, 0.55);
}

/* ===================================================================
   SCREEN 2: WAITING... SCREEN
   =================================================================== */
.demo-waiting-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  min-height: 520px;
  gap: 24px;
}

.demo-radar-beacon {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.demo-radar-beacon .core-ring-blue {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--accent-blue) 0%, rgba(56, 189, 248, 0.2) 70%);
  border: 2px solid var(--accent-blue);
  box-shadow: 0 0 28px rgba(56, 189, 248, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #060d17;
  z-index: 2;
  animation: pulseBeaconBlue 1.8s infinite ease-in-out;
}

.demo-radar-beacon .pulse-wave-blue-1,
.demo-radar-beacon .pulse-wave-blue-2 {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 80px;
  height: 80px;
  margin-top: -40px;
  margin-left: -40px;
  border-radius: 50%;
  border: 2px solid var(--accent-blue);
  opacity: 0.8;
  animation: radarExpandBlue 2.2s infinite ease-out;
}

.demo-radar-beacon .pulse-wave-blue-2 {
  animation-delay: 1.1s;
}

@keyframes pulseBeaconBlue {
  0%, 100% {
    transform: scale(0.96);
    filter: brightness(1);
  }
  50% {
    transform: scale(1.08);
    filter: brightness(1.25);
  }
}

@keyframes radarExpandBlue {
  0% {
    transform: scale(0.4);
    opacity: 0.9;
  }
  100% {
    transform: scale(2.5);
    opacity: 0;
  }
}

.demo-waiting-hero {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  animation: blinkDots 1.6s infinite;
}

/* ===================================================================
   SCREEN 3: SPLIT-SCREEN DASHBOARD
   =================================================================== */
.demographic-split-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  height: 100%;
}

.split-top-header {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.split-title-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.split-city-heading {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.split-prop-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
}

.split-view-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  min-height: 720px;
  height: calc(100vh - 220px);
}

/* Left Panel: Map with District Circles */
.split-map-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.split-map-viewport {
  width: 100%;
  height: 100%;
  flex: 1;
  background-color: #060d17;
  z-index: 1;
}

.map-control-overlay-top {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.btn-map-control-glass {
  background-color: rgba(10, 22, 38, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
}

.btn-map-control-glass:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.map-legend-overlay-bottom {
  position: absolute;
  bottom: 14px;
  left: 14px;
  z-index: 10;
  background-color: rgba(10, 22, 38, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  box-shadow: var(--shadow-md);
}

.legend-row-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}

.legend-circle-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
}

/* Plain text labels for districts on map - NO background, visible in both dark & light */
.district-map-label-wrapper {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.district-map-plain-text {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: var(--font-display, 'Space Grotesk', sans-serif);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.02em;
}

.district-map-plain-text,
[data-theme="light"] .district-map-plain-text {
  color: #0f172a;
  text-shadow:
    -1.5px -1.5px 0 #ffffff,
     1.5px -1.5px 0 #ffffff,
    -1.5px  1.5px 0 #ffffff,
     1.5px  1.5px 0 #ffffff,
     0 2px 5px rgba(255, 255, 255, 0.95);
}

[data-theme="dark"] .district-map-plain-text {
  color: #ffffff;
  text-shadow:
    -1.5px -1.5px 0 #000,
     1.5px -1.5px 0 #000,
    -1.5px  1.5px 0 #000,
     1.5px  1.5px 0 #000,
     0 2px 5px rgba(0, 0, 0, 0.95);
}

/* Right Panel: Graphical Demographics Visualization */
.split-charts-panel {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

/* Comparison Status Banner / Sticky Bar */
.comparison-status-dock {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(8px);
}

.comparison-status-dock.active {
  border-color: var(--accent-blue);
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.12), var(--bg-card));
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
}

.comparison-dock-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.comparison-dock-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.comparison-status-dock.active .comparison-dock-badge {
  background-color: var(--accent-blue);
  color: #060d17;
  border-color: var(--accent-blue);
}

.comparison-dock-text {
  font-size: 13px;
  color: var(--text-primary);
}

.btn-open-compare {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-display);
  padding: 6px 14px;
  border-radius: var(--radius-xs);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-open-compare:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

/* District Cards List */
.district-cards-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.district-card-item {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}

.district-card-item:hover {
  border-color: var(--border-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.district-card-item.compared {
  border-color: var(--accent-blue);
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.25);
  background-color: rgba(56, 189, 248, 0.04);
}

.district-card-item.compared::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-blue);
}

.district-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.district-card-title-block {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.district-card-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.district-card-coords {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.btn-compare-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 600;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-compare-toggle:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-compare-toggle.active {
  background-color: rgba(56, 189, 248, 0.15);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  font-weight: 700;
}

/* 3 Core KPI Metrics Grid */
.demo-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.demo-metric-box {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.metric-lbl {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.metric-val-main {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-context {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Graphical Ethnic Composition (100% Total) */
.ethnic-breakdown-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.section-subheading {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Multi-Segment Stacked Progress Bar */
.ethnic-stacked-bar-container {
  width: 100%;
  height: 24px;
  background-color: var(--bg-main);
  border-radius: var(--radius-full);
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border-color);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.ethnic-bar-slice {
  height: 100%;
  transition: width 0.4s ease-out;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #060d17;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slice-white {
  background: linear-gradient(180deg, #38bdf8, #0ea5e9);
}

.slice-black {
  background: linear-gradient(180deg, #00e5b0, #059669);
}

.slice-hispanic {
  background: linear-gradient(180deg, #f59e0b, #d97706);
}

.slice-asian {
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
}

.slice-other {
  background: linear-gradient(180deg, #fb7185, #e11d48);
}

/* Legend Grid for Ethnic Demographics */
.ethnic-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
}

.ethnic-legend-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xs);
  padding: 6px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-swatch-line {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.color-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-pct-val {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===================================================================
   SIDE-BY-SIDE TWO DISTRICT COMPARISON MODAL
   =================================================================== */
.demo-compare-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(6, 13, 23, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2500;
  padding: 24px;
  animation: fadeIn 0.2s ease-out;
}

.demo-compare-dialog {
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-blue);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7), 0 0 32px rgba(56, 189, 248, 0.25);
  overflow: hidden;
  animation: modalScale 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.demo-compare-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: rgba(56, 189, 248, 0.06);
}

.demo-compare-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.demo-compare-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Side-by-Side Comparison Grid */
.compare-columns-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.compare-col-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.compare-col-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.compare-col-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

/* Comparison Metric Rows */
.compare-metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background-color: var(--bg-surface);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-color);
  font-size: 13px;
}

.compare-metric-val {
  font-family: var(--font-mono);
  font-weight: 700;
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.delta-badge.positive {
  background-color: rgba(0, 229, 176, 0.15);
  color: var(--accent-teal);
  border: 1px solid rgba(0, 229, 176, 0.3);
}

.delta-badge.negative {
  background-color: rgba(251, 113, 133, 0.15);
  color: var(--accent-coral);
  border: 1px solid rgba(251, 113, 133, 0.3);
}

.delta-badge.neutral {
  background-color: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.demo-compare-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: var(--bg-card);
}

/* Responsive */
@media (max-width: 1024px) {
  .split-view-container {
    grid-template-columns: 1fr;
    height: auto;
  }
  .split-map-panel {
    height: 440px;
  }
  .demo-metrics-grid {
    grid-template-columns: 1fr;
  }
  .compare-columns-grid {
    grid-template-columns: 1fr;
  }
}
