/* Component attribute form (component edit, step 2 — templates/form/attribute.fields.html.twig).

   This template predates the design-system migration and styled everything with
   hardcoded Tailwind utilities. The rules here replace the parts that either
   ignored the brand palette or fought the layout. */

/* Expanded-state accent for the attribute accordion headers. The template used
   `[&.active]:text-blue-600`, a hardcoded blue that ignored the brand palette —
   an expanded group title clashed with every other active state in the same form.

   The brand hue is mixed toward --text rather than used raw. Raw #9C1C1C on the
   dark panel (#1f2937) measures 1.81:1, far below the WCAG AA 4.5:1 floor this
   project requires; the mix lands at ~6:1 while keeping the brand tint, and it
   adapts to both themes because --text flips with the theme.

   Scoped to `button` on purpose: the read-only benefits table in
   macros/component.html.twig reuses .accordion-header on a div, and its level-0
   titles already sit on a primary-tinted background. */
button.accordion-header.active {
    color: color-mix(in srgb, var(--color-primary) 45%, var(--text));
}

/* Group header type scale. The template carried `text-xl` (20px) on root headers and
   `text-lg` (18px) on nested ones, both at font-weight 500 — 43% and 29% above
   auth-shell__dashboard-panel-title, the largest title size the design system uses
   (14px), and lighter than it rather than bolder. Big and thin is the inverse of the
   DS convention, which is small and heavy.

   The root tier matches the panel title exactly; nested drops one step. Only two
   tiers are needed because the 16px per-level indent already carries depth. */
.attribute-form__group-label {
    font-size: 14px;
    font-weight: 850;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.attribute-form__group-label--nested {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.01em;
}

/* The chevron SVG is hardcoded 24x24 in the markup, so `text-2xl` never sized it —
   it just left a 24px icon beside 14px text. 16px matches the DS inline-icon size. */
.attribute-form__toggle svg {
    width: 16px;
    height: 16px;
}

/* Accordion surfaces. These mirror the tokens auth-shell__dashboard-panel uses
   (border: 1px var(--line); translucent surface tint) but carry no padding, because
   the accordion header supplies its own. The previous
   `bg-white dark:bg-gray-800 rounded-2xl border-slate-300 dark:border-gray-700`
   resolved to an opaque rgb(31,41,55) block, so these panels did not match the
   translucent panes the rest of the shell — including step 1 of this same form —
   draws, and read as pasted on top of the page gradient. */
.attribute-form__panel {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface) 70%, transparent);
    color: var(--text);
}

[data-theme="light"] .attribute-form__panel {
    background: rgba(255, 255, 255, 0.62);
}

/* Nested rows separate with the token rule instead of border-slate-200. */
.attribute-form__nested-item {
    border-bottom: 1px solid var(--line);
}

.attribute-form__nested-item:last-child {
    border-bottom: 0;
}

/* Per-level indent for the nested attribute accordion. Each nesting level wraps
   its children in this container, so the indent compounds with depth without the
   recursion having to track a level counter.

   v3 conveyed the hierarchy with semantic heading levels (`h{{ lvl + 3 }}` plus
   `<hr>`); the v4 nested accordion dropped that and never replaced it, leaving
   depth 1 and depth 2 headers at an identical x offset and font size. */
.attribute-form__nest-root {
    padding: 1.5rem 1.5rem 1.5rem 2.5rem;
}

.attribute-form__nest {
    padding-left: 1rem;
}

/* Cost-sharing field rows.

   The costsharing Stimulus controller hides the non-applicable fields with
   `display: none`. Under the previous `grid-cols-1 md:grid-cols-3 lg:grid-cols-5`
   layout the hidden cells still reserved their tracks, because grid tracks come
   from grid-template-columns and do not collapse when an item is removed from
   flow. A row with one visible field left ~560px of dead space and squeezed that
   field into a 124px track that clipped its label ("Sin Preferid…" — the longest
   option in that same select is 34 characters).

   Flex wrapping drops hidden cells out of the flow entirely, so the visible
   fields share the full row width. */
.costsharing__row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Grow to share the row, but never narrower than a width that clips the longest
   option label, and never so wide that a lone select spans the whole panel. */
/* 12rem basis, not wider: the coinsurance+min+max case shows three value fields
   at once, and a larger basis wrapped the third onto a line of its own. At 12rem
   all three share one line (~202px each, ample for a numeric input plus its
   currency addon) while a lone field still grows to the 22rem cap. */
.costsharing__row > * {
    flex: 1 1 12rem;
    min-width: 0;
    max-width: 22rem;
}

/* The cost-sharing type select gets a larger share of its row: its longest option
   ("Coaseguro con copago mínimo/máximo") needs 274px of text, and an even split of
   the indented row left only 263px of inner width, clipping the last word.

   Weighted rather than full-width on purpose. Full width did clear the label, but
   it pushed the value fields onto a second line in every single cost-sharing card
   — ~66 of them on this form — which added ~2300px of scroll to an already 21000px
   page. Growing one cell costs no height at all. */
.costsharing__row > .costsharing__field--wide {
    flex: 2 1 20rem;
    max-width: none;
}

/* Scroll-to-bottom floating button. Was `bg-green-600 hover:bg-green-700` with a
   green focus ring — a third off-brand color in a form that already had the
   hardcoded blue. */
.attribute-form__scroll-fab {
    background: var(--color-primary);
    color: var(--cta-text);
}

.attribute-form__scroll-fab:hover {
    background: color-mix(in srgb, var(--color-primary) 85%, black);
}

.attribute-form__scroll-fab:focus-visible {
    outline: 2px solid color-mix(in srgb, var(--color-primary) 60%, transparent);
    outline-offset: 2px;
}
