:root {
  --bg-color: #0a0b10;
  --panel-bg: rgba(18, 20, 30, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f3f9;
  --text-secondary: #8f96a3;
  --accent-color: #00f0ff;
  --accent-rgb: 0, 240, 255;
  --power-on: #ff0055;
  --power-on-rgb: 255, 0, 85;
  --warm-color: #ffa600;
  --cold-color: #e3f2fd;
  --mix-color: #fff9e6;
  
  --font-main: 'Outfit', sans-serif;
  --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.5);
  --shadow-sm: 0 4px 10px rgba(0, 0, 0, 0.3);
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-medium: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-color);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Canvas stretching */
#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.loading-overlay.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-container {
  text-align: center;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid rgba(255, 255, 255, 0.05);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  margin: 0 auto 20px auto;
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.2);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loader-title {
  font-size: 1.5rem;
  font-weight: 500;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.loader-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Premium Sidebar Panel */
.control-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  bottom: 20px;
  width: 380px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 20px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: transform var(--transition-medium);
}

.panel-header {
  padding: 24px 24px 20px 24px;
  border-bottom: 1px solid var(--panel-border);
}

.brand-tag {
  display: inline-block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 700;
  color: var(--accent-color);
  background: rgba(0, 240, 255, 0.1);
  padding: 4px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.panel-title {
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  line-height: 1.2;
}

.panel-subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 4px;
}

.panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Custom scrollbar for panel */
.panel-content::-webkit-scrollbar {
  width: 6px;
}
.panel-content::-webkit-scrollbar-track {
  background: transparent;
}
.panel-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}
.panel-content::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
}

.section-description {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Battery Card Styles */
.battery-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.battery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.battery-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.battery-status-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.battery-status-tag.charging {
  background: rgba(57, 255, 20, 0.15);
  color: #39ff14;
  animation: pulse-light 1.5s infinite;
}

.battery-status-tag.discharging {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.battery-status-tag.critical {
  background: rgba(255, 0, 85, 0.15);
  color: var(--power-on);
  animation: pulse-light 0.8s infinite;
}

@keyframes pulse-light {
  0% { opacity: 0.6; }
  50% { opacity: 1; }
  100% { opacity: 0.6; }
}

.battery-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.battery-icon-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.battery-icon {
  width: 48px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  padding: 2px;
  position: relative;
  flex-shrink: 0;
}

.battery-icon::after {
  content: "";
  position: absolute;
  top: 4px;
  right: -5px;
  width: 3px;
  height: 10px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 0 2px 2px 0;
}

.battery-level-bar {
  height: 100%;
  border-radius: 2px;
  background: #39ff14;
  transition: width 0.3s ease, background-color 0.3s ease;
  box-shadow: 0 0 5px rgba(57, 255, 20, 0.3);
}

.battery-percentage-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.cable-toggle-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
}

.cable-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Form Controls */
.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 500;
}

.control-label {
  font-size: 0.85rem;
  font-weight: 500;
}

/* Buttons */
.btn-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border: none;
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary {
  background-color: var(--accent-color);
  color: #000;
}

.btn-primary:hover {
  background-color: #00d9e6;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-secondary:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(1px);
}

/* Power Toggle Button */
.btn-power-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 14px;
  cursor: pointer;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 0.95rem;
  transition: all var(--transition-fast);
  width: 100%;
}

.btn-power-toggle.off {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-power-toggle.off:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-power-toggle.on {
  background: rgba(255, 0, 85, 0.15);
  border: 1px solid rgba(255, 0, 85, 0.3);
  color: #fff;
  box-shadow: 0 0 15px rgba(255, 0, 85, 0.2);
}

.btn-power-toggle.on:hover {
  background: rgba(255, 0, 85, 0.22);
  border-color: rgba(255, 0, 85, 0.5);
  box-shadow: 0 0 20px rgba(255, 0, 85, 0.35);
}

.power-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  transition: all var(--transition-fast);
}

.btn-power-toggle.on .power-icon {
  background: var(--power-on);
  color: #fff;
  box-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(255, 0, 85, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(255, 0, 85, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 0, 85, 0); }
}

.status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.5px;
}

.status-badge.off {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.status-badge.on {
  background: var(--power-on);
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 0, 85, 0.4);
}

/* Color Temperature Picker */
.color-temp-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.temp-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: left;
}

