/* Distribution Network GIS Analyzer - Consulting Grade UI (Matching Reference Design) */
:root {
  --primary: #1e293b;
  --primary-blue: #2563eb;
  --overlap-red: #dc2626;
  --overlap-bg: #fef2f2;
  --overlap-border: #fee2e2;
  --review-orange: #d97706;
  --review-bg: #fffbeb;
  --review-border: #fef3c7;
  --justified-green: #059669;
  --justified-bg: #f0fdf4;
  --justified-border: #dcfce7;
  --direct-dot: #1e293b;
  --bg-main: #f8fafc;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --header-height: 54px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text-main);
  background-color: var(--bg-main);
  overflow: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: #0f172a;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid #1e293b;
  z-index: 1000;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #ffffff;
}

/* Header Region Selector */
.header-region-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 4px 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.header-region-selector:hover,
.header-region-selector:focus-within {
  background: rgba(255, 255, 255, 0.12);
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.header-region-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

.header-region-label svg {
  color: #60a5fa;
  flex-shrink: 0;
}

.region-select-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.header-region-dropdown {
  background: #1e293b;
  color: #ffffff;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 5px 28px 5px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  min-width: 150px;
  transition: border-color 0.2s, background-color 0.2s;
}

.header-region-dropdown:hover {
  background: #273549;
  border-color: #64748b;
}

.header-region-dropdown:focus {
  border-color: #3b82f6;
  background: #1e293b;
}

.region-select-wrapper::after {
  content: '';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #94a3b8;
  pointer-events: none;
}

.header-region-dropdown option {
  background: #0f172a;
  color: #ffffff;
  padding: 8px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.btn-primary {
  background: #2563eb;
  color: #ffffff;
}
.btn-primary:hover {
  background: #1d4ed8;
}

.btn-export-img {
  background: #0f766e;
  color: #ffffff;
  box-shadow: 0 1px 4px rgba(15,118,110,0.3);
}
.btn-export-img:hover {
  background: #115e59;
}

.btn-success {
  background: #10b981;
  color: #ffffff;
}
.btn-success:hover {
  background: #059669;
}

.btn-secondary {
  background: #334155;
  color: #f8fafc;
  border: 1px solid #475569;
}
.btn-secondary:hover {
  background: #475569;
}

.btn-outline {
  background: transparent;
  color: #334155;
  border: 1px solid #cbd5e1;
}
.btn-outline:hover {
  background: #f1f5f9;
}

/* Dashboard Capture Area (Sidebar + Map Viewport) */
.dashboard-capture-area {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  background: #ffffff;
  height: calc(100vh - var(--header-height));
  width: 100vw;
}

/* Left Sidebar */
.sidebar {
  width: 370px;
  min-width: 370px;
  background: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 500;
  overflow-y: auto;
  box-shadow: 2px 0 8px rgba(0,0,0,0.03);
}

.sidebar-content {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
}

/* Sidebar Top Section */
.network-tag {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.network-main-title {
  font-size: 23px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
  margin-bottom: 10px;
}

.network-desc {
  font-size: 12.5px;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 22px;
}

.section-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* 3 Interactive KPI Cards matching screenshot */
.kpi-banner-card {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  user-select: none;
}

.kpi-banner-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.kpi-banner-card.active-filter {
  box-shadow: 0 0 0 2px #2563eb !important;
}

.kpi-banner-card.card-overlap {
  background-color: var(--overlap-bg);
  border-color: var(--overlap-border);
}
.kpi-banner-card.card-overlap .kpi-num {
  color: var(--overlap-red);
}
.kpi-banner-card.card-overlap .kpi-pct {
  color: var(--overlap-red);
}

.kpi-banner-card.card-review {
  background-color: var(--review-bg);
  border-color: var(--review-border);
}
.kpi-banner-card.card-review .kpi-num {
  color: var(--review-orange);
}
.kpi-banner-card.card-review .kpi-pct {
  color: var(--review-orange);
}

.kpi-banner-card.card-justified {
  background-color: var(--justified-bg);
  border-color: var(--justified-border);
}
.kpi-banner-card.card-justified .kpi-num {
  color: var(--justified-green);
}
.kpi-banner-card.card-justified .kpi-pct {
  color: var(--justified-green);
}

.kpi-num {
  font-size: 32px;
  font-weight: 800;
  min-width: 48px;
  line-height: 1;
}

.kpi-info {
  flex: 1;
  padding: 0 10px 0 6px;
}

.kpi-title {
  font-size: 13px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 2px;
}

.kpi-sub {
  font-size: 11px;
  color: #64748b;
  line-height: 1.35;
}

.kpi-pct {
  font-size: 13px;
  font-weight: 700;
}

/* Tricolor Progress Bar */
.dist-progress-bar {
  display: flex;
  height: 6px;
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0 6px 0;
  background: #e2e8f0;
}

.dist-bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}

.seg-overlap { background: var(--overlap-red); }
.seg-review { background: var(--review-orange); }
.seg-justified { background: var(--justified-green); }

.bar-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #475569;
  font-weight: 600;
}

.card-click-hint {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 6px;
}

/* Map Layers Checklist */
.layer-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #334155;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: #2563eb;
  cursor: pointer;
}

