/* Copyright (c) 2026 William Chesher */
/* SPDX-License-Identifier: MIT */
/* ml-companion.css - ML companion panel styles */

#ml-companion {
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  overflow-y: auto;
  font-size: 13px;
  height: 100%;
}

#ml-companion.mlc-visible {
  display: flex;
}

/* =========================================================================
 * Consent banner
 * ========================================================================= */

.mlc-consent-banner {
  background: #2a1a1a;
  border: 1px solid #663333;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
}

.mlc-consent-msg {
  color: #e8a0a0;
  margin-bottom: 6px;
}

.mlc-consent-action {
  color: #888;
}

/* =========================================================================
 * Pipeline stage header (absorbed from ml-panel)
 * ========================================================================= */

.mlc-pipeline {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--hover-bg, #e8e8e8);
  border-radius: 8px;
}

html.dark-theme .mlc-pipeline {
  background: #252830;
}

.mlc-stage {
  flex: 1;
  text-align: center;
  padding: 4px 2px;
  border-radius: 6px;
  transition: background 0.2s;
}

.mlc-stage-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #888);
  display: block;
}

.mlc-stage-status {
  font-size: 9px;
  color: var(--text-muted, #999);
  display: block;
  min-height: 12px;
}

.mlc-stage-arrow {
  color: var(--text-muted, #ccc);
  font-size: 11px;
  flex-shrink: 0;
}

/* Stage states */
.mlc-stage-active {
  background: rgba(0, 137, 123, 0.1);
}

.mlc-stage-active .mlc-stage-label {
  color: #00897B;
}

html.dark-theme .mlc-stage-active .mlc-stage-label {
  color: #26a69a;
}

.mlc-stage-done .mlc-stage-label {
  color: #00897B;
}

html.dark-theme .mlc-stage-done .mlc-stage-label {
  color: #26a69a;
}

.mlc-stage-error .mlc-stage-label {
  color: #e53e3e;
}

/* =========================================================================
 * Sections
 * ========================================================================= */

.mlc-section {
  background: var(--hover-bg, #e8e8e8);
  border-radius: 8px;
  padding: 10px 12px;
}

html.dark-theme .mlc-section {
  background: #252830;
}

.mlc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.mlc-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted, #888);
}

.mlc-section-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.mlc-badge-idle {
  background: var(--hover-bg, #ddd);
  color: var(--text-muted, #888);
}

html.dark-theme .mlc-badge-idle {
  background: #333;
}

.mlc-badge-active {
  background: rgba(0, 137, 123, 0.15);
  color: #00897B;
}

html.dark-theme .mlc-badge-active {
  color: #26a69a;
}

.mlc-badge-done {
  background: rgba(0, 137, 123, 0.12);
  color: #00897B;
  font-weight: 600;
}

html.dark-theme .mlc-badge-done {
  color: #26a69a;
}

.mlc-badge-error {
  background: rgba(229, 62, 62, 0.12);
  color: #e53e3e;
}

.mlc-empty {
  color: var(--text-muted, #999);
  font-size: 12px;
  font-style: italic;
  padding: 4px 0;
}

/* Contextual hints -- guide, not just report */
.mlc-hint {
  font-size: 12px;
  color: var(--text-muted, #999);
  line-height: 1.4;
  padding: 2px 0 6px;
}

/* =========================================================================
 * DATA section - class list
 * ========================================================================= */

.mlc-classes {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mlc-class-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--card-bg, #fff);
}

html.dark-theme .mlc-class-row {
  background: #1a1d23;
}

.mlc-class-name {
  font-weight: 500;
  font-size: 13px;
}

.mlc-class-count {
  font-size: 12px;
  color: var(--text-muted, #888);
  font-variant-numeric: tabular-nums;
  min-width: 24px;
  text-align: right;
}

/* Recording status */
.mlc-record-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 6px 10px;
  background: rgba(229, 62, 62, 0.08);
  border-radius: 6px;
  font-size: 12px;
  color: #e53e3e;
}

.mlc-rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e53e3e;
  animation: mlc-rec-pulse 1s ease infinite;
}

@keyframes mlc-rec-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Spectrogram canvas */
#mlc-spectrogram {
  width: 100%;
  height: 80px;
  border-radius: 6px;
  margin-top: 8px;
  background: #1a1d23;
}

/* =========================================================================
 * MODEL section
 * ========================================================================= */

.mlc-model-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mlc-model-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
}

.mlc-model-label {
  color: var(--text-muted, #888);
}

.mlc-model-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Training progress bar */
.mlc-progress-bar {
  height: 4px;
  background: var(--border-color, #ddd);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

html.dark-theme .mlc-progress-bar {
  background: #333;
}

.mlc-progress-fill {
  height: 100%;
  width: 0%;
  background: #00897B;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.mlc-train-pct {
  font-size: 11px;
  color: #00897B;
  text-align: center;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* =========================================================================
 * LIVE section - confidence bars
 * ========================================================================= */

.mlc-bars {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mlc-bar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s;
}

.mlc-bar-row.mlc-bar-below {
  opacity: 0.4;
}

.mlc-bar-row.mlc-bar-active {
  transition: none;
}

.mlc-bar-label {
  font-size: 12px;
  font-weight: 500;
  min-width: 60px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mlc-bar-track {
  flex: 1;
  height: 12px;
  background: var(--border-color, #ddd);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

/* Threshold marker on each bar track */
.mlc-bar-track::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 1px;
  left: var(--mlc-threshold-pct, 70%);
  pointer-events: none;
  transition: left 0.15s ease;
  z-index: 1;
}

html.dark-theme .mlc-bar-track::after {
  background: rgba(255, 255, 255, 0.3);
}

html.dark-theme .mlc-bar-track {
  background: #333;
}

.mlc-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 6px;
  transition: width 0.25s ease;
  background: #00897B;
}

.mlc-bar-above .mlc-bar-fill {
  background: #00897B;
}

.mlc-bar-below .mlc-bar-fill {
  background: #666;
}

.mlc-bar-value {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 32px;
  text-align: right;
  color: var(--text-muted, #888);
}

.mlc-bar-above .mlc-bar-value {
  color: #00897B;
}

/* Live indicator */
.mlc-live-indicator {
  font-size: 11px;
  color: #00897B;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mlc-pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00897B;
  animation: mlc-pulse 1.5s ease infinite;
}

@keyframes mlc-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Threshold slider */
.mlc-threshold {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color, #e0e0e0);
}

html.dark-theme .mlc-threshold {
  border-top-color: #333;
}

.mlc-threshold-label {
  font-size: 11px;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

.mlc-slider {
  flex: 1;
  height: 4px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color, #ddd);
  border-radius: 2px;
  outline: none;
}

html.dark-theme .mlc-slider {
  background: #444;
}

.mlc-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00897B;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mlc-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #00897B;
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.mlc-threshold-value {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #00897B;
  min-width: 32px;
  text-align: right;
}

/* Hit rate */
.mlc-hit-rate {
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-top: 6px;
  text-align: center;
}

/* Commit button */
.mlc-commit-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 6px;
  background: #00897B;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.mlc-commit-btn:hover {
  background: #00796B;
}

/* Assessment history dots */
.mlc-history {
  display: flex;
  gap: 3px;
  margin-top: 8px;
  justify-content: center;
  min-height: 12px;
}

.mlc-history-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: background 0.2s;
}

.mlc-dot-above {
  background: #00897B;
}

.mlc-dot-below {
  background: #555;
}

html.dark-theme .mlc-dot-below {
  background: #444;
}

/* =========================================================================
 * Celebration -- training complete
 * ========================================================================= */

.mlc-celebrate {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(0, 137, 123, 0.1);
  border: 1px solid rgba(0, 137, 123, 0.25);
  text-align: center;
}

.mlc-celebrate-text {
  font-size: 13px;
  font-weight: 600;
  color: #00897B;
}

html.dark-theme .mlc-celebrate-text {
  color: #26a69a;
}

.mlc-celebrate-pop {
  animation: mlc-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes mlc-pop {
  0% { transform: scale(0.9); opacity: 0.5; }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); opacity: 1; }
}

/* =========================================================================
 * Detected class callout -- the "it works" moment
 * ========================================================================= */

.mlc-detected {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: background 0.2s, border-color 0.2s;
}

.mlc-detected-strong {
  background: rgba(0, 137, 123, 0.12);
  border: 1px solid rgba(0, 137, 123, 0.3);
}

.mlc-detected-weak {
  background: var(--hover-bg, #e8e8e8);
  border: 1px solid transparent;
  opacity: 0.6;
}

html.dark-theme .mlc-detected-weak {
  background: #2a2d35;
}

.mlc-detected-label {
  font-size: 18px;
  font-weight: 700;
  color: #00897B;
  letter-spacing: -0.3px;
}

html.dark-theme .mlc-detected-label {
  color: #26a69a;
}

.mlc-detected-weak .mlc-detected-label {
  color: var(--text-muted, #888);
}

.mlc-detected-conf {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: #00897B;
}

.mlc-detected-weak .mlc-detected-conf {
  color: var(--text-muted, #888);
}

.mlc-detected-pulse {
  animation: mlc-detect-pulse 0.3s ease;
}

@keyframes mlc-detect-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.02); box-shadow: 0 0 12px rgba(0, 137, 123, 0.3); }
  100% { transform: scale(1); box-shadow: none; }
}

.mlc-detected-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* =========================================================================
 * Correction flow (Phase 5)
 * ========================================================================= */

.mlc-correct {
  margin-top: 6px;
}

.mlc-correct-link {
  font-size: 12px;
  color: var(--text-muted, #888);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.mlc-correct-link:hover {
  color: #00897B;
}

.mlc-correct-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.mlc-correct-prompt {
  font-size: 12px;
  color: var(--text-muted, #888);
  flex-shrink: 0;
}

.mlc-correct-select {
  flex: 1;
  font-size: 12px;
  padding: 3px 6px;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 4px;
  background: var(--card-bg, #fff);
  color: inherit;
  min-width: 0;
}

html.dark-theme .mlc-correct-select {
  background: #1a1d23;
  border-color: #444;
}

.mlc-correct-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border: none;
  border-radius: 4px;
  background: #00897B;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
}

.mlc-correct-btn:hover {
  background: #00796B;
}

.mlc-correct-cancel {
  font-size: 12px;
  background: none;
  border: none;
  color: var(--text-muted, #888);
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

.mlc-correct-confirm {
  font-size: 12px;
  color: #00897B;
  font-weight: 500;
  margin-top: 4px;
}

/* =========================================================================
 * Tutor section (absorbed from ml-panel)
 * ========================================================================= */

.mlc-tutor {
  margin-top: 8px;
  padding: 8px 0 0;
  border-top: 1px solid var(--border-color, #e0e0e0);
}

html.dark-theme .mlc-tutor {
  border-top-color: #333;
}

.mlc-tutor-suggestion {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-primary, #333);
  min-height: 16px;
  margin-bottom: 6px;
}

html.dark-theme .mlc-tutor-suggestion {
  color: #ddd;
}

.mlc-tutor-replies {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.mlc-tutor-reply {
  background: rgba(0, 137, 123, 0.08);
  border: 1px solid rgba(0, 137, 123, 0.3);
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 11px;
  cursor: pointer;
  color: #00897B;
  transition: background 0.2s;
}

.mlc-tutor-reply:hover {
  background: rgba(0, 137, 123, 0.15);
}

html.dark-theme .mlc-tutor-reply {
  background: rgba(38, 166, 154, 0.1);
  border-color: rgba(38, 166, 154, 0.3);
  color: #26a69a;
}

.mlc-tutor-btn {
  background: #00897B;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.mlc-tutor-btn:hover {
  background: #00796B;
}

.mlc-tutor-btn:disabled {
  background: #999;
  cursor: wait;
}

/* =========================================================================
 * Cancel training link
 * ========================================================================= */

.mlc-cancel-train {
  display: block;
  font-size: 11px;
  color: var(--text-muted, #888);
  text-align: center;
  margin-top: 4px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.mlc-cancel-train:hover {
  color: #e53e3e;
}

/* =========================================================================
 * Undo correction link
 * ========================================================================= */

.mlc-reset-row {
  text-align: center;
  margin-top: 6px;
}

.mlc-reset-link {
  display: inline;
  font-size: 11px;
  color: var(--text-muted, #888);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.mlc-reset-link:hover {
  color: #e53e3e;
}

.mlc-undo-link {
  display: block;
  font-size: 11px;
  color: var(--text-muted, #888);
  margin-top: 4px;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
  animation: mlc-undo-fade 5s ease forwards;
}

.mlc-undo-link:hover {
  color: #00897B;
}

@keyframes mlc-undo-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0.3; }
}

/* =========================================================================
 * Model comparison
 * ========================================================================= */

.mlc-model-comparison {
  font-size: 12px;
  color: var(--text-muted, #888);
  margin-top: 6px;
  padding: 4px 0;
}

.mlc-comparison-text {
  font-variant-numeric: tabular-nums;
}

.mlc-delta-positive {
  color: #00897B;
  font-weight: 600;
}

html.dark-theme .mlc-delta-positive {
  color: #26a69a;
}

.mlc-delta-negative {
  color: #e53e3e;
  font-weight: 600;
}

/* =========================================================================
 * Progressive disclosure tiers (Phase 6a)
 * ========================================================================= */

/* Beginner: only class names, model status, detected class, correction */
.mlc-tier-beginner #mlc-spectrogram,
.mlc-tier-beginner .mlc-model-row,
.mlc-tier-beginner .mlc-train-pct,
.mlc-tier-beginner .mlc-bars,
.mlc-tier-beginner .mlc-threshold,
.mlc-tier-beginner .mlc-commit-btn,
.mlc-tier-beginner .mlc-hit-rate,
.mlc-tier-beginner .mlc-history { display: none !important; }

/* Intermediate: hide hit rate and history dots */
.mlc-tier-intermediate .mlc-hit-rate,
.mlc-tier-intermediate .mlc-history { display: none !important; }

/* Advanced: everything visible (no overrides needed) */
