/* Styles for the lb_daily_html form of the labelling-performance section.
 *
 * Scoped :where(.lb-daily) on the form's private root class, which adds no
 * specificity. Loaded from anvil.yaml native_deps.head_html, which styles the
 * designer canvas too. Nothing is hidden until JavaScript runs; the two
 * tooltips' `visibility: hidden` is hover state.
 *
 * TWO RULES CARRY A SECOND CLASS. The dependency injects its theme into
 * <head> at runtime, AFTER every head link, so its `.px-input, .px-select
 * { width: 100% }` would win a tie. `.px-select.lb-daily-select` and
 * `.px-input.lb-daily-date-input` win on specificity instead. Missed, the
 * month dropdown and the date box stretch to the card's width.
 *
 * `#lb-daily-chart` is an id selector and beats everything shared whatever the
 * order; it keeps its min-height: 350px, which is the floor the chart's fixed
 * `height: 350` number draws against. Every other selector here is private to
 * this leaf (`.lb-daily-*`, `.lb-tooltip-text`) and ties with nothing.
 */

:where(.lb-daily) .lb-daily-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

:where(.lb-daily) .lb-daily-monthly-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

:where(.lb-daily) .px-select.lb-daily-select {
  min-width: 140px;
  width: auto;
}

:where(.lb-daily) .lb-daily-monthly-display {
  font-family: var(--px-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--px-text-primary);
}

:where(.lb-daily) .lb-daily-divider {
  height: 1px;
  background: var(--px-border);
  margin: 1rem 0;
}

:where(.lb-daily) .lb-daily-subtitle {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--px-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

:where(.lb-daily) .px-input.lb-daily-date-input {
  width: auto;
}

:where(.lb-daily) .lb-daily-btn-tooltip {
  position: relative;
  display: inline-block;
}

:where(.lb-daily) .lb-daily-btn-tooltip .lb-tooltip-text {
  visibility: hidden;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--px-bg-card);
  color: var(--px-text-secondary);
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.7rem;
  font-weight: 400;
  white-space: nowrap;
  box-shadow: var(--px-shadow-md);
  z-index: 10;
  opacity: 0;
  transition: opacity 0.2s;
}

:where(.lb-daily) .lb-daily-btn-tooltip:hover .lb-tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Explainer affordance for "how is this number calculated".
   Same show-on-hover mechanics as .lb-daily-btn-tooltip above, but the
   content is a sentence rather than a label, so it wraps to a readable
   column instead of inheriting that rule's `white-space: nowrap` (which
   would run the definition straight off the side of the card). */
:where(.lb-daily) .lb-daily-info {
  position: relative;
  display: inline-flex;
  align-items: center;
}

:where(.lb-daily) .lb-daily-monthly-kpi {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

:where(.lb-daily) .lb-daily-info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 50%;
  border: 1px solid var(--px-border);
  background: var(--px-bg-deep);
  color: var(--px-text-secondary);
  font-family: var(--px-font);
  font-size: 0.7rem;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  cursor: help;
  user-select: none;
}

:where(.lb-daily) .lb-daily-info-icon:hover,
:where(.lb-daily) .lb-daily-info-icon:focus {
  color: var(--px-text-primary);
  border-color: var(--px-text-muted);
  outline: none;
}

:where(.lb-daily) .lb-daily-info-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  /* Below the icon, not above it: both anchors sit near the top of the
     card, where a bottom-anchored tooltip would open off the card. */
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  max-width: min(30rem, 70vw);
  background: var(--px-bg-card);
  color: var(--px-text-secondary);
  border: 1px solid var(--px-border);
  border-radius: var(--px-radius-sm);
  padding: 0.6rem 0.8rem;
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  box-shadow: var(--px-shadow-md);
  z-index: 20;
  transition: opacity 0.2s;
}

:where(.lb-daily) .lb-daily-info:hover .lb-daily-info-text,
:where(.lb-daily) .lb-daily-info:focus-within .lb-daily-info-text {
  visibility: visible;
  opacity: 1;
}

/* Anchored left for the icon that sits mid-row rather than at the card's
   right edge, so the panel opens into the card instead of past it. */
:where(.lb-daily) .lb-daily-info.is-inline .lb-daily-info-text {
  left: 0;
  right: auto;
}

:where(.lb-daily) .lb-daily-info-formula {
  display: block;
  color: var(--px-text-primary);
  font-weight: 700;
  margin-bottom: 0.35rem;
}

:where(.lb-daily) #lb-daily-chart {
  min-height: 350px;
  margin-top: 1rem;
  position: relative;
}

@media (max-width: 640px) {
  :where(.lb-daily) .lb-daily-monthly-row,
  :where(.lb-daily) .lb-daily-controls {
    flex-direction: column;
    align-items: flex-start;
  }
}
