/* KineticFlow - Global Styles & Design System */

:root {
  --font-heading: 'Space Grotesk', sans-serif;
  --font-body: 'Outfit', sans-serif;
  
  /* Color Palettes */
  --bg-deep: #05050a;
  --bg-panel: rgba(13, 13, 25, 0.5);
  --bg-panel-hover: rgba(20, 20, 38, 0.65);
  --border-light: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(0, 240, 255, 0.3);
  
  /* Active Theme Colors - Default (Nebula) */
  --theme-primary: #00f0ff;    /* Cyan */
  --theme-secondary: #9d4edd;  /* Magenta/Purple */
  --theme-glow: rgba(0, 240, 255, 0.4);
  --theme-glow-secondary: rgba(157, 78, 221, 0.4);
  
  --text-main: #f0f0f5;
  --text-muted: #8a8a9e;
  --text-active: #ffffff;
  
  --shadow-neon: 0 0 20px var(--theme-glow);
  --shadow-neon-inset: inset 0 0 10px var(--theme-glow);
  --shadow-premium: 0 24px 48px rgba(0, 0, 0, 0.5);
  
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --transition-fast: all 0.15s ease;
}

/* Base resets & layouts */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* Background canvas */
#particleCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: auto;
}

/* Background ambient glow effect */
#ambientGlow {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  background: radial-gradient(circle 800px at var(--glow-x, 50%) var(--glow-y, 50%), var(--theme-glow), transparent 60%);
  opacity: 0.15;
  pointer-events: none;
  transition: background 0.5s ease;
}

/* Glassmorphic card styling helper */
.glass-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-premium);
  border-radius: 16px;
  transition: var(--transition-smooth);
}

/* Splash screen overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(4, 4, 8, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s;
}

.overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-card {
  width: 90%;
  max-width: 500px;
  padding: 40px;
  text-align: center;
  background: rgba(13, 13, 28, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
  animation: floatUp 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes floatUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.splash-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 15px;
}

.logo-icon {
  font-size: 3.5rem;
  color: var(--theme-primary);
  text-shadow: 0 0 30px var(--theme-glow);
  margin-bottom: 15px;
  animation: pulseGlow 3s infinite ease-in-out;
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(1);
    filter: drop-shadow(0 0 10px var(--theme-glow));
  }
  50% {
    transform: scale(1.08);
    filter: drop-shadow(0 0 25px var(--theme-primary));
  }
}

.splash-logo h1 {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 4px;
}

.splash-logo h1 span {
  color: var(--theme-primary);
  text-shadow: 0 0 15px var(--theme-glow);
}

.splash-subtitle {
  color: var(--text-muted);
  font-size: 1.1rem;
  margin-bottom: 30px;
}

.splash-info {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 35px;
  text-align: left;
}

.info-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  background: rgba(255, 255, 255, 0.03);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.info-item i {
  font-size: 1.2rem;
  color: var(--theme-secondary);
  margin-top: 2px;
}

.info-item span {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--theme-primary), var(--theme-secondary));
  color: #fff;
  border: none;
  padding: 16px 36px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  border-radius: 30px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 8px 24px var(--theme-glow-secondary);
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: 0;
  left: -50%;
  width: 200%;
  height: 100%;
  background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
  transform: skewX(-30deg);
  transition: 0.75s;
}

.btn-primary:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px var(--theme-glow);
}

.btn-primary:hover::after {
  left: 120%;
}

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

.loading-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.loading-status.hidden {
  display: none !important;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--theme-primary);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loadingText {
  font-size: 0.9rem;
  color: var(--theme-primary);
  text-shadow: 0 0 10px var(--theme-glow);
  font-weight: 600;
}

/* HUD layout wrapper */
#hudContainer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none; /* Let clicks pass to canvas if not on UI elements */
}

/* Header bar */
.hud-header {
  position: absolute;
  top: 20px;
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: auto;
}

.hud-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-panel);
  padding: 10px 20px;
  border-radius: 30px;
  border: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.hud-logo i {
  color: var(--theme-primary);
  font-size: 1.2rem;
  filter: drop-shadow(0 0 5px var(--theme-glow));
}

.hud-logo h2 {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.system-stats {
  display: flex;
  gap: 10px;
}

.stat-badge {
  background: var(--bg-panel);
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.stat-badge.highlight {
  border-color: var(--theme-primary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.15);
}

.stat-label {
  color: var(--text-muted);
}

.stat-value {
  color: var(--text-active);
  font-weight: 700;
  font-family: var(--font-heading);
}

/* Floating Sidebar Container */
.sidebar {
  position: absolute;
  top: 90px;
  left: 20px;
  bottom: 20px;
  width: 330px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  box-shadow: var(--shadow-premium);
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  z-index: 20;
}

.sidebar.collapsed {
  transform: translateX(-355px);
}

/* Sidebar Toggle Handle */
.sidebar-toggle {
  position: absolute;
  right: -36px;
  top: 20px;
  width: 36px;
  height: 36px;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-left: none;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
  transition: var(--transition-fast);
  box-shadow: 8px 4px 16px rgba(0, 0, 0, 0.2);
}

.sidebar-toggle:hover {
  color: var(--theme-primary);
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

/* Sidebar scrollable contents */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Custom Scrollbar for Sidebar */
.sidebar-content::-webkit-scrollbar {
  width: 5px;
}

.sidebar-content::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: var(--theme-glow);
}

/* UI Section Container */
.control-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-section h3 {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-active);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-section h3 i {
  color: var(--theme-primary);
  font-size: 0.9rem;
}

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

.control-group label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

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

.slider-header span {
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--theme-primary);
}

/* Custom Styled Select */
.select-wrapper {
  position: relative;
}

.select-wrapper::after {
  content: '\f078';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  font-size: 0.75rem;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

select {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 10px 14px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 0.9rem;
  appearance: none;
  cursor: pointer;
  transition: var(--transition-fast);
}

select:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.2);
}

