/* Main Body Styling */
#main-body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #f4f4f4;
  color: #333;
  overflow: hidden;
}

#main-content {
  height: 100%;
  width: 80%;
  margin-left: 5%;
  margin-right: 5%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#main-content::after {
  content: '';
  flex-shrink: 0;
  height: 20px;
}

/* Title Bar Styling */
#title-bar {
  width: 98%;
  position: relative;
  display: flex;
  align-self: center;
  margin: 0 auto;
  left: 0;
  background-color: #034e7b;
  color: #ffffff;
  padding: 15px 20px;
  text-align: left; /* Align title to the left */
}

#title-bar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: bold;
}

/* Main Layout */
#main-layout {
  display: flex;
  height: calc(100vh - 50px); /* Full height minus title bar */
  margin: 0;
  padding: 0;
}

/* Sidebar */
#sidebar {
  width: 20%;
  position: relative;
  background-color: #f4f4f4;
  padding: 20px;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto; /* Add scrolling for long content */
}

/* Chart Container */
#chart-container {
  position: relative; /* Reference point for child elements like #loading-spinner */
  flex: 1; /* Expand to fill remaining space */
  /* display: flex; */
  justify-content: center;
  align-items: center;
  margin: 0;
  padding: 0;
  width: 100%; /* Full width */
  height: 100%; /* Full height of container */
  background-color: #f4f4f4; /* Match the background color with the canvas */
}

/* Loading Spinner */
#loading-spinner {
  position: absolute; /* Position absolute to remove from document flow */
  top: 50%; /* Center vertically */
  left: 50%; /* Center horizontally */
  transform: translate(-50%, -50%); /* Adjust alignment for exact centering */
  z-index: 1000; /* Ensure it is above the canvas */
  flex-direction: column; /* Stack spinner and text vertically */
  align-items: center; /* Center horizontally */
  justify-content: center; /* Center vertically */
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 16px;
  color: #555; /* Neutral gray for text */
  background-color: rgba(255, 255, 255, 0.3); /* Increased transparency for modern look */
  padding: 20px 30px;
  border-radius: 16px; /* Smooth, more rounded corners */
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1); /* More prominent shadow for depth */
  width: 280px; /* Increased width for warning text */
  min-height: 130px; /* Minimum height for consistent alignment */
  max-width: 90vw; /* Responsive max width */
  min-width: 300px; /* Responsive max width */
  max-height: 80vh; /* Responsive max height */
}

#loading-spinner:not(.hidden) {
  display: flex; /* Enable flexbox for alignment when visible */
}

.spinner {
  position: absolute;
  left: 43%;
  transform: translateX(-50%);
  width: 40px; /* Adjust spinner size */
  height: 40px; /* Adjust spinner size */
  border: 4px solid rgba(0, 0, 0, 0.1); /* Subtle gray border */
  border-top: 4px solid #3690c0; /* Accent color for the spinner */
  border-radius: 50%; /* Circle shape */
  animation: spin 1s linear infinite; /* Smooth rotation */
}

#loading-spinner p {
  margin-top: 65px; /* Space between spinner and text */
  color: #333; /* Darker text for readability */
  font-size: 14px; /* Balanced font size */
  font-weight: 500; /* Slightly bold for emphasis */
  line-height: 1.4; /* Better line spacing for multi-line content */
  max-width: 100%; /* Ensure text doesn't overflow */
}

/* Keyframes for Spinner Animation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Canvas */
#chart-canvas {
  width: 100%; /* Full width of the container */
  height: 100%; /* Full height of the container */
  display: block;
  background-color: #f4f4f4; /* Match the background color of the chart container */
  border: none; /* Remove any borders */
}

/* Toolbar and Controls */
#toolbar {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.file-upload-row {
  display: flex;
  flex-direction: column; /* Stack label, input, and file name */
  gap: 5px; /* Space between elements */
  margin-bottom: 10px; /* Reduced space between rows */
  margin-top: 2px;
}

.button-group {
  display: flex;
  gap: 10px;
  margin-top: 15px;
  margin-bottom: 5px;
}

/* Buttons */
.control-button {
  font-size: 13px;
  padding: 6px 10px;
  color: #333;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
}

.control-button:hover {
  background-color: #d0d0d0;
}

