/* ============================================================================
   Mainline Effluent — NZ Farm Dairy Effluent (FDE) Design & Pond Engineering
   Dark GIS Workspace, Sunlight Field Mode, CAD Left Rail & A4 Print Styles
   ============================================================================ */

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: #0b1120;
  color: #e2e8f0;
  overflow: hidden;
  max-width: 100vw;
}
.font-mono { font-family: 'JetBrains Mono', monospace; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 9999px; }
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

.cad-rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  padding: 5px 2px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.ctx-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 600;
  color: inherit;
  transition: background-color 0.12s ease;
}
.ctx-menu-item:hover { background: rgba(16, 185, 129, 0.18); }

/* Node & Pipe Badges */
.map-node-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
  transition: transform 0.15s ease;
}
.selected-node-ring {
  outline: 3px solid #facc15 !important;
  outline-offset: 2px;
  transform: scale(1.15);
  z-index: 1000 !important;
}
.active-parent-ring {
  outline: 2.5px solid #10b981 !important;
  outline-offset: 2px;
}

.pipe-label-marker, .pipe-flow-arrow-marker {
  background: transparent !important;
  border: none !important;
  pointer-events: none !important;
  overflow: visible !important;
}

.pipe-label-pill {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  width: max-content;
  white-space: nowrap;
  transform: translate(-50%, -50%);
  background: rgba(9, 15, 30, 0.90);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(148, 163, 184, 0.4);
  border-radius: 7px;
  padding: 2px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9.5px;
  line-height: 1.25;
  color: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}
