/* Price-history chart (producto.html).
   Series colours are the validated categorical slots — fixed order, one slot
   per store, never cycled. Everything else (surface, controls, ink) is the
   site's own palette. */

.price-chart {
  --pc-surface: #fff;
  --pc-border: rgba(11, 11, 11, 0.1);
  --pc-grid: #E7EBE9;
  --pc-ink: #19352D;
  --pc-ink-muted: #7C8D87;
  --pc-green: #29594B;
  --pc-lime: #CFFF45;
  --pc-chip: #F6F8F7;

  /* Categorical slots 1–6, fixed order, one per store, never cycled. Red and
     green are kept out of the first five (the five stores in the table): this
     page already spends them on price meaning — mínimo/máximo and the 7-day
     trend badge — so a green line would read as "barato" rather than as a
     store. Validated on white: worst adjacent CVD ΔE 13.2, normal-vision
     ΔE 19.3, every slot ≥ 3:1. Re-run the check before touching a value. */
  --pc-series-1: #eb6834; /* naranja  */
  --pc-series-2: #2a78d6; /* azul     */
  --pc-series-3: #c98500; /* ambar    */
  --pc-series-4: #d55181; /* magenta  */
  --pc-series-5: #4a3aa7; /* violeta  */
  --pc-series-6: #199e70; /* verde azulado — solo si aparece una 6a tienda */

  padding: 24px;
  border: 1px solid var(--pc-border);
  border-radius: 16px;
  background: var(--pc-surface);
  font-family: "Satoshi", sans-serif;
}

/* --- Controls: one row above the plot ------------------------------------ */
.price-chart__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.price-chart__ranges {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 30px;
  background: var(--pc-chip);
}

.price-chart__range {
  padding: 7px 16px;
  border: none;
  border-radius: 30px;
  background: transparent;
  color: var(--pc-ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.2s ease-in-out 0s, color 0.2s ease-in-out 0s;
}

.price-chart__range:hover {
  background: rgba(41, 89, 75, 0.1);
}

.price-chart__range[aria-pressed="true"] {
  background: var(--pc-green);
  color: #fff;
}

.price-chart__range[disabled] {
  opacity: 0.35;
  cursor: default;
}

.price-chart__range[disabled]:hover {
  background: transparent;
}

.price-chart__table-toggle {
  margin-left: auto;
  padding: 7px 16px;
  border: 1px solid var(--pc-border);
  border-radius: 30px;
  background: transparent;
  color: var(--pc-ink);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.price-chart__table-toggle:hover {
  border-color: var(--pc-green);
}

/* --- Legend: identity, and the store filter ------------------------------ */
.price-chart__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.price-chart__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  border: 1px solid var(--pc-border);
  border-radius: 30px;
  background: transparent;
  color: var(--pc-ink);
  font-size: 14px;
  line-height: 1.2;
  cursor: pointer;
}

.price-chart__legend-item:hover {
  border-color: var(--pc-green);
}

/* With a single store there is nothing to filter, so the legend is a plain
   label — it still names the store, which the section title does not. */
.price-chart__legend-static {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px 6px 10px;
  color: var(--pc-ink);
  font-size: 14px;
  line-height: 1.2;
}

/* A muted store keeps its colour — identity never moves between stores. */
.price-chart__legend-item[aria-pressed="false"] {
  opacity: 0.45;
}

.price-chart__legend-key {
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  flex: 0 0 auto;
}

.price-chart__legend-name {
  font-weight: 500;
}

/* The latest price rides the legend, so every series has a visible value even
   when the reader never hovers (the three lighter slots need it — they sit
   below 3:1 on white). */
.price-chart__legend-value {
  color: var(--pc-ink-muted);
  font-variant-numeric: tabular-nums;
}

/* --- Plot ---------------------------------------------------------------- */
.price-chart__figure {
  position: relative;
  margin: 0;
}

.price-chart__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  touch-action: pan-y;
}

.price-chart__svg:focus-visible {
  outline: 2px solid var(--pc-green);
  outline-offset: 4px;
  border-radius: 8px;
}

.price-chart__grid line {
  stroke: var(--pc-grid);
  stroke-width: 1;
  shape-rendering: crispEdges;
}

.price-chart__axis text {
  fill: var(--pc-ink-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.price-chart__line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.price-chart__dot {
  stroke: var(--pc-surface);
  stroke-width: 2;
}

.price-chart__endlabel {
  fill: var(--pc-ink);
  font-size: 13px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.price-chart__crosshair {
  stroke: var(--pc-ink-muted);
  stroke-width: 1;
  opacity: 0.6;
}

.price-chart__series--muted {
  display: none;
}

.price-chart__empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0 20px;
  color: var(--pc-ink-muted);
  font-size: 15px;
  text-align: center;
}

/* --- Tooltip ------------------------------------------------------------- */
.price-chart__tooltip {
  position: absolute;
  z-index: 2;
  min-width: 168px;
  padding: 10px 12px;
  border: 1px solid var(--pc-border);
  border-radius: 12px;
  background: var(--pc-surface);
  box-shadow: 0 12px 28px rgba(25, 53, 45, 0.14);
  pointer-events: none;
}

.price-chart__tooltip-date {
  margin-bottom: 6px;
  color: var(--pc-ink-muted);
  font-size: 12px;
}

.price-chart__tooltip-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  font-size: 14px;
}

.price-chart__tooltip-key {
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: currentColor;
  flex: 0 0 auto;
  align-self: center;
}

/* Value leads, store name follows — the reader already knows the store. */
.price-chart__tooltip-value {
  color: var(--pc-ink);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.price-chart__tooltip-name {
  margin-left: auto;
  color: var(--pc-ink-muted);
}

.price-chart__note {
  margin: 14px 0 0;
  color: var(--pc-ink-muted);
  font-size: 13px;
}

/* --- Table view (the twin that never needs a hover) ---------------------- */
.price-chart__table-wrap {
  margin-top: 20px;
  max-height: 320px;
  overflow: auto;
}

.price-chart__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.price-chart__table th,
.price-chart__table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--pc-grid);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.price-chart__table th:first-child,
.price-chart__table td:first-child {
  text-align: left;
  font-variant-numeric: normal;
}

.price-chart__table thead th {
  position: sticky;
  top: 0;
  background: var(--pc-surface);
  color: var(--pc-ink-muted);
  font-weight: 500;
}

@media (max-width: 575px) {
  .price-chart {
    padding: 16px;
  }

  /* Keep the five presets on one line instead of stacking two rows of chips. */
  .price-chart__ranges {
    gap: 2px;
    padding: 3px;
  }

  .price-chart__range {
    padding: 6px 10px;
    font-size: 13px;
  }

  .price-chart__table-toggle {
    margin-left: 0;
    padding: 6px 12px;
    font-size: 13px;
  }

  .price-chart__legend-item,
  .price-chart__legend-static {
    font-size: 13px;
  }
}
