/* Basic reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "Helvetica Neue", Arial, sans-serif;
  background-color: #f3f3f3;
  color: #333;
  line-height: 1.4;
}

/* Header */
header {
  position: relative;
  padding: 20px;
  background: #4a90e2;
  color: white;
  text-align: center;
}
header .subtitle {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-top: 5px;
}

/* Dark Mode Toggle */
.dark-mode-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 0.9rem;
}
.dark-mode-toggle input {
  margin-right: 5px;
}

/* Step navigation bar */
.steps {
  display: flex;
  justify-content: center;
  background: #fafafa;
  padding: 10px 0;
  border-bottom: 1px solid #e0e0e0;
}
.step {
  margin: 0 10px;
  padding: 8px 12px;
  border-radius: 20px;
  background: #eee;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  transition: background 0.25s;
}
.step strong {
  margin-right: 5px;
  background: #ccc;
  display: inline-block;
  width: 20px;
  text-align: center;
  border-radius: 50%;
  font-weight: normal;
}
.step.active {
  background: #4a90e2;
  color: white;
}
.step.active strong {
  background: #2775c9;
  color: white;
}

/* Container layout */
.container {
  display: flex;
  flex-direction: row;
  max-width: 1200px;
  margin: 20px auto;
  gap: 20px;
}

/* Sidebar */
.sidebar {
  flex: 0 0 350px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 15px 15px 50px 15px;
  height: calc(100vh - 120px);
  overflow-y: auto;
}
input[type="file"] {
  width: 100%;
  box-sizing: border-box;
}

/* Main content */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Chart & right column wrapper */
#chartAndRightColWrapper {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: flex-start;
}

/* Chart wrapper and containers */
#chartWrapper {
  position: relative;
  width: 800px;
  height: 500px;
}
#chartContainer,
#chartContainerLambert {
  width: 800px;
  height: 500px;
  border: 1px solid #ccc;
  background: #fff;
}
#chartContainerLambert {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
}

/* Right side panel */
#rightSidePanel {
  width: 220px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
#zoomContainer {
  text-align: center;
}
#zoomView {
  border: 1px solid #ccc;
  background: #fff;
  margin: 10px auto;
  display: block;
}
.right-panel-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 10px;
}
.right-panel-section h3 {
  margin-bottom: 5px;
}
.right-panel-section p {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: #555;
}
.btn-group {
  display: flex;
  gap: 5px;
}
.right-panel-section .btn-group button {
  padding: 2px 4px;
  font-size: 0.7rem;
}
.copydata .btn-group button {
  cursor: pointer;
  border-radius: 4px;
  padding: 10px;
  font-size: 1rem;
}
.control-section button {
  font-size: 1rem; /* Font size for the text */
  padding: 10px 20px; /* Padding to control button size */
  border-radius: 8px; /* Rounded corners for the button */
  border: 1px solid #ccc; /* Border color */
  background-color: #4a90e2; /* Background color */
  color: white; /* Text color */
  cursor: pointer; /* Makes the button clickable */
  transition: background-color 0.3s, transform 0.2s; /* Transition effects */
  display: inline-block; /* Ensure buttons are aligned properly */
  width: 200px; /* Fixed width for all buttons to ensure uniform size */
  text-align: center; /* Center the text inside the button */
  margin-bottom: 10px; /* Space between buttons */
}

/* Data Tables */
.points-table-section {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 15px;
}
.points-table-section h3 {
  margin-bottom: 10px;
}
.table-container {
  margin-bottom: 15px;
}
.table-container h4 {
  margin-bottom: 5px;
  font-size: 1rem;
  color: #333;
}
.points-list {
  width: 100%;
  max-height: 300px;
  overflow-y: auto;
}
.points-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.points-list th,
.points-list td {
  border: 1px solid #ddd;
  padding: 6px 8px;
  text-align: center;
}
.points-list th {
  background: #f2f2f2;
}
.points-list tr:nth-child(even) {
  background: #fafafa;
}

/* Buttons & inputs */
.btn,
.btn-file,
.btn-select {
  cursor: pointer;
  font-size: 0.8rem;
  padding: 6px 6px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #f7f7f7;
  transition: background 0.2s ease;
}
.btn:hover,
.btn-file:hover,
.btn-select:hover {
  background: #e2e2e2;
}
/* Dark Mode Overrides for Buttons */
body.dark-mode .btn:hover,
body.dark-mode .btn-file:hover,
body.dark-mode .btn-select:hover {
  background: black;
}

/* Light Mode Overrides for Buttons (optional, but necessary if dark mode is not active) */
body:not(.dark-mode) .btn:hover,
body:not(.dark-mode) .btn-file:hover,
body:not(.dark-mode) .btn-select:hover {
  background: white;
}
.btn:active,
.btn-file:active,
.btn-select:active {
  background: #ddd;
}
.primary-btn {
  background: #4a90e2;
  color: white;
  border: 1px solid #4a90e2;
}
.primary-btn:hover {
  background: #3f7ec4;
}

/* Control sections */
.control-section {
  margin-bottom: 20px;
}
.control-section h2 {
  margin-bottom: 10px;
  font-size: 1.1rem;
  color: #4a4a4a;
}
.control-section p {
  font-size: 0.9rem;
  margin-bottom: 10px;
  color: #555;
}
.param-group {
  margin-bottom: 10px;
}
.param-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 0.9rem;
}
.param-group input,
.param-group textarea,
.param-group select {
  width: 100%;
  padding: 5px;
  font-size: 0.9rem;
}

/* Lambert W parameter row */
.lw-row {
  display: grid;
  grid-template-columns: 110px 1fr 30px;
  align-items: center;
  gap: 8px;
}

