/* ============================================
   Geared Head Simulator — Styles
   Dark, cinematic UI for filmmakers
   ============================================ */

:root {
  --bg: #0a0a0f;
  --surface: #141420;
  --surface2: #1a1a2e;
  --border: #2a2a3e;
  --text: #e0e0e8;
  --text-dim: #8888a0;
  --accent: #00ffaa;
  --accent-dim: #00cc88;
  --tilt-color: #ff6644;
  --danger: #ff4466;
  --radius: 8px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', monospace;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ---- */
.app {
  display: grid;
  grid-template-columns: 1fr 320px;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  gap: 0;
}

/* ---- Header ---- */
.header {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header h1 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.header h1 span {
  color: var(--accent);
  font-weight: 700;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text-dim);
  padding: 4px 10px;
  background: var(--surface2);
  border-radius: 20px;
  border: 1px solid var(--border);
  max-width: 400px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-badge.error {
  color: var(--danger);
  border-color: var(--danger);
}

/* ---- Main Viewer Area ---- */
.viewer-area {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  background: #000;
  overflow: hidden;
}

#viewer-container,
#yt-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#yt-container {
  display: none;
  z-index: 2;
}

#yt-container iframe {
  width: 100% !important;
  height: 100% !important;
}

.viewer-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  gap: 16px;
  pointer-events: none;
  z-index: 1;
}

.viewer-placeholder svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
}

.viewer-placeholder p {
  font-size: 15px;
  opacity: 0.5;
}

/* ---- Center Crosshair ---- */
.crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  pointer-events: none;
}

.crosshair-h, .crosshair-v {
  position: absolute;
  background: rgba(255, 255, 255, 0.35);
}

.crosshair-h {
  width: 28px;
  height: 1px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.crosshair-v {
  width: 1px;
  height: 28px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.crosshair-dot {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ---- HUD Overlay ---- */
.hud {
  position: absolute;
  bottom: 16px;
  left: 16px;
  display: flex;
  gap: 16px;
  z-index: 5;
  pointer-events: none;
}

.hud-card {
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 13px;
}

.hud-card .label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.hud-card .value {
  font-size: 18px;
  font-weight: 700;
}

.hud-card.pan .value { color: var(--accent); }
.hud-card.tilt .value { color: var(--tilt-color); }
.hud-card.fps .value { color: var(--text); }

/* ---- Sidebar ---- */
.sidebar {
  grid-column: 2;
  grid-row: 2;
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.sidebar-section {
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 12px;
}

/* ---- Tracking Section ---- */
.tracking-section {
  position: relative;
}

.tracking-section .cam-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
}

.tracking-section.minimized .cam-wrapper {
  display: none;
}

#webcam {
  display: none;
}

#tracking-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.hand-indicators {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.hand-indicator {
  flex: 1;
  text-align: center;
  padding: 6px;
  border-radius: var(--radius);
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: 12px;
  font-family: var(--mono);
  transition: all 0.15s;
}

.hand-indicator.left { color: var(--accent); }
.hand-indicator.right { color: var(--tilt-color); }

.hand-indicator.active.left {
  border-color: var(--accent);
  background: rgba(0, 255, 170, 0.1);
  box-shadow: 0 0 12px rgba(0, 255, 170, 0.15);
}

.hand-indicator.active.right {
  border-color: var(--tilt-color);
  background: rgba(255, 102, 68, 0.1);
  box-shadow: 0 0 12px rgba(255, 102, 68, 0.15);
}

.hand-indicator.coasting.left {
  border-color: var(--accent);
  background: rgba(0, 255, 170, 0.05);
  opacity: 0.5;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

.hand-indicator.coasting.right {
  border-color: var(--tilt-color);
  background: rgba(255, 102, 68, 0.05);
  opacity: 0.5;
  animation: pulse 0.6s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.3; }
  to { opacity: 0.7; }
}

/* ---- Tracking Controls ---- */
.tracking-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--border);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

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

.btn-primary:hover {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(255, 68, 102, 0.15);
}

.btn-small {
  padding: 5px 10px;
  font-size: 12px;
}

/* ---- Source Controls ---- */
.source-select-wrapper {
  margin-bottom: 12px;
}

.webcam-select-wrapper select,
.source-select-wrapper select {
  width: 100%;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238888a0'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.input-row {
  display: flex;
  gap: 6px;
}

.input-row input {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 13px;
  font-family: var(--font);
}

.input-row input::placeholder {
  color: var(--text-dim);
}

.input-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.source-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.source-panel.hidden {
  display: none;
}

.or-divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* ---- Settings ---- */
.setting-row {
  margin-bottom: 12px;
}

.setting-row:last-child {
  margin-bottom: 0;
}

.setting-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 6px;
}

.setting-label .val {
  font-family: var(--mono);
  color: var(--accent);
}

input[type="range"] {
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

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

/* ---- Keyboard Shortcuts ---- */
.shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.shortcut {
  font-size: 11px;
  color: var(--text-dim);
}

.shortcut kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  margin-right: 3px;
}

/* ---- Footer ---- */
.footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
  gap: 8px;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ---- Sample Videos ---- */
.sample-videos {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 8px;
}

.sample-video-btn {
  display: block;
  width: 100%;
  padding: 6px 10px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.sample-video-btn:hover {
  border-color: var(--accent);
  background: rgba(0, 255, 170, 0.05);
}

.sample-label {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 8px;
  margin-bottom: 4px;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 50vh auto auto;
  }

  .sidebar {
    grid-column: 1;
    grid-row: 3;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }

  .footer {
    grid-row: 4;
  }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--surface);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ---- Hidden file input ---- */
#file-input {
  display: none;
}
