/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1a1a;
  --bg-secondary: #2a2a2a;
  --bg-tertiary: #333;
  --text-primary: #fff;
  --text-secondary: #ccc;
  --accent: #4a9eff;
  --border: #444;
  --shadow: rgba(0, 0, 0, 0.5);
  --transition: 0.3s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  overflow: hidden;
  background: #000;
  color: var(--text-primary);
}

/* Canvas */
#canvas {
  display: block;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Control Panel */
.control-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 320px;
  height: 100vh;
  background: var(--bg-primary);
  border-left: 1px solid var(--border);
  z-index: 10;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.control-panel::-webkit-scrollbar {
  width: 8px;
}

.control-panel::-webkit-scrollbar-track {
  background: var(--bg-secondary);
}

.control-panel::-webkit-scrollbar-thumb {
  background: var(--bg-tertiary);
  border-radius: 4px;
}

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

/* Panel Header */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.panel-header h1 {
  font-size: 24px;
  font-weight: 600;
}

.toggle-btn {
  display: none;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 24px;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  cursor: pointer;
  transition: background var(--transition);
}

.toggle-btn:hover {
  background: #444;
}

/* Preset Buttons */
.preset-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 15px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.preset-btn {
  padding: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--transition);
}

.preset-btn:hover {
  background: #444;
  border-color: var(--accent);
  transform: translateY(-1px);
}

.preset-btn:active {
  transform: translateY(0);
}

/* Control Sections */
.control-section {
  border-bottom: 1px solid var(--border);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background: var(--bg-secondary);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.section-header:hover {
  background: #2e2e2e;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.toggle-icon {
  font-size: 14px;
  transition: transform var(--transition);
}

.control-section.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.section-content {
  padding: 15px 20px;
  max-height: 1000px;
  overflow: hidden;
  transition: max-height var(--transition), padding var(--transition);
}

.control-section.collapsed .section-content {
  max-height: 0;
  padding: 0 20px;
}

/* Control Groups */
.control-group {
  margin-bottom: 20px;
}

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

.control-group label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.control-group label span {
  font-weight: 600;
  color: var(--accent);
  font-family: monospace;
  font-size: 13px;
}

/* Range Inputs */
input[type="range"] {
  width: 100%;
  height: 6px;
  background: var(--bg-tertiary);
  border-radius: 3px;
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
  background: #5aa7ff;
  transform: scale(1.1);
}

input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all var(--transition);
}

input[type="range"]::-moz-range-thumb:hover {
  background: #5aa7ff;
  transform: scale(1.1);
}

/* Select Inputs */
select {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}

select:hover {
  border-color: var(--accent);
}

select:focus {
  outline: none;
  border-color: var(--accent);
}

/* Buttons */
.btn {
  padding: 10px 16px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  font-weight: 500;
}

.btn:hover {
  background: #444;
  border-color: var(--accent);
}

.btn:active {
  transform: scale(0.98);
}

.control-group .btn {
  width: 100%;
}

/* Export Buttons */
.export-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.export-buttons .btn {
  padding: 12px;
  font-size: 13px;
}

/* Keyboard Shortcuts */
.shortcuts {
  padding: 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.shortcuts h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-list div {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  justify-content: space-between;
}

kbd {
  padding: 2px 6px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-primary);
}

/* Notification */
.notification {
  position: fixed;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%);
  padding: 15px 30px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  z-index: 1000;
  transition: bottom var(--transition);
  box-shadow: 0 4px 12px var(--shadow);
}

.notification.show {
  bottom: 30px;
}

.notification.success {
  border-color: #4ade80;
}

.notification.error {
  border-color: #f87171;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .control-panel {
    width: 100%;
    height: auto;
    max-height: 60vh;
    top: auto;
    bottom: 0;
    border-left: none;
    border-top: 1px solid var(--border);
    transform: translateY(calc(100% - 70px));
  }

  .control-panel.expanded {
    transform: translateY(0);
  }

  .toggle-btn {
    display: block;
  }

  .panel-header {
    position: relative;
  }

  .preset-buttons {
    grid-template-columns: repeat(2, 1fr);
  }

  .export-buttons {
    grid-template-columns: 1fr;
  }

  .notification {
    bottom: -60px;
    left: 10px;
    right: 10px;
    transform: none;
    width: auto;
  }

  .notification.show {
    bottom: 80px;
  }
}

@media (max-width: 480px) {
  .panel-header h1 {
    font-size: 20px;
  }

  .preset-buttons {
    grid-template-columns: 1fr;
  }

  .control-group label {
    font-size: 13px;
  }

  .control-group label span {
    font-size: 12px;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support (already dark by default) */
@media (prefers-color-scheme: light) {
  /* Could add light mode styles here if desired */
}