#datafly-button:hover {
  background-color: #e0f7fa;
}

/* On/Off toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 64px;
  height: 24px;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.toggle-option {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  color: #888;
  z-index: 1;
  line-height: 24px;
}

.toggle-switch.active .toggle-on {
  color: #333;
}

.toggle-switch:not(.active) .toggle-off {
  color: #333;
}

.toggle-slider {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 50%;
  height: calc(100% - 2px);
  background-color: #fff;
  border-radius: 3px;
  transition: left 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.toggle-switch:not(.active) .toggle-slider {
  left: calc(50% - 1px);
}

/* Three-state toggle switch */
.toggle-switch-3 {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 120px;
  height: 24px;
  background-color: #e0e0e0;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  user-select: none;
}

.toggle-option-3 {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  color: #888;
  z-index: 1;
  line-height: 24px;
}

.toggle-switch-3 .toggle-option-3.selected {
  color: #333;
}

.toggle-slider-3 {
  position: absolute;
  top: 1px;
  width: calc(100% / 2);
  height: calc(100% - 2px);
  background-color: #fff;
  border-radius: 3px;
  transition: left 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.toggle-switch-3[data-state="on"] .toggle-slider-3 {
  left: 1px;
}


.toggle-switch-3[data-state="off"] .toggle-slider-3 {
  left: calc(100% / 2 - 1px);
}



/* Styling for the DATA section header */
#toolbar h2 {
  font-size: 15px; 
  font-weight: bold;
  color: #333;
  text-transform: uppercase;
  margin-top: 0px; 
  margin-bottom: 0px; 
}

/* Styling for the file section divider */
.file-section-divider {
  border: 0;
  border-top: 1px solid #e0e0e0;  /* Light grey line */
  margin: 0 0; /* Reduced margins for closer alignment */
}

/* Sliders with Same-Line Labels */
.slider-group {
  display: flex;
  align-items: center;
  gap: 8px; /* Reduced gap between label and slider */
  justify-content: space-between;
}

.slider-group label {
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  color: #034e7b; /* Dark navy blue for slider labels */
}

/* Specific styling for projection sliders to ensure consistent width */
.projection-slider {
  justify-content: flex-start; /* Override space-between for projections */
}

.projection-slider label {
  flex: 0 0 auto; /* Don't grow or shrink */
  min-width: 85px; /* Ensure consistent label width */
}

.projection-slider input[type="range"] {
  flex: 0 0 120px; /* Fixed width for consistency */
  margin: 0 8px; /* Add some margin */
}

.projection-slider span {
  flex: 0 0 auto; /* Don't grow or shrink */
  min-width: 20px; /* Ensure consistent value display width */
  text-align: center;
}

/* Secondary Controls spacing */
#secondary-controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* File upload labels (bold) */
.bold-label {
  font-size: 14px;
  font-weight: bold;
  color: #034e7b; /* Dark navy blue for consistency */
}

/* Select dropdown styling */
select, .custom-select {
  font-size: 13px;
  padding: 6px 8px;
  color: #333;
  background-color: #ffffff;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}

select:hover, .custom-select:hover {
  border-color: #999;
}

select:focus, .custom-select:focus {
  outline: none;
  border-color: #034e7b;
  box-shadow: 0 0 3px rgba(3, 78, 123, 0.3);
}

/* Slider Styling */
input[type="range"] {
  margin-left: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 8px; 
  background: #ddd;
  border-radius: 6px;
  outline: none;
  cursor: pointer;
}

/* Default width for range inputs not in projection sliders */
.slider-group:not(.projection-slider) input[type="range"] {
  width: 100%;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 11px;
  height: 11px;
  background-color: #3690c0;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background-color: #2a7299;
  transform: scale(1.2);
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background-color: #3690c0;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input[type="range"]::-moz-range-thumb:hover {
  background-color: #2a7299;
  transform: scale(1.2);
  box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* Styling for the progress bar and message */
#info-message {
  font-size: 17px;
  text-align: center;
  padding: 10px 10px;
  background-color: #f4f4f4;
}

progress {
  width: 100%;  /* Ensure it takes up full width */
  height: 6px; /* Adjust height to be thinner */
  margin-top: 10px;
  margin-bottom: 10px;
  border-radius: 6px;  /* Rounded corners */
  background-color: #ddd;  /* Light gray background */
}

progress::-webkit-progress-value {
  background-color: #3690c0; /* Same color as the slider thumb */
  border-radius: 4px;
}

/* Responsive Design */
@media (max-width: 768px) {
  #main-layout {
    flex-direction: column;
  }

  #sidebar {
    width: 100%;
  }
}