select:focus {
  outline: none;
  border-color: var(--theme-primary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.1);
}

select option {
  background: #0f0f20;
  color: var(--text-main);
  padding: 10px;
}

/* Custom Styled Ranges */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  outline: none;
  transition: var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--theme-primary);
  box-shadow: var(--shadow-neon);
  cursor: pointer;
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Checkbox and toggle styles */
.checkbox-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.checkbox-row label {
  font-size: 0.9rem;
  color: var(--text-main);
  font-weight: 500;
}

/* Sleek Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

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

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

.slider-switch:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider-switch {
  background-color: rgba(0, 240, 255, 0.1);
  border-color: var(--theme-primary);
}

input:checked + .slider-switch:before {
  transform: translateX(20px);
  background-color: var(--theme-primary);
  box-shadow: 0 0 8px var(--theme-primary);
}

/* Legends and Card Layout */
.legend-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  transition: var(--transition-smooth);
}

.legend-card.active {
  background: rgba(0, 240, 255, 0.06);
  border-color: var(--theme-primary);
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.1);
  transform: scale(1.02);
}

.gesture-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  width: 24px;
  text-align: center;
  transition: var(--transition-fast);
}

.legend-card.active .gesture-icon {
  color: var(--theme-primary);
  text-shadow: 0 0 10px var(--theme-glow);
}

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

.legend-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

.legend-card.active .legend-title {
  color: var(--theme-primary);
}

.legend-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Picture in Picture camera overlay */
#cameraPipContainer {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 200px;
  height: 150px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-premium);
  pointer-events: auto;
  transition: width 0.3s ease, height 0.3s ease;
  z-index: 10;
}

#cameraPipContainer.glowing-border {
  border: 1.5px solid var(--theme-primary);
  box-shadow: 0 0 15px var(--theme-glow), var(--shadow-premium);
}

#webcam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera feed */
}

#skeletonCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  object-fit: cover; /* Match webcam crop-zoom aspect ratio */
  transform: scaleX(-1); /* Mirror skeleton overlay to match mirrored webcam */
  pointer-events: none;
}

.pip-label {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 3;
  background: rgba(0, 0, 0, 0.6);
  padding: 4px 8px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.pip-label i {
  color: var(--theme-primary);
  font-size: 0.45rem;
  animation: pulseBeacon 1.5s infinite ease-in-out;
}

@keyframes pulseBeacon {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Toast Notifications */
.toast {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: rgba(13, 13, 25, 0.9);
  backdrop-filter: blur(10px);
  border: 1.5px solid var(--theme-primary);
  padding: 12px 24px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 15px var(--theme-glow);
  z-index: 1000;
  pointer-events: auto;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(30px);
  pointer-events: none;
}

.toast i {
  color: var(--theme-primary);
  font-size: 1.1rem;
}

.toast span {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Active theme variations */
body[data-theme="solar"] {
  --theme-primary: #ffb703;
  --theme-secondary: #ff4d00;
  --theme-glow: rgba(255, 183, 3, 0.4);
  --theme-glow-secondary: rgba(255, 77, 0, 0.4);
}

body[data-theme="neon"] {
  --theme-primary: #00ff66;
  --theme-secondary: #ff007f;
  --theme-glow: rgba(0, 255, 102, 0.35);
  --theme-glow-secondary: rgba(255, 0, 127, 0.35);
}

body[data-theme="biolume"] {
  --theme-primary: #00f5d4;
  --theme-secondary: #0077b6;
  --theme-glow: rgba(0, 245, 212, 0.4);
  --theme-glow-secondary: rgba(0, 119, 182, 0.4);
}

body[data-theme="rainbow"] {
  --theme-primary: #ff007f;
  --theme-secondary: #00f0ff;
  --theme-glow: rgba(255, 0, 127, 0.3);
  --theme-glow-secondary: rgba(0, 240, 255, 0.3);
}

/* Responsiveness adjustments */
@media (max-width: 768px) {
  .sidebar {
    width: calc(100vw - 40px);
  }
  #cameraPipContainer {
    width: 140px;
    height: 105px;
    bottom: 10px;
    right: 10px;
  }
  .system-stats {
    display: none;
  }
}
