@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Space+Grotesk:wght@400;700&display=swap");

:root {
  /* Background colors */
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-tertiary: #0d0d14;
  --bg-black: #000;

  /* Border Surface colors */
  --border-primary: #1a1a2e;
  --border-secondary: #2a2a4e;

  /* Text colors */
  --text-primary: #e0e0e0;
  --text-muted: #666;

  /* Accent colors */
  --accent-cyan: #00f5d4;
  --accent-cyan-dark: #00c4a7;
  --accent-purple: #7b2cbf;
  --accent-pink: #f72585;
}

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

body {
  font-family: "Space Grotesk", sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

.main-content {
  display: flex;
  gap: 2rem;
  justify-content: center;
  align-items: flex-start;
  flex-direction: column-reverse;
}

.video-section {
  flex: 1;
  min-width: 640px;
  max-width: 1280px;
  position: relative;
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-primary);
  display: none;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg-black);
}

#webcam {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: none;
}

#canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.controls {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-primary);
}

button {
  flex: 1;
  padding: 0.875rem 1.5rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

#startBtn {
  background: linear-gradient(
    135deg,
    var(--accent-cyan),
    var(--accent-cyan-dark)
  );
  color: var(--bg-primary);
}

#startBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 245, 212, 0.3);
}

#startBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

#stopBtn {
  background: var(--border-primary);
  color: var(--text-primary);
  border: 1px solid var(--border-secondary);
}

#stopBtn:hover:not(:disabled) {
  background: var(--border-secondary);
}

#stopBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 15, 0.95);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 1.5rem;
  z-index: 10;
}

.loading-overlay.hidden {
  display: none;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-primary);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-text {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.no-detection {
  color: var(--text-muted);
  font-style: italic;
}

.unity-section {
  flex: 1;
  width: 100%;
  position: relative;
  background: var(--bg-secondary);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border-primary);
}

#unity-container {
  position: relative;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
  background: var(--bg-tertiary);
}

#unity-canvas {
  display: block;
  border-radius: 8px;
  background: #000;
}

#unity-loading-bar {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 200px;
  display: none;
}

#unity-logo {
  width: 154px;
  height: 130px;
  background: url("balloonPop/TemplateData/unity-logo-dark.png") no-repeat
    center;
  background-size: contain;
  margin: 0 auto 1rem;
}

#unity-progress-bar-empty {
  width: 100%;
  height: 18px;
  background: var(--border-primary);
  border-radius: 9px;
  overflow: hidden;
}

#unity-progress-bar-full {
  width: 0%;
  height: 100%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 9px;
  transition: width 0.3s ease;
}

#unity-warning {
  margin-top: 1rem;
  width: 100%;
}

#unity-warning div {
  padding: 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.toggle-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  margin-bottom: 2rem;
  width: fit-content;
  position: absolute;
  left: 167px;
  top: 60px;
  z-index: 10;
  flex-direction: column-reverse;
}

.toggle-label {
  font-size: 0.9rem;
  color: var(--text-primary);
  font-weight: 600;
  user-select: none;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

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

.toggle-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border-primary);
  border-radius: 26px;
  transition: all 0.3s ease;
  border: 2px solid var(--border-secondary);
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all 0.3s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-cyan-dark));
  border-color: var(--accent-cyan);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
  background: var(--bg-primary);
}

.toggle-switch:hover .toggle-slider {
  border-color: var(--accent-cyan);
}

/* Responsive adjustments */
@media (max-width: 1400px) {
  .main-content {
    flex-direction: column;
    align-items: center;
  }

  .video-section,
  .unity-section {
    width: 100%;
    max-width: 1280px;
  }
}
