/* ============================================
   OmniBase CSS - Unified Control Panel Styles
   ============================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
  font-family: system-ui, -apple-system, sans-serif;
  background: #1a1a2e;
  color: #eee;
  min-height: 100vh;
  overflow: hidden;
}

/* Header */
.header {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 0 10px;
}

.header h1 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.subtitle {
  display: none;
}

.header-right {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.legend-toggle {
  background: #16213e;
  border: none;
  color: #555;
  font-size: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  filter: grayscale(1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.legend-toggle:hover {
  background: #1e2a4a;
}

.legend-toggle.active {
  background: #3a3a4a;
  color: #888;
}

/* Main Layout */
.layout {
  display: flex;
  flex-direction: row;
  gap: 15px;
  padding: 10px;
  height: calc(100vh - 30px);
}

/* Chart Container */
.chart-container {
  flex: 1;
  background: #16213e;
  border-radius: 12px;
  padding: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: grab;
  min-width: 0;
  position: relative;
}

.chart-container:active { cursor: grabbing; }

.chart-container svg {
  background: #0f0f23;
  border-radius: 8px;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

/* HTML Legend (inside chart-container, top-right, fixed size) */
.chart-legend {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(15, 15, 35, 0.85);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
  pointer-events: none;
}

.chart-legend.hidden {
  display: none;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-color {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-label {
  font-size: 10px;
  color: #999;
  white-space: nowrap;
}

/* Controls Wrapper */
.controls-wrapper {
  display: flex;
  width: 320px;
  flex-shrink: 0;
  min-height: 0;
  align-self: stretch;
}

/* Multiscroller Strip */
.multiscroller-strip {
  width: 32px;
  flex-shrink: 0;
  background: #16213e;
  border-radius: 12px 0 0 12px;
  display: flex;
  flex-direction: column;
  padding: 4px 0;
  align-self: stretch;
}

/* Center content-sized buttons when using full names */
.multiscroller-strip.full-names {
  justify-content: flex-start;
}

.strip-btn {
  flex: 1;
  min-height: 30px;
  max-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: #666;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s;
  writing-mode: vertical-lr;
}

/* When showing full names, buttons size to their content */
.multiscroller-strip.full-names .strip-btn {
  flex: 0 0 auto;
  min-height: 0;
  max-height: none;
  padding: 6px 0;
}

.strip-btn:hover {
  color: #4fc3f7;
  background: rgba(79, 195, 247, 0.1);
}

/* Button won't do anything - section already visible/at-top */
.strip-btn.inactive {
  color: #3a3a4a;
  cursor: default;
}

.strip-btn.active {
  color: #4fc3f7;
  background: rgba(79, 195, 247, 0.15);
}

.strip-btn.inactive:not(.active):hover {
  color: #3a3a4a;
  background: transparent;
  cursor: default;
}

/* When multiscroller is unlocked (legend hidden), show grab cursor */
.multiscroller-unlocked .strip-btn {
  cursor: grab;
}

.multiscroller-unlocked .strip-btn:active {
  cursor: grabbing;
}

/* Controls Panel */
.controls {
  position: relative;
  flex: 1;
  background: #16213e;
  border-radius: 0 12px 12px 0;
  padding: 12px 12px 12px 8px;
  overflow-y: auto;
  overflow-x: hidden;
}

.controls::-webkit-scrollbar {
  width: 6px;
}

.controls::-webkit-scrollbar-track {
  background: #0f0f23;
  border-radius: 3px;
}

.controls::-webkit-scrollbar-thumb {
  background: #4fc3f7;
  border-radius: 3px;
}

.control-group { 
  margin-bottom: 14px;
  scroll-margin-top: 4px;
  padding: 8px;
  margin-left: -8px;
  margin-right: -4px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.control-group.active {
  background: rgba(79, 195, 247, 0.06);
}

.control-group h3 {
  font-size: 10px;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.control { margin-bottom: 8px; }
.control label { display: flex; justify-content: space-between; font-size: 11px; margin-bottom: 2px; }
.control label span:last-child { color: #4fc3f7; font-family: monospace; font-size: 10px; }

input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: #0f0f23;
  outline: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4fc3f7;
  cursor: pointer;
}

.presets { display: flex; flex-wrap: wrap; gap: 4px; }

.preset-btn {
  padding: 4px 8px;
  border: 1px solid #4fc3f7;
  background: transparent;
  color: #4fc3f7;
  border-radius: 4px;
  cursor: pointer;
  font-size: 10px;
  transition: all 0.2s;
}

.preset-btn:hover, .preset-btn.active { background: #4fc3f7; color: #1a1a2e; }

/* Hint text - large screens only */
.hint {
  display: none;
  font-size: 11px;
  color: #555;
  margin-top: 12px;
  line-height: 1.5;
}

@media (min-width: 1000px) {
  .hint {
    display: block;
  }
}

/* ============================================
   PORTRAIT LAYOUT (default, controlled by JS)
   ============================================ */
body.layout-portrait .layout {
  flex-direction: column;
  gap: 10px;
  padding: 8px;
}

body.layout-portrait .chart-container {
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 800 / 650;
  min-height: 0;
  /* Ensure minimum space for controls */
  max-height: calc(100vh - 270px);
}

body.layout-portrait .controls-wrapper {
  width: 100%;
  flex: 1;
  min-height: 210px;
  max-height: none;
}

body.layout-portrait .multiscroller-strip {
  border-radius: 12px 0 0 12px;
}

body.layout-portrait .controls {
  border-radius: 0 12px 12px 0;
}

/* ============================================
   LANDSCAPE LAYOUT (controlled by JS)
   ============================================ */
body.layout-landscape {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr;
  height: 100vh;
  gap: 0 10px;
  padding: 10px;
}

body.layout-landscape .header {
  grid-column: 1;
  grid-row: 1;
  height: auto;
}

body.layout-landscape .layout {
  display: contents;
}

body.layout-landscape .chart-container {
  grid-column: 1;
  grid-row: 2;
  flex: unset;
  min-height: 0;
  aspect-ratio: 800 / 650;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: 100%;
  justify-self: center;
}

body.layout-landscape .controls-wrapper {
  grid-column: 2;
  grid-row: 1 / 3;
  width: auto;
  height: 100%;
}

/* Large landscape - taller header */
@media (min-width: 1000px) {
  body.layout-landscape .header {
    flex-direction: column;
    padding: 10px;
  }
  
  body.layout-landscape .header h1 {
    font-size: 24px;
    margin-bottom: 5px;
  }
  
  body.layout-landscape .subtitle {
    display: block;
    color: #888;
    font-size: 14px;
    text-align: center;
  }
  
  body.layout-landscape .header-right {
    top: 10px;
    transform: none;
  }
}

/* Very small screens */
@media (max-height: 500px) {
  .controls-wrapper {
    min-height: 150px;
  }
}

/* ============================================
   Additional Control Types
   ============================================ */

/* Select/Dropdown */
.control select {
  width: 100%;
  padding: 6px 8px;
  background: #0f0f23;
  border: 1px solid #333;
  border-radius: 4px;
  color: #eee;
  font-size: 11px;
  cursor: pointer;
  outline: none;
}

.control select:focus {
  border-color: #4fc3f7;
}

/* File Drop Area */
.file-drop {
  border: 2px dashed #333;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  color: #666;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: #4fc3f7;
  background: rgba(79, 195, 247, 0.05);
  color: #4fc3f7;
}

.file-drop-icon {
  font-size: 24px;
  margin-bottom: 8px;
  opacity: 0.5;
}

/* Status Message */
.status-message {
  font-size: 11px;
  color: #4fc3f7;
  margin-top: 8px;
  min-height: 16px;
}

.status-message.error {
  color: #ff6b6b;
}

/* Info Panel */
.info-panel {
  font-size: 11px;
  color: #888;
  margin-top: 8px;
  padding: 8px;
  background: rgba(79, 195, 247, 0.1);
  border-radius: 4px;
  display: none;
  line-height: 1.4;
}

.info-panel.visible {
  display: block;
}

.info-panel strong {
  color: #4fc3f7;
}

/* Button in control group */
.control-group .btn {
  background: #4fc3f7;
  color: #1a1a2e;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 11px;
  width: 100%;
  transition: all 0.2s;
}

.control-group .btn:hover {
  background: #3dbdb5;
}

.control-group .btn:disabled {
  background: #666;
  cursor: not-allowed;
}

.control-group .btn.secondary {
  border: 1px solid #f7cd4fcf;
  border-radius: 4px;
  background: transparent;
  color: #f7cd4fcf;
}

.control-group .btn.secondary:hover {
  background: #f7cd4f8f;
  color: #000;
}

/* ============================================
   3D Canvas Support
   ============================================ */

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
  border-radius: 8px;
}

/* Dynamic roll controls container */
.dynamic-controls {
  /*max-height: 200px;*/
  overflow-y: auto;
}

.dynamic-controls::-webkit-scrollbar {
  width: 4px;
}

.dynamic-controls::-webkit-scrollbar-track {
  background: #0f0f23;
  border-radius: 2px;
}

.dynamic-controls::-webkit-scrollbar-thumb {
  background: #4fc3f7;
  border-radius: 2px;
}


    
    /* OmniTree-specific styles */
    .tree-container {
      position: relative;
      width: 100%;
      height: 100%;
      cursor: grab;
    }
    
    .tree-container.scrolling {
      cursor: default;
    }
    
    .tree-container.dragging {
      cursor: grabbing;
    }
    
    .ascii-output {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background: #0f0f23;
      border-radius: 8px;
      padding: 20px;
      font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
      font-size: 14px;
      line-height: 1.5;
      color: #a1a1aa;
      overflow: auto;
      white-space: pre;
      transition: opacity 0.3s;
      pointer-events: none;
    }
    
    .ascii-output.active {
      pointer-events: auto;
    }
    
    .ascii-output::-webkit-scrollbar {
      width: 8px;
      height: 8px;
    }
    
    .ascii-output::-webkit-scrollbar-track {
      background: #16213e;
      border-radius: 4px;
    }
    
    .ascii-output::-webkit-scrollbar-thumb {
      background: #4fc3f7;
      border-radius: 4px;
    }
    

    
    .tree-info {
      display: flex;
      justify-content: space-between;
      font-size: 11px;
      color: #888;
      margin-top: 8px;
    }
    
    .tree-info .value {
      color: #ccc;
    }
    
    /* Toggle styles integrated into control panel */
    .toggle-group {
      display: flex;
      flex-direction: column;
      gap: 8px;
    }
    
    .toggle-item {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      user-select: none;
      padding: 4px 0;
    }
    
    .toggle-item input {
      display: none;
    }
    
    .toggle-slider {
      width: 36px;
      height: 20px;
      background: #3f3f46;
      border-radius: 10px;
      position: relative;
      transition: background 0.2s ease;
      flex-shrink: 0;
    }
    
    .toggle-slider::after {
      content: '';
      position: absolute;
      width: 14px;
      height: 14px;
      background: #e4e4e7;
      border-radius: 50%;
      top: 3px;
      left: 3px;
      transition: transform 0.2s ease;
    }
    
    .toggle-item input:checked + .toggle-slider {
      background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    }
    
    .toggle-item input:checked + .toggle-slider::after {
      transform: translateX(16px);
    }
    
    .toggle-label {
      font-size: 11px;
      color: #888;
    }
