/* ==========================================================================
   OPTICAL SCHEMATIC BUILDER - MAIN PAGE LAYOUT
   ======================================.action-label {
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: bold;
  margin: 0 8px 0 0;
  padding: 0;
  color: inherit;
  display: inline-block;
  line-height: 1;
  white-space: nowrap;
  width: 140px;
  text-align: left;
}======================= */

/* Base Styles */
body, html {
  height: 100vh;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #f4f4f4;
  overflow: hidden;
}

/* Main Layout Structure */
.main-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.title-row {
  background: #222;
  color: #fafafa;
  padding: 8px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.title-row h1 {
  margin: 0;
  font-size: 1.8rem;
  letter-spacing: 1px;
}

.header-nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.nav-link {
  background-color: #444;
  padding: 6px 12px;
  border-radius: 4px;
  text-decoration: none;
  color: #fafafa;
  font-size: 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: 1px solid #555;
}

.nav-link:hover {
  background-color: #555;
  border-color: #777;
  transform: translateY(-1px);
}

/* Content Area */
.content-row {
  display: flex;
  flex: 1;
  min-height: 0;
  background: #ededed;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: 180px;
  background: #e0e0e0;
  border-right: 1px solid #bdbdbd;
  display: flex;
  flex-direction: column;
  padding: 0;
  min-width: 150px;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Sidebar Component Menu */
.component-menu {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 5px 12px;
  background: #fafafa;
  border-radius: 8px;
  margin: 12px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.component-menu > p {
  font-family: inherit;
  font-size: 1rem;
  font-weight: bold;
  text-align: center;
  margin: 0;
  padding: 0;
  color: inherit;
}

.component-menu button {
  padding: 5px 0;
  cursor: pointer;
  border: 1px solid #bdbdbd;
  background: #ededed;
  border-radius: 4px;
  font-size: 1rem;
  transition: all 0.2s;
}

.component-menu button:hover {
  background: #bdbdbd;
  border-color: #222;
  color: #222;
}

/* Workspace Area */
.workspace-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  min-width: 0;
}

/* Workspace Action Toolbar */
.action-toolbar {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 10px;
  background: #fafafa;
  padding: 8px 8px;
  border-radius: 8px;
  gap: 8px;
  align-items: stretch;
}

.action-row {
  display: flex;
  flex-direction: row;
  gap: 5px;
  align-items: center;
  flex: 1;
  min-width: 500px;
}

.action-title-column {
  display: flex;
  align-items: center;
  min-width: 150px;
  flex-shrink: 0;
}

.action-buttons-column {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  min-width: 350px;
  flex: 1;
}

.action-toolbar button {
  padding: 5px;
  font-size: 0.9375rem;
  border: 1px solid #bdbdbd;
  background: #ededed;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.action-toolbar button:hover {
  background: #bdbdbd;
  border-color: #222;
  color: #222;
}

.action-label {
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: bold;
  margin: 0;
  padding: 0;
  color: inherit;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
}

/* Canvas */
.canvas-container {
  flex: 1;
  position: relative;
  display: flex;
  background: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
  padding: 0;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

#canvas {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: block;
  border: 1px solid #bdbdbd;
  border-radius: 8px;
  box-sizing: border-box;
  cursor: default;
}

/* Component Interactions */
.component {
  cursor: move;
}

.component:hover path,
.component:hover rect,
.component:hover line,
.component:hover ellipse {
  stroke: #555;
  stroke-width: 2.5;
}

.component-hit-area {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}

/* Footer */
.footer {
  background: #333;
  color: #ccc;
  text-align: center;
  padding: 6px 12px;
  flex-shrink: 0;
  font-size: 0.875rem;
}

.footer p {
  margin: 0;
}

.footer a {
  color: #fff;
  text-decoration: none;
}

.footer img {
  height: 0.9em;
  vertical-align: middle;
  margin-right: 4px;
}

/* ==========================================================================
   RAY CONTROLS & INTERACTIVE ELEMENTS
   ========================================================================== */

/* Custom Range Sliders - Hue Slider */
input[type="range"].hue-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
  outline: none;
}

input[type="range"].hue-slider::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
}

