.analyzer-root {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
}

// ── Header ───────────────────────────────────────────────────────────────────

.analyzer-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;

  .header-icon {
    font-size: 2rem;
    width: 2rem;
    height: 2rem;
    color: #558b2f;
  }

  .header-title {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 600;
    color: #1b5e20;
  }

  .mpob-badge {
    margin-left: auto;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
  }
}

// ── Engine selector row ──────────────────────────────────────────────────────

.engine-selector-row {
  display: flex;
  align-items: center;
  gap: 1rem;

  .engine-field {
    width: 280px;
  }

  .engine-status-badge {
    padding: 4px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;

    &.remote {
      background: #e3f2fd;
      color: #1565c0;
      border: 1px solid #90caf9;
    }

    &.local {
      background: #f3e5f5;
      color: #6a1b9a;
      border: 1px solid #ce93d8;
    }

    &.n8n {
      background: #fff8e1;
      color: #e65100;
      border: 1px solid #ffcc02;
    }
  }
}

// ── Input mode toggle ────────────────────────────────────────────────────────

.input-mode-toggle {
  display: flex;
  gap: 0.5rem;

  button {
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    color: #546e7a;

    &.active {
      background: #e8f5e9;
      color: #2e7d32;
      border-color: #a5d6a7;
    }
  }
}

// ── Drop zone ────────────────────────────────────────────────────────────────

.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 220px;
  border: 2px dashed #a5d6a7;
  border-radius: 12px;
  background: #f9fbe7;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;

  &.drag-over {
    border-color: #2e7d32;
    background: #e8f5e9;
  }

  .drop-icon {
    font-size: 3rem;
    width: 3rem;
    height: 3rem;
    color: #81c784;
  }

  .drop-primary {
    margin: 0;
    font-size: 1rem;
    color: #37474f;
    font-weight: 500;
  }

  .drop-secondary {
    margin: 0;
    font-size: 0.85rem;
    color: #90a4ae;
  }

  .loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;

    .loading-label {
      font-size: 0.9rem;
      color: #546e7a;
    }
  }
}

// ── Camera section ───────────────────────────────────────────────────────────

.camera-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border: 2px solid #a5d6a7;
  border-radius: 12px;
  background: #1a1a2e;
  min-height: 200px;
  overflow: hidden;

  .camera-preview {
    display: none;
    width: 100%;
    max-width: 640px;
    border-radius: 8px;

    &.visible {
      display: block;
    }
  }

  .camera-loading {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    border-radius: 10px;

    .loading-label {
      font-size: 0.9rem;
      color: #fff;
    }
  }

  .camera-controls {
    display: flex;
    gap: 0.75rem;
  }
}

// ── Canvas bounding box overlay ──────────────────────────────────────────────

.canvas-container {
  border-radius: 12px;
  overflow: hidden;
  display: none;

  &.has-content {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    width: auto;
    max-width: 100%;
    background-color: transparent;
  }

  .result-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 70vh;
  }
}

// ── Studio workspace vertical stack ──────────────────────────────────────────

.studio-workspace {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

// ── Batch carousel ────────────────────────────────────────────────────────────

.carousel-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.carousel-nav {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: 1.5px solid #a5d6a7;
  border-radius: 50%;
  background: #f9fbe7;
  color: #2e7d32;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;

  &:hover {
    background: #e8f5e9;
    border-color: #2e7d32;
  }
}

.carousel-track {
  flex: 1;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: #a5d6a7 transparent;

  &::-webkit-scrollbar {
    height: 4px;
  }

  &::-webkit-scrollbar-thumb {
    background: #a5d6a7;
    border-radius: 2px;
  }
}

.carousel-card {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1.5px solid #c8e6c9;
  background: #f9fbe7;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 52px;

  &:hover {
    border-color: #81c784;
    background: #e8f5e9;
  }

  &.active {
    border-color: #2e7d32;
    background: #e8f5e9;
  }

  .card-index {
    font-size: 0.82rem;
    font-weight: 700;
    color: #2e7d32;
  }

  .card-meta {
    font-size: 0.65rem;
    color: #607d8b;
    white-space: nowrap;
  }
}

// ── Results panel ────────────────────────────────────────────────────────────

.results-panel {
  border: 1px solid #c8e6c9;
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
}

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: #e8f5e9;
  border-bottom: 1px solid #c8e6c9;

  .results-title {
    font-size: 0.95rem;
    color: #1b5e20;
  }

  .timing-info {
    font-size: 0.78rem;
    color: #607d8b;
  }
}

.results-body {
  display: flex;
  gap: 1.25rem;
  padding: 1.25rem;
}

// ── Detection cards ──────────────────────────────────────────────────────────

.detections-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.detection-card {
  &.health-alert {
    border-left: 4px solid #f44336;
  }

  mat-card-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem !important;
  }

  .grade-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .grade-label {
    flex: 1;
    font-weight: 500;
    font-size: 0.9rem;
  }

  .confidence-value {
    font-size: 0.85rem;
    color: #546e7a;
    font-variant-numeric: tabular-nums;
  }

  .alert-icon {
    font-size: 1.1rem;
    width: 1.1rem;
    height: 1.1rem;
  }
}

.no-detections {
  font-size: 0.9rem;
  color: #90a4ae;
  font-style: italic;
  margin: 0.5rem 0;
}

// ── Industrial summary ───────────────────────────────────────────────────────

.summary-block {
  margin-top: 0.75rem;

  .summary-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #607d8b;
    margin: 0 0 0.4rem;
  }

  .summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
  }

  .summary-chip {
    padding: 2px 10px;
    border-radius: 10px;
    border: 1.5px solid;
    font-size: 0.78rem;
    background: #fafafa;
    color: #37474f;
  }
}
