/**
 * Chrome Spaceship Control Panel Styling
 * Metallic rotary knobs, LED indicators, and futuristic UI
 */

*, *::before, *::after {
  box-sizing: border-box;
}

#control-panel {
  position: fixed;
  top: 50%;
  right: 40px;
  transform: translateY(-50%);
  width: 280px;
  max-width: calc(100% - 40px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
  border: 2px solid #444;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 
    0 10px 40px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  font-family: 'Arial', 'Helvetica', sans-serif;
  z-index: 1000;
}

/* Custom scrollbar for control panel */
#control-panel::-webkit-scrollbar {
  width: 8px;
}

#control-panel::-webkit-scrollbar-track {
  background: #1a1a1a;
  border-radius: 4px;
}

#control-panel::-webkit-scrollbar-thumb {
  background: #444;
  border-radius: 4px;
}

#control-panel::-webkit-scrollbar-thumb:hover {
  background: #555;
}

#control-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.1) 2px,
      rgba(0, 0, 0, 0.1) 4px
    );
  pointer-events: none;
  border-radius: 8px;
}

.panel-header {
  text-align: center;
  margin-bottom: 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #333;
}

.panel-title {
  font-size: 12px;
  font-weight: bold;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin: 0;
}

.control-group {
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.control-group label {
  font-size: 9px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-align: center;
  display: block;
}

/* Slider Styling */
.slider {
  position: relative;
  width: 100%;
  cursor: pointer;
  user-select: none;
  padding: 4px 0;
  margin-bottom: 10px;
}

.slider-track {
  width: 100%;
  height: 6px;
  background: linear-gradient(to bottom, #1a1a1a, #2a2a2a);
  border: 2px solid #444;
  border-radius: 4px;
  position: relative;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    0 1px 2px rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.slider-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background: linear-gradient(to right, #2E7D32, #4CAF50);
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.4);
  transition: width 0.1s ease;
  pointer-events: none;
}

.slider-thumb {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  background: radial-gradient(
    circle at 35% 35%,
    #ffffff 0%,
    #e0e0e0 40%,
    #c0c0c0 70%,
    #999 100%
  );
  border: 2px solid #666;
  border-radius: 50%;
  box-shadow: 
    0 2px 6px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.6);
  transition: left 0.1s ease;
  pointer-events: none;
}

.slider-value {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 9px;
  color: #4CAF50;
  font-weight: bold;
  text-shadow: 0 0 4px rgba(76, 175, 80, 0.6);
  font-family: 'Courier New', monospace;
  white-space: nowrap;
}

.slider.active .slider-thumb {
  box-shadow: 
    0 2px 10px rgba(76, 175, 80, 0.6),
    inset 0 1px 2px rgba(255, 255, 255, 0.6);
  border-color: #4CAF50;
}

.slider.active .slider-track {
  border-color: #4CAF50;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.6),
    0 0 8px rgba(76, 175, 80, 0.3);
}

/* Toggle Switch Styling */
.toggle {
  position: relative;
  width: 36px;
  height: 14px;
  cursor: pointer;
  user-select: none;
  margin: 0 auto;
}

.toggle-inline {
  width: 36px;
  height: 14px;
}

.toggle-track {
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, #2a2a2a, #1a1a1a);
  border: 2px solid #444;
  border-radius: 5px;
  position: relative;
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
}

.toggle-thumb {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 10px;
  height: 10px;
  transform: translateY(-50%);
  background: radial-gradient(
    circle at 30% 30%,
    #f0f0f0 0%,
    #c0c0c0 50%,
    #888 100%
  );
  border-radius: 50%;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.5);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toggle-led {
  position: absolute;
  top: 50%;
  right: 3px;
  width: 4px;
  height: 4px;
  background: #333;
  border-radius: 50%;
  transform: translateY(-50%);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
  transition: all 0.3s ease;
}

.toggle.active .toggle-track {
  background: linear-gradient(to bottom, #1a3a1a, #0a2a0a);
  border-color: #4CAF50;
}

.toggle.active .toggle-thumb {
  left: calc(100% - 12px);
  background: radial-gradient(
    circle at 30% 30%,
    #fff 0%,
    #e0e0e0 50%,
    #aaa 100%
  );
}

.toggle.active .toggle-led {
  background: #4CAF50;
  box-shadow: 
    0 0 8px rgba(76, 175, 80, 0.8),
    0 0 16px rgba(76, 175, 80, 0.4),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* Color Picker Styling */
.color-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.color-preview {
  position: relative;
  width: 50px;
  height: 50px;
  border-radius: 6px;
  border: 2px solid #444;
  cursor: pointer;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.color-preview:hover {
  border-color: #555;
  box-shadow: 
    0 2px 10px rgba(0, 0, 0, 0.6),
    inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

.color-picker input[type="color"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: none;
}

.color-picker input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker input[type="color"]::-webkit-color-swatch {
  border: none;
}

/* Selector Styling */
.selector select {
  width: 100%;
  padding: 8px 6px;
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  border: 2px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.selector select:hover {
  border-color: #555;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.selector select:focus {
  outline: none;
  border-color: #4CAF50;
  box-shadow: 
    0 0 8px rgba(76, 175, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Button Styling */
.control-button {
  width: 100%;
  padding: 8px;
  background: linear-gradient(to bottom, #4a4a4a, #3a3a3a);
  border: 2px solid #555;
  border-radius: 6px;
  color: #ddd;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  margin-top: 8px;
}

.control-button:hover {
  background: linear-gradient(to bottom, #5a5a5a, #4a4a4a);
  border-color: #666;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.control-button:active {
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  box-shadow: 
    inset 0 2px 4px rgba(0, 0, 0, 0.5),
    0 1px 2px rgba(255, 255, 255, 0.1);
  transform: translateY(1px);
}

.control-button.primary {
  background: linear-gradient(to bottom, #4CAF50, #388E3C);
  border-color: #2E7D32;
  color: #fff;
}

.control-button.primary:hover {
  background: linear-gradient(to bottom, #66BB6A, #4CAF50);
  box-shadow: 
    0 2px 8px rgba(76, 175, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Divider */
.control-divider {
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    #444 20%,
    #444 80%,
    transparent
  );
  margin: 8px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 6px 0 6px 0;
  padding: 0 4px;
}

.section-header .toggle {
  margin: 0;
}

.control-section-label {
  font-size: 9px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
  margin: 0;
}

/* Grid Layout for Controls */
.control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 6px 0;
}

.control-grid-3 {
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.control-grid-full {
  grid-column: 1 / -1;
}

/* Number Settings Styling */
.number-mode-select {
  width: 100%;
  padding: 6px 4px;
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  border: 2px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-size: 9px;
  cursor: pointer;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.number-mode-select:hover {
  border-color: #555;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.number-mode-select:focus {
  outline: none;
  border-color: #4CAF50;
  box-shadow: 
    0 0 8px rgba(76, 175, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.number-input {
  width: 100%;
  padding: 6px 8px;
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  border: 2px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-size: 11px;
  text-align: center;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
}

.number-input:hover {
  border-color: #555;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.number-input:focus {
  outline: none;
  border-color: #4CAF50;
  box-shadow: 
    0 0 8px rgba(76, 175, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* File Upload Styling */
.upload-label {
  display: block;
  width: 100%;
  font-size: 9px;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
  text-align: center;
}

.image-upload-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  width: 100%;
}

.image-upload-row .toggle {
  margin: 0;
  flex-shrink: 0;
}

.file-input {
  flex: 1;
  padding: 0;
  background: transparent;
  border: none;
  color: transparent;
  font-size: 0;
  cursor: pointer;
}

.file-input::file-selector-button {
  width: 100%;
  padding: 6px 4px;
  background: linear-gradient(to bottom, #3a3a3a, #2a2a2a);
  border: 2px solid #444;
  border-radius: 6px;
  color: #aaa;
  font-size: 9px;
  cursor: pointer;
  margin: 0;
  box-sizing: border-box;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  vertical-align: middle;
}

.file-input::file-selector-button:hover {
  border-color: #555;
  box-shadow: 
    0 2px 8px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.file-input::file-selector-button:focus {
  outline: none;
  border-color: #4CAF50;
  box-shadow: 
    0 0 8px rgba(76, 175, 80, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Responsive adjustments */
@media (max-width: 1024px) {
  #control-panel {
    width: 260px;
  }
}

@media (max-width: 768px) {
  html, body {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  main {
    height: auto;
    min-height: 100vh;
    padding: 10px;
    gap: 10px;
  }
  
  #canvas-container canvas {
    max-width: 100%;
    height: auto !important;
  }
  
  #control-panel {
    position: relative;
    width: calc(100% - 20px);
    max-width: 100%;
    top: 0;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    margin: 10px auto;
    max-height: none;
    padding: 16px 12px;
  }
  
  .control-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .control-grid-3 {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  
  .control-button {
    padding: 12px;
    font-size: 12px;
    touch-action: manipulation;
  }
  
  .selector select {
    padding: 12px 8px;
    font-size: 12px;
    min-height: 44px; /* iOS touch target minimum */
  }
  
  .slider {
    padding: 6px 0;
    margin-bottom: 12px;
  }
  
  .slider-thumb {
    width: 18px;
    height: 18px;
  }
  
  .toggle {
    width: 40px;
    height: 16px;
  }
  
  .toggle-thumb {
    width: 12px;
    height: 12px;
  }
  
  .color-preview {
    width: 60px;
    height: 60px;
  }
  
  .section-header {
    margin: 8px 0;
  }
}

@media (max-width: 480px) {
  #control-panel {
    width: calc(100% - 10px);
    margin: 5px auto;
    padding: 12px 10px;
  }
  
  .panel-title {
    font-size: 11px;
  }
  
  .control-button {
    padding: 12px;
    font-size: 11px;
    min-height: 44px; /* iOS touch target minimum */
  }
  
  .selector select {
    padding: 12px 8px;
    font-size: 11px;
    min-height: 44px; /* iOS touch target minimum */
  }
  
  .slider-thumb {
    width: 20px;
    height: 20px;
  }
  
  .toggle {
    width: 44px;
    height: 18px;
  }
  
  .toggle-thumb {
    width: 14px;
    height: 14px;
  }
  
  .color-preview {
    width: 50px;
    height: 50px;
  }
  
  .control-group label,
  .section-header,
  .control-section-label,
  .upload-label {
    font-size: 10px;
  }
}

/* Video Recording & Code Export Styles */
.control-button.secondary {
  background: linear-gradient(to bottom, #4a90e2, #3a70c2);
  border-color: #5a9fe8;
  color: #fff;
}

.control-button.secondary:hover {
  background: linear-gradient(to bottom, #5aa0f2, #4a90e2);
  box-shadow: 
    0 2px 8px rgba(74, 144, 226, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.control-button.recording {
  background: linear-gradient(to bottom, #e74c3c, #c0392b);
  border-color: #e74c3c;
  animation: pulse 1.5s infinite;
}

.control-button.recording:hover {
  background: linear-gradient(to bottom, #f55c4c, #e74c3c);
  box-shadow: 
    0 2px 8px rgba(231, 76, 60, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 
      0 0 0 0 rgba(231, 76, 60, 0.7),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
  50% {
    box-shadow: 
      0 0 0 8px rgba(231, 76, 60, 0),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

.btn-icon {
  font-size: 13px;
  margin-right: 4px;
}

.button-group {
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 8px;
  align-items: stretch;
}

.button-group .control-button {
  flex: 1;
  margin-top: 0;
}

.recording-status {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  background: rgba(231, 76, 60, 0.1);
  border-radius: 4px;
  border: 2px solid rgba(231, 76, 60, 0.3);
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.recording-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e74c3c;
  margin-right: 8px;
  animation: blink 1s infinite;
  box-shadow: 0 0 8px rgba(231, 76, 60, 0.6);
}

@keyframes blink {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0.3;
  }
}

#recording-time {
  color: #e74c3c;
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-shadow: 0 0 4px rgba(231, 76, 60, 0.4);
}

