/* YOYO AI CAMERA V0 — FOUNDER TEST LAB STYLES */

:root {
  --bg-main: #0c0f14;
  --bg-card: #151a21;
  --bg-card-subtle: #1c232d;
  --border-color: #273140;
  --border-focus: #3b82f6;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-red: #ef4444;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.5;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

.lab-container {
  width: 100%;
  max-width: 1240px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.lab-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.badge-v0 {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.05em;
}

.lab-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Technical Status Grid */
.status-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 16px;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.status-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-item .label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-item .value {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  font-variant-numeric: tabular-nums;
  word-break: break-all;
}

.status-item .value.healthy {
  color: var(--accent-green);
}

.status-item .value.warning {
  color: var(--accent-amber);
}

.status-item .value.error {
  color: var(--accent-red);
}

/* Controls Card */
.controls-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.group-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-right: 4px;
}

.btn {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-blue-hover);
}

.btn-secondary {
  background: #334155;
  color: #f8fafc;
}

.btn-secondary:hover:not(:disabled) {
  background: #475569;
}

.btn-outline {
  background: transparent;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover:not(:disabled) {
  background: var(--bg-card-subtle);
  border-color: #475569;
}

.btn-danger {
  background: #7f1d1d;
  border-color: #991b1b;
  color: #fee2e2;
}

.btn-danger:hover:not(:disabled) {
  background: #991b1b;
}

.btn-tab {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 12px;
  font-size: 0.78rem;
}

.btn-tab.active {
  background: #1e293b;
  border-color: var(--accent-blue);
  color: #38bdf8;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

/* Viewports Section */
.viewports-section {
  width: 100%;
}

.viewports-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

.viewport-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viewport-header {
  padding: 10px 14px;
  background: var(--bg-card-subtle);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.03em;
}

.badge-raw {
  background: #334155;
  color: #cbd5e1;
}

.badge-enhanced {
  background: linear-gradient(135deg, #059669, #0d9488);
  color: #ffffff;
}

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

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrapper video,
.video-wrapper canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-muted);
  gap: 8px;
  font-size: 0.85rem;
}

.ph-icon {
  font-size: 2rem;
  opacity: 0.6;
}

.fallback-overlay {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  background: rgba(153, 27, 27, 0.9);
  border: 1px solid #ef4444;
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 10;
  backdrop-filter: blur(4px);
}

.warn-badge {
  background: #ef4444;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

.fallback-overlay p {
  font-size: 0.8rem;
  color: #fecaca;
  margin: 0;
}

/* Interactive Split Slider Mode */
.split-slider-container {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  padding: 8px;
}

.split-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  overflow: hidden;
  border-radius: var(--radius-sm);
}

.split-raw-layer,
.split-enhanced-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.split-raw-layer video,
.split-enhanced-layer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.split-enhanced-layer {
  clip-path: polygon(50% 0%, 100% 0%, 100% 100%, 50% 100%);
}

.split-badge {
  position: absolute;
  top: 12px;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 5;
}

.split-badge.left {
  left: 12px;
  color: #cbd5e1;
}

.split-badge.right {
  right: 12px;
  color: #34d399;
}

.split-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  z-index: 6;
  transform: translateX(-50%);
}

.divider-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  color: #0f172a;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 4px 6px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.split-range {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: ew-resize;
  z-index: 7;
}

/* Calibration Section */
.calibration-section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.section-title-row h3 {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.section-note {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sliders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.slider-box {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.slider-header label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.slider-header .val {
  font-size: 0.85rem;
  font-weight: 700;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

.slider-box input[type="range"] {
  width: 100%;
  accent-color: var(--accent-blue);
  cursor: pointer;
}

.slider-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* Locked Rules */
.locked-rules-card {
  background: #0f172a;
  border: 1px dashed #334155;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.locked-rules-card h4 {
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  letter-spacing: 0.04em;
}

.rules-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rule-tag {
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid transparent;
}

.rule-tag.locked-true {
  background: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.rule-tag.locked-false {
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

/* Footer & Privacy */
.lab-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.privacy-note p {
  margin: 0;
  line-height: 1.4;
}

.privacy-note strong {
  color: var(--text-main);
}

.footer-meta {
  font-size: 0.72rem;
  color: #64748b;
  text-align: center;
}

/* AI Mode Section & Telemetry Panel */
.ai-mode-section {
  display: flex;
  flex-direction: column;
}

.mode-toggle-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mode-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.mode-header h3 {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.mode-buttons {
  display: flex;
  gap: 8px;
}

.btn-mode {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-mode.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.25), rgba(59, 130, 246, 0.15));
  border-color: var(--border-focus);
  color: #60a5fa;
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
}

.ai-telemetry-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.telemetry-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.t-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.03em;
}

.t-val {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e2e8f0;
}

.t-val.healthy {
  color: #34d399;
}

.slider-box.highlight-box {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.rules-clarification {
  margin-top: 10px;
  font-size: 0.78rem;
  color: #94a3b8;
  line-height: 1.5;
}

/* =========================================================================
   RESPONSIVE DESIGN (Mobile 390px / Portrait adaptation)
   ========================================================================= */

@media (max-width: 768px) {
  body {
    padding: 8px;
  }

  .lab-container {
    gap: 10px;
  }

  .viewports-grid {
    grid-template-columns: 1fr; /* Stack vertically on mobile */
    gap: 10px;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .btn {
    font-size: 0.78rem;
    padding: 7px 10px;
  }

  .sliders-grid {
    grid-template-columns: 1fr;
  }

  .lab-header h1 {
    font-size: 1.15rem;
  }
}