.chk-icon-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.chk-diamond-sm {
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  display: inline-block;
  border: 1px solid #ffffff;
}

.chk-icon-line {
  font-family: monospace;
  font-weight: bold;
  letter-spacing: -2px;
  color: #475569;
}

.chk-icon-ring {
  font-size: 11px;
}

/* Extra Tools inside Sidebar */
.sidebar-tools-box {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tool-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
}

.tool-input, .tool-select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12px;
  color: #1e293b;
  outline: none;
  background: #ffffff;
}

/* Map Area */
.map-container {
  flex: 1;
  position: relative;
  background: #e5e7eb;
  height: 100%;
  width: 100%;
  min-width: 0;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1;
}

/* Map Legend matching screenshot */
.map-legend {
  position: absolute;
  bottom: 24px;
  right: 24px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  z-index: 500;
  font-size: 11px;
  min-width: 200px;
}

.legend-header {
  font-size: 10.5px;
  font-weight: 800;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: #334155;
  font-size: 11px;
}

.legend-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 7px 0;
}

.symbol-diamond {
  width: 12px;
  height: 12px;
  transform: rotate(45deg);
  border: 1.5px solid #ffffff;
  outline: 1.5px solid #000000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.4);
  display: inline-block;
}

.symbol-dt-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1e293b;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 1px #475569;
  display: inline-block;
}

.symbol-ring-10-sample {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px dashed var(--overlap-red);
  display: inline-block;
}

.symbol-ring-20-sample {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px dashed var(--review-orange);
  display: inline-block;
}

.symbol-ring-justified-sample {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px dashed var(--justified-green);
  display: inline-block;
}

/* Markers & Badges */
.custom-dt-pin-wrapper {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.dt-marker-pin {
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.4));
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.dt-marker-pin:hover {
  transform: scale(1.2);
}

.ldm-diamond-marker {
  width: 15px;
  height: 15px;
  transform: rotate(45deg);
  border: 1.5px solid #ffffff;
  outline: 1.5px solid #000000;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

/* Distance Label Container (Zero default Leaflet styling) */
.dist-label-container {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  width: auto !important;
  height: auto !important;
}

/* Clean Text-Only Distance Label — no background, no box, black outline stroke for prominence */
.dist-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: none;
  border: none;
  box-shadow: none;
  padding: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
  white-space: nowrap;
}

.dist-pill .dist-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* Distance Value Text — colored per category, bold, black outline via text-stroke & shadow */
.dist-pill .dist-val {
  font-size: 11.5px;
  font-weight: 900;
  letter-spacing: 0.2px;
  line-height: 1;
  /* Black outline trick using multiple text-shadows — works cross-browser */
  -webkit-text-stroke: 2.5px #000000;
  paint-order: stroke fill;
}

/* Each category gives its own text fill color on top of the black stroke */
.dist-pill.dist-overlap .dist-dot  { background: #ef4444; }
.dist-pill.dist-overlap .dist-val  {
  color: #ef4444;
  -webkit-text-stroke: 2.5px #000000;
}

.dist-pill.dist-review .dist-dot   { background: #f59e0b; }
.dist-pill.dist-review .dist-val   {
  color: #f59e0b;
  -webkit-text-stroke: 2.5px #000000;
}

.dist-pill.dist-justified .dist-dot { background: #10b981; }
.dist-pill.dist-justified .dist-val  {
  color: #10b981;
  -webkit-text-stroke: 2.5px #000000;
}

/* Floating Inspector Card */
.inspector-card {
  position: absolute;
  top: 16px;
  left: 16px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 14px;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  max-width: 340px;
  width: 340px;
  display: none;
}

.inspector-card.visible {
  display: block;
}

/* Bottom Analytical Drawer */
.bottom-drawer {
  position: absolute;
  bottom: 0;
  left: 370px;
  right: 0;
  background: #ffffff;
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
  z-index: 600;
  display: flex;
  flex-direction: column;
  transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 44px; /* Collapsed */
  overflow: hidden;
}

.bottom-drawer.expanded {
  height: 360px;
}

.drawer-header {
  height: 44px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  cursor: pointer;
  user-select: none;
}

.drawer-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
}

.drawer-tab {
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.drawer-tab.active {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
}

.drawer-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #ffffff;
}

.tab-pane {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.tab-pane.active {
  display: flex;
}

/* Data Tables */
.table-toolbar {
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
}

.table-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: #475569;
  font-weight: 600;
  padding: 8px 12px;
  border-bottom: 2px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: pointer;
  white-space: nowrap;
}

.data-table td {
  padding: 7px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  white-space: nowrap;
}

.data-table tr:hover {
  background: #f8fafc;
  cursor: pointer;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-overlap { background: #fee2e2; color: #dc2626; border: 1px solid #fca5a5; }
.badge-review { background: #ffedd5; color: #ea580c; border: 1px solid #fdba74; }
.badge-justified { background: #d1fae5; color: #059669; border: 1px solid #6ee7b7; }
.badge-direct { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }

/* Upload Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal-box {
  background: #ffffff;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  padding: 14px 18px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: #64748b;
}

.modal-body {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: #2563eb;
  background: #eff6ff;
}

.dropzone-title {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 4px;
}

.dropzone-sub {
  font-size: 11px;
  color: #64748b;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid #3b82f6; }
