/*
 * Flavour-profile bars + override panel + admin coverage.
 * Plan: docs/plans/flavour-fingerprint-pairing-frontend.md §8.
 *
 * Uses ONLY existing CSS variables from themes.css — no new tokens.
 * Mobile-first base styles; @media min-width:481px opens up inline label+bar.
 */

/* ============================================================================
   Section header (collapsible) — pattern matches .wine-profile-section
   ============================================================================ */

.flavor-profile-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.flavor-profile-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0.5rem 0;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.flavor-profile-toggle:hover {
  color: var(--accent);
}

.flavor-profile-chevron {
  font-size: 0.75rem;
  margin-left: 0.5rem;
  transition: transform 120ms ease;
}

.flavor-profile-body {
  padding: 0.5rem 0 0.25rem;
}

/* ============================================================================
   Bars
   ============================================================================ */

.flavor-profile__bars {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
}

.flavor-profile__row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: var(--space-xs);
  min-height: 32px;
}

@media (min-width: 481px) {
  .flavor-profile__row {
    grid-template-columns: 6.5rem 1fr 1.5rem;
    gap: var(--space-md);
  }
}

.flavor-profile__bar-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  cursor: help;
}

.flavor-profile__bar-track {
  height: 0.5rem;
  background: var(--bg-slot);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.flavor-profile__bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 200ms ease;
}

/* Discrete width per integer 0..5 — no inline style.setProperty (audit-r1/M4). */
.flavor-profile__bar-fill[data-value="0"] { width: 4%; opacity: 0.4; } /* visible nub */
.flavor-profile__bar-fill[data-value="1"] { width: 20%; }
.flavor-profile__bar-fill[data-value="2"] { width: 40%; }
.flavor-profile__bar-fill[data-value="3"] { width: 60%; }
.flavor-profile__bar-fill[data-value="4"] { width: 80%; }
.flavor-profile__bar-fill[data-value="5"] { width: 100%; }

.flavor-profile__bar-value {
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  text-align: right;
  min-width: 1.5rem;
}

/* Compact variant — used by wine-add toast preview */
.flavor-profile__bars--compact .flavor-profile__row {
  min-height: 24px;
}
.flavor-profile__bars--compact .flavor-profile__bar-track {
  height: 0.35rem;
}

@media (prefers-reduced-motion: reduce) {
  .flavor-profile__bar-fill,
  .flavor-profile-chevron {
    transition: none;
  }
}

/* ============================================================================
   Footer (confidence + source + actions)
   ============================================================================ */

.flavor-profile__footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.flavor-profile__confidence {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  background: transparent;
  color: inherit;
}

.flavor-profile__confidence--medium {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.flavor-profile__confidence--low {
  background: var(--color-warning-bg);
  color: var(--color-warning-muted);
  border: 1px solid var(--color-warning);
}

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

.flavor-profile__actions {
  display: flex;
  gap: var(--space-sm);
  margin-left: auto;
}

.flavor-profile__re-extract,
.flavor-profile__edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  min-height: 32px;
  cursor: pointer;
}

.flavor-profile__re-extract:hover,
.flavor-profile__edit-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.flavor-profile__re-extract:disabled,
.flavor-profile__edit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================================
   Loading / re-extracting overlay
   ============================================================================ */

.flavor-profile__bars--loading {
  position: relative;
  opacity: 0.6;
  pointer-events: none;
}

.flavor-profile__loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ============================================================================
   Override subpanel — sliders replace bars in-place
   ============================================================================ */

.flavor-profile__editor {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.flavor-profile__slider-row {
  display: grid;
  grid-template-columns: 6.5rem 1fr 1.5rem;
  align-items: center;
  gap: var(--space-md);
}

@media (max-width: 480px) {
  .flavor-profile__slider-row {
    grid-template-columns: 1fr;
  }
}

.flavor-profile__editor input[type="range"] {
  width: 100%;
}

.flavor-profile__editor-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: 0.75rem;
}