.pipe-label-pill.is-selected { border-color: #facc15; }
.pipe-label-pill.is-worst { border-color: #f59e0b; box-shadow: 0 0 0 1.5px rgba(245, 158, 11, 0.35); }
.pipe-flow-arrow-wrap { display: flex; align-items: center; justify-content: center; pointer-events: none; filter: drop-shadow(0 1px 3px rgba(0,0,0,0.85)); }

@keyframes pipeFlowMarch {
  from { stroke-dashoffset: 26; }
  to   { stroke-dashoffset: 0; }
}
@keyframes pipeArrowGlide {
  0%, 100% { transform: translateX(-2.2px) scale(0.96); opacity: 0.78; }
  50%      { transform: translateX(2.4px) scale(1.06); opacity: 1; }
}
.pipe-flow-pulse { pointer-events: none !important; animation: pipeFlowMarch 0.95s linear infinite; }
.pipe-flow-pulse.pipe-flow-slow  { animation-duration: 1.45s; }
.pipe-flow-pulse.pipe-flow-med   { animation-duration: 0.95s; }
.pipe-flow-pulse.pipe-flow-fast  { animation-duration: 0.62s; }
.pipe-flow-pulse.pipe-flow-turbo { animation-duration: 0.40s; }
.pipe-flow-arrow-svg { display: block; will-change: transform, opacity; animation: pipeArrowGlide 1.15s ease-in-out infinite; }
.pipe-flow-arrow-svg.pipe-flow-slow  { animation-duration: 1.65s; }
.pipe-flow-arrow-svg.pipe-flow-med   { animation-duration: 1.15s; }
.pipe-flow-arrow-svg.pipe-flow-fast  { animation-duration: 0.80s; }
.pipe-flow-arrow-svg.pipe-flow-turbo { animation-duration: 0.55s; }
@media (prefers-reduced-motion: reduce) { .pipe-flow-pulse, .pipe-flow-arrow-svg { animation: none !important; } }
@media print { .pipe-flow-pulse { display: none !important; } .pipe-flow-arrow-svg { animation: none !important; opacity: 1 !important; transform: none !important; } }

/* Leaflet Dark Theme & Zoom Controls Clear of CAD Rail */
.leaflet-container { background: #0b1120; }
.leaflet-popup-content-wrapper {
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.65);
}
.leaflet-popup-tip { background: #0f172a; }
.leaflet-bottom.leaflet-left .leaflet-control-zoom {
  margin-bottom: 96px;
  margin-left: 76px;
  border: 1px solid #334155 !important;
  border-radius: 10px !important;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.55) !important;
}
.leaflet-control-zoom a {
  background: #0f172a !important;
  color: #e2e8f0 !important;
  border-bottom-color: #334155 !important;
}
.leaflet-control-zoom a:hover { background: #1e293b !important; color: #34d399 !important; }

/* Responsive Grids */
.auto-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
.auto-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; }

/* Sunlight Field Mode */
body.theme-sunlight { background-color: #f1f5f9; color: #0f172a; }
body.theme-sunlight header,
body.theme-sunlight #sidebarDrawer,
body.theme-sunlight #leftCadRail,
body.theme-sunlight #viewDropdownMenu,
body.theme-sunlight #mapContextMenu,
body.theme-sunlight #fdeLegendWidget,
body.theme-sunlight .leaflet-popup-content-wrapper {
  background-color: rgba(255, 255, 255, 0.96) !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}
body.theme-sunlight .leaflet-popup-tip { background: #ffffff !important; }
body.theme-sunlight nav,
body.theme-sunlight .bg-\[\#0b1120\],
body.theme-sunlight .bg-\[\#0f172a\],
body.theme-sunlight .bg-slate-900 { background-color: #f8fafc !important; border-color: #cbd5e1 !important; }
body.theme-sunlight .bg-\[\#1e293b\],
body.theme-sunlight .bg-\[\#0f172a\]\/95 { background-color: #ffffff !important; border-color: #cbd5e1 !important; }
body.theme-sunlight .bg-slate-800 { background-color: #e2e8f0 !important; color: #0f172a !important; border-color: #cbd5e1 !important; }
body.theme-sunlight .text-white { color: #0f172a !important; }
body.theme-sunlight button.bg-emerald-600,
body.theme-sunlight button.bg-sky-600,
body.theme-sunlight button.bg-amber-600,
body.theme-sunlight button.bg-indigo-600,
body.theme-sunlight button.bg-rose-600,
body.theme-sunlight button.bg-teal-600,
body.theme-sunlight .bg-emerald-600,
body.theme-sunlight .bg-sky-600 { color: #ffffff !important; }
body.theme-sunlight .text-slate-200, body.theme-sunlight .text-slate-300 { color: #1e293b !important; }
body.theme-sunlight .text-slate-400 { color: #475569 !important; }
body.theme-sunlight .text-emerald-300, body.theme-sunlight .text-emerald-200 { color: #047857 !important; }
body.theme-sunlight .text-sky-300, body.theme-sunlight .text-sky-200 { color: #0369a1 !important; }
body.theme-sunlight .text-amber-300, body.theme-sunlight .text-amber-200 { color: #b45309 !important; }
body.theme-sunlight .text-rose-300, body.theme-sunlight .text-rose-400 { color: #be123c !important; }
body.theme-sunlight input, body.theme-sunlight select, body.theme-sunlight textarea {
  background-color: #ffffff !important; color: #0f172a !important; border-color: #94a3b8 !important;
}
body.theme-sunlight .pipe-label-pill { background: rgba(255,255,255,0.94); border-color: #334155; color: #0f172a; }
body.theme-sunlight .pipe-label-pill span { color: #0f172a !important; }

/* A4 Print Styles */
#printReportSheet { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  html, body {
    overflow: visible !important;
    height: auto !important;
    background: #ffffff !important;
    color: #0f172a !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
  #appRoot, #customModal, #toastBanner, #siteQuestionnaireModal, #labImportModal, #mobileFieldDock, #mobileFieldPinSheet, #mainlineHelpModal, #mainlineLicenseModal { display: none !important; }
  #printReportSheet {
    display: block !important;
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 10px;
    line-height: 1.4;
  }
  #printReportSheet .proposal-header {
    display: flex; justify-content: space-between; align-items: flex-start; gap: 14px;
    border-bottom: 2.5px solid #047857; padding-bottom: 10px; margin-bottom: 12px;
  }
  #printReportSheet .proposal-section-title {
    font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
    color: #065f46; border-bottom: 1px solid #cbd5e1; padding-bottom: 3px; margin: 12px 0 6px;
    page-break-after: avoid;
  }
  #printReportSheet .proposal-box {
    background: #f8fafc; border: 1px solid #cbd5e1; border-radius: 6px;
    padding: 7px 9px; margin-bottom: 8px; page-break-inside: avoid;
  }
  #printReportSheet .proposal-map-figure {
    border: 1px solid #cbd5e1; border-radius: 6px; overflow: hidden; margin: 6px 0 10px; page-break-inside: avoid;
  }
  #printReportSheet .proposal-map-img { width: 100%; height: auto; display: block; }
  #printReportSheet .proposal-map-caption {
    background: #f1f5f9; padding: 4px 8px; font-size: 8.5px; color: #334155;
    display: flex; justify-content: space-between; border-top: 1px solid #cbd5e1;
  }
  #printReportSheet table { width: 100%; border-collapse: collapse; margin-bottom: 8px; font-size: 9.2px; }
  #printReportSheet th, #printReportSheet td { border: 1px solid #cbd5e1; padding: 4px 6px; text-align: left; }
  #printReportSheet th { background: #ecfdf5; font-weight: 700; color: #064e3b; }
  #printReportSheet .num { text-align: right; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
  #printReportSheet .totals-row td { background: #f1f5f9; font-weight: 700; }
  #printReportSheet .grand-total-row td { background: #064e3b; color: #ffffff; font-weight: 800; font-size: 10.5px; }
  #printReportSheet .sig-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 14px; page-break-inside: avoid; }
  #printReportSheet .sig-line { border-bottom: 1px solid #475569; height: 26px; margin-bottom: 4px; }
}

/* Draggable Floating Map Boxes */
.map-floating-widget {
  position: absolute;
  user-select: none;
  touch-action: none;
  cursor: grab;
}
.map-floating-widget.is-dragging {
  cursor: grabbing;
  z-index: 980 !important;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.75), 0 0 0 1.5px rgba(52, 211, 153, 0.7) !important;
}
.widget-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: -1px;
  padding: 1px 4px;
  border-radius: 4px;
}
.widget-drag-handle:hover { color: #34d399; background: rgba(52, 211, 153, 0.14); }

/* Solid Opaque Dropdowns & Field Dock in Sunlight Mode */
body.theme-sunlight #headerToolsDropdown,
body.theme-sunlight #viewDropdownMenu,
body.theme-sunlight #mapContextMenu,
body.theme-sunlight #mobileFieldDock,
body.theme-sunlight #mobileFieldPinSheet {
  background-color: #ffffff !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* Rich Quick-Edit Right-Click Context Menu Controls */
.ctx-label { display: block; font-size: 9.5px; color: #94a3b8; margin-bottom: 2px; font-weight: 600; }
.ctx-input { background: #0b1120; border: 1px solid #334155; border-radius: 6px; padding: 3px 6px; font-size: 10.5px; color: #f8fafc; outline: none; }
.ctx-input:focus { border-color: #34d399; }
.ctx-step-btn { padding: 3px 6px; border-radius: 6px; background: #1e293b; border: 1px solid #475569; font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700; flex-shrink: 0; }
.ctx-step-btn:hover { background: #334155; }
.ctx-chip { padding: 4px 6px; border-radius: 6px; background: #1e293b; border: 1px solid #334155; font-size: 10px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-chip:hover { background: #334155; border-color: #64748b; }
.ctx-pill { padding: 3px 4px; border-radius: 6px; background: #1e293b; border: 1px solid #334155; font-family: 'JetBrains Mono', monospace; font-size: 9.5px; font-weight: 700; color: #cbd5e1; text-align: center; }
.ctx-pill:hover { background: #334155; }
.ctx-pill.is-active { background: #059669; border-color: #34d399; color: #ffffff; }
body.theme-sunlight .ctx-chip, body.theme-sunlight .ctx-pill, body.theme-sunlight .ctx-step-btn { background: #f1f5f9 !important; border-color: #cbd5e1 !important; color: #0f172a !important; }
body.theme-sunlight .ctx-pill.is-active { background: #059669 !important; border-color: #059669 !important; color: #ffffff !important; }
body.theme-sunlight .ctx-label { color: #475569 !important; }

/* Simplified Mobile / Tablet Field Dock Clearance (< 1024px) */
@media (max-width: 1023px) {
  #fdeLegendWidget:not(.widget-user-moved) { bottom: 76px !important; left: 72px !important; }
  #sidebarDrawer { padding-bottom: 72px; }
  #leftCadRail { max-height: calc(100% - 86px) !important; }
}

/* LINZ 1m LiDAR Hillshade Relief Overlay */
.linz-hillshade-overlay {
  mix-blend-mode: multiply;
  pointer-events: none;
}