.temp-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.temp-btn.active {
  background: rgba(255, 255, 255, 0.09);
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.temp-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.temp-dot.cold { background-color: var(--cold-color); box-shadow: 0 0 8px var(--cold-color); }
.temp-dot.mix { background-color: var(--mix-color); box-shadow: 0 0 8px var(--mix-color); }
.temp-dot.warm { background-color: var(--warm-color); box-shadow: 0 0 8px var(--warm-color); }

.temp-kelvin {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 400;
}

/* Premium Slider */
.premium-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  margin: 8px 0;
  transition: background var(--transition-fast);
}

.premium-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-color);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.5);
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.premium-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: #fff;
}

/* Switches */
.switch-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.switch-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 75%;
}

.switch-title {
  font-size: 0.85rem;
  font-weight: 500;
}

.switch-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  transition: .3s;
  border-radius: 34px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

input:checked + .switch-slider {
  background-color: var(--accent-color);
}

input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* RGB Color Palette */
.rgb-color-palette {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 10px;
  margin-top: 4px;
  transition: opacity var(--transition-fast), visibility var(--transition-fast);
}

.rgb-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
  position: relative;
}

.rgb-dot:hover {
  transform: scale(1.15);
}

.rgb-dot.active {
  border-color: #fff;
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.custom-color-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  margin-left: auto;
  border-radius: 50%;
  overflow: hidden;
}

.custom-color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.custom-color-picker::-webkit-color-swatch {
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

.custom-color-picker.active::-webkit-color-swatch {
  border-color: #fff;
}

/* Premium Custom Select */
.custom-select-wrapper {
  position: relative;
  width: 100%;
}

.premium-select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.premium-select:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.15);
}

.premium-select:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.custom-select-wrapper::after {
  content: "";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--text-secondary);
  pointer-events: none;
}

/* Cabin Simulator Environment Buttons */
.time-day-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.env-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.env-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.env-btn.active {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-color);
  box-shadow: var(--shadow-sm);
}

/* Exploded View Legend Styles */
.exploded-legend-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style: none;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 4px;
}

.exploded-legend-list::-webkit-scrollbar {
  width: 4px;
}
.exploded-legend-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.legend-item:hover {
  background: rgba(0, 240, 255, 0.05);
  border-color: rgba(0, 240, 255, 0.2);
  transform: translateX(4px);
}

.legend-item.active {
  background: rgba(0, 240, 255, 0.12);
  border-color: var(--accent-color);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

.legend-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

.legend-item:hover .legend-number,
.legend-item.active .legend-number {
  background: var(--accent-color);
  border-color: var(--accent-color);
  color: #000;
}

.legend-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.legend-text strong {
  font-size: 0.85rem;
  color: var(--text-primary);
}

.legend-text p {
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

/* Tech link list */
.tech-links a {
  transition: text-shadow var(--transition-fast), color var(--transition-fast);
}
.tech-links a:hover {
  color: #fff !important;
  text-shadow: 0 0 8px rgba(0, 240, 255, 0.6);
}

/* Footer styling */
.panel-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--panel-border);
  background: rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.memory-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #39ff14;
  background: rgba(57, 255, 20, 0.08);
  padding: 6px 12px;
  border-radius: 8px;
  align-self: flex-start;
  border: 1px solid rgba(57, 255, 20, 0.15);
}

.copyright {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.25);
}

/* Floating Interaction Hints */
.interaction-hint {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 280px;
  background: rgba(18, 20, 30, 0.6);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 16px;
  padding: 16px;
  z-index: 10;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  animation: fade-in-up 1s ease-out;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hint-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-color);
}

.hint-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hint-list li {
  font-size: 0.75rem;
  color: var(--text-secondary);
  line-height: 1.3;
}

.hint-list li strong {
  color: var(--text-primary);
}

/* Media Queries */
@media (max-width: 768px) {
  body {
    overflow-y: auto;
  }
  
  .control-panel {
    position: relative;
    top: 0;
    left: 0;
    bottom: auto;
    width: 100%;
    height: auto;
    border-radius: 0;
    border: none;
    border-top: 1px solid var(--panel-border);
  }
  
  #webgl-canvas {
    position: relative;
    height: 60vh;
  }
  
  .interaction-hint {
    display: none;
  }
}