/* Tooltip Styles */
#tooltip {
  position: absolute;
  background: rgba(50, 50, 50, 0.9);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  display: none;
  pointer-events: none;
  z-index: 1000;
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
  opacity: 0;
  transform: translateY(-10px);
  /* Add white text border for better readability */
  text-shadow: 
    -1px -1px 0 rgba(255, 255, 255, 0.3),
    1px -1px 0 rgba(255, 255, 255, 0.3),
    -1px 1px 0 rgba(255, 255, 255, 0.3),
    1px 1px 0 rgba(255, 255, 255, 0.3),
    0 0 3px rgba(255, 255, 255, 0.3);
}

#tooltip[style*="display: block"] {
  opacity: 1;
  transform: translateY(0);
}

.hidden {
  display: none;
}

/* PCA projection indicator */
.projection-indicator {
  margin: 8px 0 6px 0;
  padding: 6px 8px;
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  font-size: 12px;
  color: #495057;
}

.projection-indicator .indicator-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 12px;
}

#pca-projection-text {
  font-family: "Courier New", monospace;
  font-size: 11px;
  white-space: pre-line;
  color: #212529;
}

.projection-metric {
  margin-top: 4px;
  font-size: 11px;
  color: #495057;
}

.projection-actions {
  margin-top: 6px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.control-button.small {
  padding: 4px 8px;
  font-size: 11px;
  line-height: 1.2;
}

.control-button.small.secondary {
  background-color: #f0f0f0;
}

.projection-bookmarks {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px dashed #ced4da;
}

.projection-bookmarks .bookmark-title {
  font-weight: 600;
  font-size: 11px;
  margin-bottom: 4px;
  color: #495057;
}

.bookmark-item {
  font-size: 11px;
  padding: 4px 6px;
  margin-bottom: 4px;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  background-color: #ffffff;
  cursor: pointer;
  transition: background-color 0.15s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bookmark-item:hover {
  background-color: #eef4ff;
}

.bookmark-thumb {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border: 1px solid #e0e0e0;
  border-radius: 3px;
  background-color: #f8f9fa;
}

.bookmark-label {
  font-size: 11px;
  color: #212529;
  line-height: 1.2;
  word-break: break-word;
}

#chart-loading-spinner {
  position: absolute;
  top: 5px;
  right: 0;
  z-index: 1000;
  display: none;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-family: Arial, sans-serif;
  font-size: 8px;
  color: #555;
  background-color: rgba(248, 249, 250, 0.95);
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: 1px solid #e0e0e0;
  width: fit-content;
  height: auto;
  min-height: 5px;
}

#chart-loading-spinner:not(.hidden) {
  display: flex;
}

#chart-loading-spinner .spinner {
  width: 12px;
  height: 12px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top: 2px solid #3690c0;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 2px;
}

#chart-loading-spinner p {
  margin: 0;
  color: #333;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.cancel-btn {
  background-color: #333;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 3px 5px;
  font-size: 8px;
  font-weight: 500;
  cursor: pointer;
  margin-top: 2px;
  margin-left: 2px;
  margin-bottom: 2px;
  transition: background-color 0.2s ease;
}

.cancel-btn:hover {
  background-color: #cc3333;
}

.cancel-btn:active {
  background-color: #aa2222;
}

/* Toast Notification Styles */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  pointer-events: none;
}

.toast {
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  margin-bottom: 10px;
  font-size: 14px;
  max-width: 400px;
  word-wrap: break-word;
  opacity: 0;
  transform: translateX(400px);
  transition: all 0.3s ease-out;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

.toast.success {
  background-color: rgba(40, 167, 69, 0.9);
}

.toast.error {
  background-color: rgba(220, 53, 69, 0.9);
}

.toast.warning {
  background-color: rgba(255, 193, 7, 0.9);
  color: #000;
}

.toast.info {
  background-color: rgba(23, 162, 184, 0.9);
}
