/* ===========================
 * Button Group (Segmented Control) Component Styles
 * ===========================
 * A horizontal row of joined "segments" in one bordered container.
 * Two uses, one component:
 *   - Single-select  → role="radiogroup", segments role="radio" (filters, Já/Nei)
 *   - Actions        → role="group", plain buttons (icon clusters ← ⋮ →)
 *
 * Sizes : xs (24px) · sm (32px, default) · md (40px)
 * States: default · hover · focus-visible · selected (aria-checked) · disabled
 * Content: text · icon+text · icon-only (square)
 *
 * Selected uses the proven "active segment" treatment (bg-brand-primary-alt +
 * text-brand-primary) — the brand TEXT keeps selection distinguishable in dark
 * mode, where --bg-brand-primary-alt collapses to --bg-secondary (= hover bg).
 * Source of truth: Figma node 2006:2629. Spec: docs/specs/2026-06-03-button-group-design.md
 * Dark mode handled by theme-aware tokens (no explicit overrides needed).
 * Zero new design tokens.
 * =========================== */


/* ─── 1. Container ─── */

.btn-group {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  background-color: var(--bg-primary);
}


/* ─── 2. Segment (base = sm) ─── */

.btn-group-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-1-5);
  flex-shrink: 0;
  margin: 0;
  border: 0;
  border-right: 1px solid var(--border-secondary);
  background-color: var(--bg-primary);
  color: var(--text-secondary);
  font-family: var(--font-primary);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
  height: 32px;
  padding: 0 var(--spacing-3);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.btn-group-item:last-child {
  border-right: 0;
}

/* Round the outer corners to match the container (inset 1px for the border). */
.btn-group-item:first-child {
  border-top-left-radius: calc(var(--radius-md) - 1px);
  border-bottom-left-radius: calc(var(--radius-md) - 1px);
}
.btn-group-item:last-child {
  border-top-right-radius: calc(var(--radius-md) - 1px);
  border-bottom-right-radius: calc(var(--radius-md) - 1px);
}

/* Leading/trailing icons inherit the segment's text colour. */
.btn-group-item > i,
.btn-group-item > svg {
  font-size: 1em;
  line-height: 1;
  flex-shrink: 0;
}


/* ─── 3. Icon-only segments (square) ─── */

.btn-group-item--icon {
  padding-left: 0;
  padding-right: 0;
  aspect-ratio: 1 / 1;
}


/* ─── 4. States ─── */

/* Hover — only on non-selected, enabled segments. */
.btn-group-item:hover:not([aria-checked="true"]):not(:disabled):not([aria-disabled="true"]) {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* Focus — standard LSH-ds ring (lifted above neighbours so it isn't clipped). */
.btn-group-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg-primary), 0 0 0 4px var(--brand-500);
  position: relative;
  z-index: 1;
  border-radius: calc(var(--radius-md) - 1px);
}

/* Selected — subtle brand tint + brand text (dark-mode-safe via brand text). */
.btn-group-item[aria-checked="true"] {
  background-color: var(--bg-brand-primary-alt);
  color: var(--text-brand-primary);
}
.btn-group-item[aria-checked="true"]:hover:not(:disabled):not([aria-disabled="true"]) {
  background-color: var(--bg-brand-primary);
}

/* Disabled — muted, inert. */
.btn-group-item:disabled,
.btn-group-item[aria-disabled="true"] {
  color: var(--text-disabled);
  cursor: not-allowed;
}


/* ─── 5. Sizes ─── */

.btn-group[data-size="xs"] .btn-group-item {
  height: 24px;
  padding: 0 var(--spacing-2);
  gap: var(--spacing-1);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-xs);
}

/* sm is the base (declared above); listed for clarity / explicit override. */
.btn-group[data-size="sm"] .btn-group-item {
  height: 32px;
  padding: 0 var(--spacing-3);
  gap: var(--spacing-1-5);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-sm);
}

.btn-group[data-size="md"] .btn-group-item {
  height: 40px;
  padding: 0 var(--spacing-4);
  gap: var(--spacing-2);
  font-size: var(--font-size-md);
  line-height: var(--line-height-md);
}


/* ─── 6. Documentation display helpers ─── */

.btn-group-demo-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px;
}

.btn-group-demo-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}

.btn-group-demo-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.btn-group-demo-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}
