/* Profile Calibration card styles
 *
 * Rendered inside the outer `.card` helper on element show pages.
 * The outer card supplies its own border/padding; this stylesheet
 * styles the inner per-profile calibration block.
 */

.calibration-card {
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  background: var(--surface-raised, #f9fafb);
}

.calibration-card-summary {
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  font-weight: 600;
  list-style: none;
  /* Override the global summary rule (utilities.css) that paints every
     <summary> with an opaque light background and muted text. The calibration
     summary should blend into its card so it reads correctly on both the light
     Element page and the dark in-tile drawer (where the light box otherwise
     covered the dark card and washed out the stats). */
  background-color: transparent;
  color: inherit;
}

.calibration-card-summary::-webkit-details-marker {
  display: none;
}

.calibration-card-summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  transition: transform 0.15s ease;
}

details[open] > .calibration-card-summary::before {
  transform: rotate(90deg);
}

.calibration-summary-label {
  font-weight: 600;
}

.calibration-summary-stats {
  font-weight: normal;
  color: var(--text-muted, #6b7280);
  font-size: 0.9em;
}

.dirty-indicator {
  font-size: 0.85em;
  color: var(--alert-warning-text, #92400e);
}

.calibration-sliders {
  margin-bottom: 0.75rem;
}

.slider-row {
  display: grid;
  grid-template-columns: 8em 1fr;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.25rem;
}

.slider-row .help-text {
  grid-column: 2 / 3;
  color: var(--text-muted, #6b7280);
  font-size: 0.8em;
}

/* ── Range slider component ─────────────────────────────────────────────── */

/* Single-value slider: track + number input in a flex row */
.range-slider-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Dual-value slider: slider on the left, the two number inputs on the right */
.range-slider-dual-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

/* Track: relative container so the overlaid thumbs and the fill stack on one
   visible bar. The base bar is drawn here (::before); the native input tracks
   are transparent so this bar and the fill show through. */
.range-slider-track {
  position: relative;
  height: 1.5rem;
  min-width: 8rem;
  flex: 1;
}

.range-slider-track::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 5px;
  transform: translateY(-50%);
  background: var(--border, #d1d5db);
  border-radius: 3px;
}

/* Colored fill marking the selected value/range, above the base bar */
.range-slider-fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 5px;
  background: var(--primary-color, #2563eb);
  border-radius: 3px;
  pointer-events: none;
  left: 0%;
  right: 100%;
}

/* Range input(s) overlaid on the track. The element is transparent (only its
   thumb is visible); pointer-events are off here and re-enabled on the thumb so
   both dual handles stay grabbable. */
.range-slider-thumb {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

/* Keep the upper dual thumb above the lower one where they overlap */
.range-slider-upper {
  z-index: 1;
}

.range-slider-thumb::-webkit-slider-runnable-track {
  height: 5px;
  background: transparent;
}

.range-slider-thumb::-moz-range-track {
  height: 5px;
  background: transparent;
}

.range-slider-thumb::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color, #2563eb);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  margin-top: -7px;
  cursor: pointer;
  pointer-events: auto;
}

.range-slider-thumb::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color, #2563eb);
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  pointer-events: auto;
}

/* The whole thumb input is nearly invisible; we restore the thumb knob above.
   We need the actual <input> to be interactive but visually the custom
   track+fill do the heavy lifting. */
.range-slider-thumb:focus::-webkit-slider-thumb {
  outline: 2px solid var(--accent, #3b82f6);
  outline-offset: 2px;
}

/* Editable number input paired with a slider */
.range-slider-number {
  width: 5em;
  text-align: right;
}

/* Dual-mode: two number inputs side by side with a separator */
.range-slider-dual-inputs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.range-band-sep {
  color: var(--text-muted, #6b7280);
}

/* ── Band rows ("Applies to") ────────────────────────────────────────────── */

.calibration-bands {
  margin-bottom: 0.75rem;
}

.calibration-bands-heading {
  font-size: 0.8em;
  color: var(--text-muted, #6b7280);
  margin-bottom: 0.25rem;
}

.calibration-grid {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0.75rem;
}

.calibration-grid th,
.calibration-grid td {
  text-align: right;
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.calibration-grid th:first-child,
.calibration-grid td:first-child {
  text-align: left;
}

.badge-configured {
  color: var(--success-color, #28a745);
}

.badge-nearest-match {
  color: var(--alert-warning-text, #92400e);
}

.calibration-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin: -0.25rem 0 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted, #6b7280);
}

.calibration-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.calibration-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-errors {
  color: var(--danger-color, #dc3545);
  font-size: 0.85em;
  margin-bottom: 0.5rem;
}

.form-errors ul {
  margin: 0;
  padding-left: 1.25rem;
}

.calibration-table-toggle {
  margin-top: 0.75rem;
}

.calibration-table-toggle > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
}

.calibration-card-static-header {
  cursor: default;
}
