.chart-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
/* General Styles */
.hidden {
  display: none !important;
}


h1 {
  color: #007bff; /* Accent color for heading */
  margin-bottom: 30px;
}

/* Wrapper for controls and backtest area */
.main-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 1200px; /* Limit width for better readability */
}

/* Card-like styling for sections */
.card {
  background-color: #2a2a4a; /* Slightly lighter dark background for cards */
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); /* Subtle shadow */
  padding: 20px;
}

/* Period Buttons */
.periods-wrapper {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 20px;
}

.period-button {
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 500;
  background-color: #3a3a5a; /* Darker button background */
  color: #e0e0e0;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.period-button:hover {
  background-color: #4a4a6a;
}

.period-button.active {
  background-color: #007bff; /* Primary accent color */
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.4);
}

/* Controls Wrapper (Settings) */
.controls-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-end; /* Align toggle button to the right */
}

#toggle-controls {
  padding: 10px 15px;
  font-size: 16px;
  background-color: #007bff;
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-bottom: 10px; /* Space between toggle and controls */
}

#toggle-controls:hover {
  background-color: #0056b3;
}

#controls {
  display: flex;
  flex-wrap: wrap; /* Allow fieldsets to wrap */
  gap: 20px;
  padding: 20px;
  border-radius: 10px;
  background-color: #2a2a4a;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  transition: all 0.4s ease-in-out;
  width: 100%; /* Take full width of parent */
  box-sizing: border-box;
}

/* Fieldset and Legend */
fieldset {
  border: 1px solid #444; /* Subtle border for fieldsets */
  border-radius: 8px;
  padding: 15px;
  flex: 1; /* Allow fieldsets to grow */
  min-width: 280px; /* Minimum width for fieldsets */
  box-sizing: border-box;
}

legend {
  font-weight: 600;
  font-size: 17px;
  color: #007bff;
  padding: 0 10px;
  margin-left: -10px; /* Adjust legend position */
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between; /* Space out label and input */
  margin-bottom: 10px;
}

.control-row:last-child {
  margin-bottom: 0;
}

label {
  font-size: 15px;
  color: #c0c0c0;
}

/* Input and Select Styles */
input[type="number"],
select {
  width: 80px; /* Adjust width */
  padding: 8px;
  border: 1px solid #555;
  border-radius: 6px;
  background-color: #3a3a5a;
  color: #e0e0e0;
  font-size: 15px;
  -moz-appearance: textfield; /* Remove spinner for Firefox */
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Custom Checkbox */
input[type="checkbox"] {
  display: none;
}

input[type="checkbox"] + label {
  position: relative;
  padding-left: 35px; /* Space for custom checkbox */
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
}

input[type="checkbox"] + label::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  background-color: #555;
  border: 2px solid #777;
  border-radius: 5px;
  transition: all 0.2s ease;
}

input[type="checkbox"] + label::after {
  content: '\2713';
  position: absolute;
  left: 5px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  color: #ffffff;
  opacity: 0;
  transition: all 0.2s ease;
}

input[type="checkbox"]:checked + label::before {
  background-color: #007bff;
  border-color: #007bff;
}

input[type="checkbox"]:checked + label::after {
  opacity: 1;
}

/* Apply Changes Button */
#apply-settings {
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background-color: #007bff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-top: 20px; /* Space from last control */
  align-self: flex-start; /* Align to left within its container */
}

#apply-settings:hover {
  background-color: #0056b3;
}

/* Chart Container */
#chart-container {
  border: 1px solid #444;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  border-radius: 10px;
  overflow: hidden; /* Ensure no overflow from chart drawing */
}

/* Tooltip */
#tooltip {
  position: absolute;
  background-color: rgba(0, 0, 0, 0.9); /* Darker, more opaque */
  color: #fff;
  padding: 10px 15px;
  border-radius: 6px;
  font-size: 13px;
  pointer-events: none;
  z-index: 1000;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0,0,0,0.4);
  transform: translate(-50%, -100%);
}

#tooltip.hidden {
  display: none;
}

/* Backtest Controls */
#backtest-controls {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

#backtest-controls .card {
  padding: 20px;
}

#backtest-controls fieldset {
  border: 1px solid #444;
  border-radius: 8px;
  padding: 15px;
}

#backtest-controls legend {
  color: #28a745; /* Green accent for backtest */
}

#run-backtest {
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  background-color: #28a745; /* Green accent */
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#run-backtest:hover {
  background-color: #218838;
}

#backtest-results {
  margin-top: 20px;
  padding: 20px;
  background-color: #2a2a4a;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

#backtest-results h2 {
  color: #28a745;
  margin-top: 0;
  margin-bottom: 15px;
}

#backtest-results p {
  margin-bottom: 8px;
  font-size: 15px;
}

#backtest-results p span {
  font-weight: 600;
  color: #007bff; /* Use primary accent for values */
}

.strategy-param-group.hidden {
  display: none;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .main-content-wrapper,
  .controls-wrapper,
  #controls,
  .periods-wrapper,
  #backtest-controls {
    width: 100%;
    padding: 10px;
  }

  #controls fieldset {
    min-width: 100%;
  }

  h1 {
    font-size: 24px;
  }
}