/* =========================
   Base Reset
========================= */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Ubuntu', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f8fafc; /* slate-50 */
  min-height: 100vh;
  padding: 20px;
  color: #1e293b; /* slate-800 */
}


button,
input,
select,
textarea {
  font-family: inherit;
}

/* =========================
   Layout
========================= */
.container {
  max-width: 1200px;
  margin: auto;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

/* =========================
   Header
========================= */
.header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  padding: 40px 24px;
  text-align: center;
}

.header h1 {
  font-size: 2.25rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 1rem;
  color: #64748b;
}

/* =========================
   Mode Selector (Tabs)
========================= */
.mode-selector {
  display: flex;
  gap: 8px;
  padding: 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.mode-btn {
  flex: 1;
  padding: 12px 0;
  font-size: 0.95rem;
  font-weight: 500;
  background: transparent;
  color: #475569;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.mode-btn:hover {
  background: #e2e8f0;
}

.mode-btn.active {
  background: #1e293b;
  color: #ffffff;
}

/* =========================
   Content
========================= */
.content {
  padding: 28px;
}

.mode-content {
  display: none;
}

.mode-content.active {
  display: block;
}

/* =========================
   Camera
========================= */
.video-container {
  position: relative;
  max-width: 820px;
  margin: 0 auto 20px;
  background: #000;
  border-radius: 12px;
  aspect-ratio: 4 / 3;
  border: 1px solid #e2e8f0;
}

#videoElement,
#videoCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

#videoCanvas {
  pointer-events: none;
}

.camera-controls {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 12px;
}

.status-message {
  text-align: center;
  font-size: 0.9rem;
  margin-top: 10px;
  color: #475569;
}

.status-message.success {
  color: #15803d;
}

.status-message.error {
  color: #b91c1c;
}

/* =========================
   Buttons
========================= */
.btn {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary {
  background: #1e293b;
  color: #ffffff;
}

.btn-primary:hover {
  background: #0f172a;
}

.btn-secondary {
  background: #475569;
  color: #ffffff;
}

.btn-secondary:hover {
  background: #334155;
}

.btn-success {
  background: #15803d;
  color: #ffffff;
}

.btn-success:hover {
  background: #166534;
}

/* =========================
   Upload
========================= */
.drop-zone {
  border: 2px dashed #cbd5f5;
  border-radius: 12px;
  padding: 70px 20px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
}

.drop-zone.drag-over {
  background: #eef2ff;
  border-color: #6366f1;
}

.drop-text {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.or-text {
  color: #64748b;
  margin: 16px 0;
}

.file-info {
  font-size: 0.8rem;
  color: #94a3b8;
}

.image-preview {
  display: none;
  margin-top: 20px;
  text-align: center;
}

.image-preview.active {
  display: block;
}

#uploadCanvas {
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
}

/* =========================
   Controls Panel
========================= */
.controls-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
  margin: 24px 0;
}

.control-group label {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 6px;
  display: block;
}

/* =========================
   Results
========================= */
.results-container {
  margin-top: 24px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  background: #ffffff;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat-card {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 18px;
  text-align: center;
}

.stat-value {
  font-size: 2rem;
  font-weight: 600;
  color: #1e293b;
}

.stat-label {
  font-size: 0.85rem;
  color: #64748b;
}

/* =========================
   Detections
========================= */
.detection-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: #f8fafc;
  border-left: 3px solid #1e293b;
  border-radius: 8px;
  margin-bottom: 8px;
}

.detection-confidence {
  font-weight: 600;
  color: #15803d;
}

/* =========================
   Loading / Error
========================= */
.loading-indicator {
  text-align: center;
  padding: 32px;
  color: #64748b;
}

.error-message {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 16px;
  border-radius: 10px;
  margin-top: 20px;
}

/* =========================
   Footer
========================= */
.footer {
  text-align: center;
  font-size: 0.85rem;
  padding: 20px;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
}

/* =========================
   Responsive
========================= */
@media (max-width: 768px) {
  .content {
    padding: 20px;
  }

  .camera-controls {
    flex-direction: column;
  }

  .btn {
    width: 100%;
  }
}