/* ============================================================================
   Pairing Lab dish-axis anchor row
   ============================================================================ */

.flavor-profile__dish-anchor {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.8rem;
  background: var(--bg-slot);
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
}

.flavor-profile__dish-anchor-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.flavor-profile__dish-anchor-chip {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
}

/* ============================================================================
   Pair-card "Why?" axis-details expander
   ============================================================================ */

.wine-pair-card details.wine-pair-axes {
  margin-top: 0.5rem;
}

.wine-pair-card details.wine-pair-axes > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  list-style: none;
  user-select: none;
}

.wine-pair-card details.wine-pair-axes > summary::-webkit-details-marker { display: none; }

.wine-pair-card details.wine-pair-axes[open] > summary {
  color: var(--accent);
}

.wine-pair-axes__grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 0.75rem;
  margin-top: 0.4rem;
  font-size: 0.85rem;
}

.wine-pair-axes__row {
  display: contents;
}

.wine-pair-axes__label { color: var(--text); font-weight: 500; }
.wine-pair-axes__values { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.wine-pair-axes__status--match    { color: var(--color-success); }
.wine-pair-axes__status--close    { color: var(--text-muted); }
.wine-pair-axes__status--penalty  { color: var(--color-error); }

/* ============================================================================
   Settings — flavour profile coverage panel
   ============================================================================ */

.flavor-profile-panel__coverage {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: 1rem;
}

.flavor-profile-panel__coverage-bar {
  display: flex;
  height: 0.6rem;
  background: var(--bg-slot);
  border-radius: 999px;
  overflow: hidden;
}

.flavor-profile-panel__coverage-segment {
  height: 100%;
}

.flavor-profile-panel__coverage-segment--ai      { background: var(--color-success); }
.flavor-profile-panel__coverage-segment--grape   { background: var(--color-warning); }
.flavor-profile-panel__coverage-segment--manual  { background: var(--color-info); }
.flavor-profile-panel__coverage-segment--missing { background: var(--color-error); }

.flavor-profile-panel__low-confidence {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
}

.flavor-profile-panel__low-confidence-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
}

.flavor-profile-panel__low-confidence-row:last-child {
  border-bottom: 0;
}

.flavor-profile-panel__low-confidence-name {
  flex: 1;
  font-size: 0.9rem;
}

.flavor-profile-panel__progress {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Dish-fingerprint backfill panel — plan §6.10 */
.dish-fp-backfill-panel {
  font-size: 0.9rem;
}
.dish-fp-backfill-panel__loading {
  color: var(--text-muted);
  padding: 0.5rem 0;
}
.dish-fp-backfill-panel__overall {
  margin-bottom: 0.75rem;
}
.dish-fp-backfill-panel__overall h4 {
  margin: 0 0 0.25rem;
}
.dish-fp-backfill-panel__hint {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 0.5rem;
}
.dish-fp-backfill-panel__overall-coverage {
  font-weight: 500;
}
.dish-fp-backfill-panel__bars {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: 0.75rem;
}
.dish-fp-backfill-panel__bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 0.2rem;
}
.dish-fp-backfill-panel__bar-track {
  height: 8px;
  background: var(--surface-subtle, rgba(0, 0, 0, 0.08));
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.dish-fp-backfill-panel__bar-fill {
  height: 100%;
  background: var(--accent, #6c5ce7);
  transition: width 200ms ease;
}
.dish-fp-backfill-panel__pending {
  color: var(--text);
  margin: 0.5rem 0;
}
.dish-fp-backfill-panel__complete {
  color: var(--color-success, #2e7d32);
  font-weight: 600;
}
.dish-fp-backfill-panel__skipped {
  color: var(--text-muted);
  font-size: 0.8rem;
}
.dish-fp-backfill-panel__progress {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}
.dish-fp-backfill-panel__run {
  margin-top: 0.5rem;
  padding: 0.45rem 0.9rem;
  background: var(--accent, #6c5ce7);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
}
.dish-fp-backfill-panel__run:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