/* Lambert W info note */
.lambertw-info {
  width: 800px;
  margin: 10px auto;
  text-align: left;
  font-size: 0.9rem;
  color: #555;
}

/* Highlight box */
.highlight-box {
  border: 2px dashed #ff9800;
  border-radius: 4px;
  padding: 8px;
  background: #fff8e1;
  margin-bottom: 15px;
}
.highlight-text {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: #444;
}
.highlight-btn {
  background: #ffd740;
  color: #333;
  font-weight: bold;
  border: 1px solid #ffa000;
}
.highlight-btn:hover {
  background: #ffc107;
}
.calibrate-btn {
  margin-top: 10px;
}
.input-error {
  border: 2px solid red !important;
}
.locked {
  background-color: #eee;
  color: #888;
  cursor: not-allowed;
}

/* Main SVG */
#chartContainer svg {
  cursor: crosshair;
}
.boundaryGroup rect {
  stroke: #333 !important;
  stroke-width: 2 !important;
  fill: none !important;
  stroke-dasharray: 4 2;
}
.calibPoint circle.outer {
  opacity: 0.3;
}
.calibPoint circle.inner {
  opacity: 1;
}
.pointsGroup circle.red {
  stroke: #aaa;
  stroke-width: 1px;
  fill: red;
}
.text.redLabel {
  fill: red;
  font-size: 12px;
}
.calibPoint text.calibLabel {
  font-size: 12px;
  font-weight: bold;
  pointer-events: none;
  user-select: none;
}
.calibPoint text.xLabel {
  fill: blue;
}
calibPoint text.yLabel {
  fill: green;
}
@keyframes pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}
.pulse {
  animation: pulse 1s infinite;
}
.interpolation-options {
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.interpolation-options label {
  font-size: 0.9rem;
}
.interpolation-options input[type="number"] {
  width: 80px;
  padding: 5px;
  font-size: 0.9rem;
}
.interpolation-options input[type="checkbox"] {
  transform: scale(1.2);
}
.interpolation-options button {
  padding: 5px 10px;
  font-size: 0.9rem;
}

/* Professional Help Icons (Transparent with Dark Tooltip) */
.help {
  display: inline-block;
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  color: #333;
  background: transparent;
  border: 1px solid #333;
  border-radius: 50%;
  margin-right: 6px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s ease;
}
.help:hover {
  background: rgba(0, 0, 0, 0.1);
}
.help::after {
  content: attr(data-help);
  position: absolute;
  left: 110%;
  top: 50%;
  transform: translate(8px, -50%);
  white-space: pre-wrap;
  background: #333;
  color: #fff;
  padding: 8px;
  border: 1px solid #222;
  border-radius: 4px;
  width: 220px;
  box-shadow: 0px 2px 6px rgba(0,0,0,0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 100;
}
.help:hover::after {
  opacity: 1;
  visibility: visible;
}

/* New Lambert W Zoom Preview Styles */
#lambertZoomWrapper {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 200px;
  height: 200px;
  border: 1px solid #ccc;
  background: #fff;
  display: none; /* Only visible in Lambert W mode */
  z-index: 1000;
}
#lambertZoomView {
  width: 200px;
  height: 200px;
  border: 1px solid #ccc;
  background: #fff;
}

/* Dark Mode Overrides */
body.dark-mode {
  background-color: #121212;
  color: #ccc;
}
body.dark-mode header {
  background: #222;
  color: #ccc;
}
body.dark-mode .steps {
  background: #222;
  border-bottom: 1px solid #333;
}
body.dark-mode .step {
  background: #222;
  color: #ccc;
}
body.dark-mode .step.active {
  background: #333;
  color: #fff;
}
body.dark-mode .sidebar {
  background: #1a1a1a;
  border-color: #333;
  color: #ccc;
  padding: 15px 15px 50px 15px;
  overflow-y: auto;
  height: calc(100vh - 120px);
}
body.dark-mode .main-content {
  background: #121212;
  color: #ccc;
}
body.dark-mode .right-panel-section {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
}
body.dark-mode .control-section {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
}
body.dark-mode .points-table-section {
  background: #1a1a1a;
  border-color: #333;
  color: #ccc;
}
body.dark-mode .table-container {
  background: #1a1a1a;
  border: 1px solid #333;
  color: #ccc;
}
body.dark-mode input,
body.dark-mode select,
body.dark-mode button {
  background: #222;
  color: #ccc;
  border-color: #444;
}
body.dark-mode button,
body.dark-mode .btn {
  border: 1px solid #4a90e2 !important;
}
body.dark-mode table,
body.dark-mode th,
body.dark-mode td {
  background: #1a1a1a;
  color: #ccc;
  border-color: #333;
}
body.dark-mode #chartContainer,
body.dark-mode #chartContainerLambert {
  background: #000;
}
.dark-mode-toggle {
  position: absolute;
  top: 20px;
  right: 20px;
  font-size: 0.9rem;
}

/* Dark Mode Overrides for Highlight Box and Zoom View */
body.dark-mode .highlight-box {
  background: #333;
  border: 2px dashed #555;
}
body.dark-mode #zoomView {
  background: #000;
  border: 1px solid #333;
}

/* Overlay styles */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
}
.overlay-content {
  background: #fff;
  padding: 20px;
  border-radius: 8px;
  text-align: center;
}
.hidden {
  display: none;
}

/* Dark mode for Manual IV Data textarea */
body.dark-mode textarea#manualDataInput {
  background-color: #333;
  color: #ccc;
  border: 1px solid #444;
}

/* Ensure section headings remain white in dark mode */
body.dark-mode .control-section h2 {
  color: #fff !important;
}

/* Loading cursor state */
body.loading {
  cursor: wait;
}
#debugRange,
#debugContainer,
#debugContainer2 {
  display: none !important;
}
