/* Custom variables matching premium portfolio theme */
:root {
  --bg-color: #0b0f14;
  --panel-bg: rgba(15, 22, 28, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --primary-color: #3da9fc;
  --accent-color: #ffcc00;
  --danger-color: #ff3b30;
  --success-color: #00e676;
  --text-color: #f0f4f8;
  --text-muted: #94a3b8;
  --border-radius: 16px;
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

body {
  margin: 0;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header styling */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(11, 15, 20, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  z-index: 50;
  height: 70px;
  box-sizing: border-box;
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: color 0.2s, transform 0.2s;
}

.back-link:hover {
  color: var(--primary-color);
  transform: translateX(-4px);
}

.app-title {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, #fff 30%, var(--primary-color));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Loading Overlay */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 20, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  gap: 16px;
  backdrop-filter: blur(10px);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(61, 169, 252, 0.2);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s infinite linear;
}

.loading-overlay p {
  font-family: var(--font-title);
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.loading-subtext {
  color: var(--text-muted);
  font-size: 12px;
}

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

/* Main Container Layout */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

.workspace {
  display: flex;
  flex: 1;
  width: 100%;
  height: 100%;
  padding: 24px;
  gap: 24px;
  box-sizing: border-box;
}

@media (max-width: 1024px) {
  .workspace {
    flex-direction: column;
    overflow-y: auto;
  }
}

/* Canvas Display Area */
.canvas-wrapper {
  position: relative;
  flex: 1;
  background: #000;
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  min-height: 400px;
}

#videoElement {
  display: none;
}

#canvasElement {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform: scaleX(-1); /* Mirror camera output */
}

/* On-screen HUD HUD and floating info */
.gesture-indicator {
  position: absolute;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.6);
  padding: 8px 16px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 14px;
  font-weight: 600;
  backdrop-filter: blur(5px);
  z-index: 10;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success-color);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--success-color);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--success-color); }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* Sidebar Controls Panel */
.control-panel {
  width: 360px;
  background: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-sizing: border-box;
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .control-panel {
    width: 100%;
    overflow-y: visible;
  }
}

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

.panel-section h2,
.panel-section h3 {
  font-family: var(--font-title);
  font-size: 16px;
  margin: 0;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Toggles & Options styling */
.options-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-toggle {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
}

.option-toggle input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.toggle-slider {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  margin-right: 12px;
  transition: 0.3s;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

.option-toggle input:checked + .toggle-slider {
  background-color: var(--primary-color);
}

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

.toggle-label {
  color: var(--text-color);
  font-weight: 500;
}

/* Filter selector buttons */
.filter-selector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-color);
}

.filter-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #0b0f14;
}

.panel-tip {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 0 0;
  line-height: 1.4;
}

/* Recording Section styling */
.recording-sec {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
  margin-top: auto;
}

.rec-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  font-family: monospace;
}

.rec-engine {
  background: rgba(61, 169, 252, 0.15);
  color: var(--primary-color);
  padding: 2px 6px;
  border-radius: 4px;
}

.rec-timer {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.rec-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  background-color: var(--danger-color);
  color: white;
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 15px rgba(255, 59, 48, 0.3);
}

.rec-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(255, 59, 48, 0.4);
}

.rec-button:active {
  transform: translateY(0);
}

.rec-icon {
  width: 12px;
  height: 12px;
  background-color: white;
  border-radius: 50%;
  transition: border-radius 0.3s, transform 0.3s;
}

/* Active Recording state styles */
.rec-button.recording {
  background-color: #2a313c;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.rec-button.recording:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.rec-button.recording .rec-icon {
  border-radius: 2px;
  transform: scale(0.9);
  background-color: var(--danger-color);
  animation: rec-blink 1s infinite alternate;
}

@keyframes rec-blink {
  from { opacity: 0.4; }
  to { opacity: 1; }
}

/* Flash feedback effect */
.flash-effect {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease-out;
  z-index: 20;
}

.flash-active {
  opacity: 0.8;
  transition: none;
}

/* Accessible Focus Rings */
a:focus-visible,
button:focus-visible,
.rec-button:focus-visible,
.filter-btn:focus-visible,
input[type="checkbox"]:focus-visible,
.option-toggle input:focus-visible + .toggle-slider {
    outline: 2px solid var(--accent, #6366f1);
    outline-offset: 2px;
}