input[type="range"].hue-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #888;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  cursor: pointer;
  margin-top: -3px;
}

input[type="range"].hue-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #888;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  cursor: pointer;
}

input[type="range"].hue-slider::-ms-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid #888;
  box-shadow: 0 0 2px rgba(0,0,0,0.2);
  cursor: pointer;
}

input[type="range"].hue-slider::-moz-range-track {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
}

input[type="range"].hue-slider::-ms-fill-lower,
input[type="range"].hue-slider::-ms-fill-upper {
  background: none;
}

input[type="range"].hue-slider:focus {
  outline: none;
}

/* Ray Shape Menu */
.ray-shape-menu {
  position: absolute;
  background-color: white;
  border: 1px solid #ccc;
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  z-index: 1000;
  padding: 0 8px;
  min-width: 0;
  font-size: 1rem;
  font-family: Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  box-sizing: border-box;
  margin-right: 20px;
}

.ray-shape-menu .ray-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
  width: 100%;
}

.ray-shape-menu .ray-label,
.ray-shape-menu .shape-label,
.ray-shape-menu .slider-label,
.ray-shape-menu .hue-label {
  font-weight: bold;
  margin-right: 6px;
}

.ray-shape-menu .slider-label {
  margin-left: 0;
}

.ray-shape-menu .hue-label {
  margin-left: 10px;
}

.ray-shape-menu .radius-slider {
  width: 80px;
}

.ray-shape-menu .value-display {
  min-width: 20px;
  font-size: 0.9rem;
}

.ray-shape-menu .hue-input {
  width: 60px;
  padding: 2px 8px;
  margin-left: 2px;
  font-size: 0.9rem;
  box-sizing: border-box;
}

/* Slider Container */
.slider-container {
  position: relative;
  width: 160px;
  height: 20px;
}

.slider-container input[type="range"].background-only {
  pointer-events: none;
  width: 160px;
}

input[type="range"].single-knob {
  width: 160px;
}

/* Custom Knobs */
.custom-knob {
  position: absolute;
  background: linear-gradient(to bottom, #ffffff 0%, #e6e6e6 100%);
  border: 1px solid #b3b3b3;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.custom-knob.knob1.selected,
.custom-knob.knob2.selected {
  z-index: 10;
}

.custom-knob:not(.selected) {
  z-index: 9;
}

/* Gradient Toggle Button */
.gradient-toggle {
  margin-left: 4px;
  width: 24px;
  height: 24px;
  font-size: 0.875rem;
  cursor: pointer;
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  background: #ededed;
  border: 1px solid #bdbdbd;
  transition: all 0.2s;
}

.gradient-toggle:hover {
  background: #bdbdbd;
  border-color: #222;
}

.gradient-toggle.active {
  background: #4CAF50;
  border-color: #45a049;
  color: white;
}

.gradient-icon {
  width: 100%;
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff);
}

.gradient-icon.enabled {
  border: 2px solid #4CAF50;
}

.gradient-icon.disabled {
  border: none;
  background: none;
}

/* Swatch Controls */
.swatch-btn {
  margin-left: 4px;
}

.swatch-popup {
  position: absolute;
  z-index: 2000;
  background: #fff;
  border: 1px solid #888;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatch-popup .swatch {
  width: 24px;
  height: 24px;
  border: 1px solid #888;
  border-radius: 4px;
  cursor: pointer;
}

.swatch-popup .no-colors {
  color: #888;
}

/* Control Buttons */
.remove-btn,
.plus-btn {
  margin-left: 0;
  font-weight: bold;
  cursor: pointer;
}

/* Component Preview Tooltip */
.component-preview-tooltip {
  position: absolute;
  background: white;
  border: 2px solid #333;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  padding: 8px;
  z-index: 1000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.component-preview-tooltip.show {
  opacity: 1;
  transform: translateY(0);
}

.component-preview-tooltip svg {
  display: block;
  width: 80px;
  height: 60px;
  background: #f9f9f9;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.component-preview-tooltip .tooltip-title {
  text-align: center;
  font-size: 0.8rem;
  font-weight: bold;
  margin: 4px 0 0 0;
  color: #333;
}
