/* Components — mirror the sets on Figma page "Components" */

/* Hover / pressed: palette-interactive overlays painted on top of the fill */

/* ---------- Button (Figma "Button NEW" 2042:24188) ----------
   Style: Primary · Secondary · Ghost (+ Destructive) · Size: S 32 (default) · XS 24
   State overlays are painted on top of the fill: hover → interactive/hover,
   pressed → interactive/pressed, keyboard focus → interactive/focus. */
.btn {
  --btn-overlay: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--ds-spacing-s);
  height: 32px;
  padding: 0 var(--ds-spacing-m);
  border: 0;
  border-radius: var(--ds-border-radius-m);
  background-image: linear-gradient(var(--btn-overlay), var(--btn-overlay));
  font: var(--ds-font-body-strong-s-weight) var(--ds-font-body-strong-s-size)/var(--ds-font-body-strong-s-line-height) var(--ds-ref-font-family-body);
  white-space: nowrap;
  cursor: pointer;
}
.btn:has(> svg:first-child),
.btn:has(> svg:last-child) { gap: var(--ds-spacing-xs); padding-inline: var(--ds-spacing-s); }
.btn--icon { width: 32px; padding: 0; }
.btn--xs { height: 24px; font: var(--ds-font-caption-strong-weight) var(--ds-font-caption-strong-size)/var(--ds-font-caption-strong-line-height) var(--ds-ref-font-family-body); }
.btn--xs.btn--icon { width: 24px; }
.btn svg { width: 16px; height: 16px; flex: none; }

.btn:hover:not(:disabled) { --btn-overlay: var(--ds-palette-interactive-hover); }
.btn:active:not(:disabled) { --btn-overlay: var(--ds-palette-interactive-pressed); }
.btn:focus-visible { outline: none; --btn-overlay: var(--ds-palette-interactive-focus); }

/* Gap #1: white label on background/brand is below 4.5:1 — kept as in Figma */
.btn--primary { background-color: var(--ds-palette-background-brand); color: var(--ds-palette-content-on-high); }
.btn--secondary { background-color: var(--ds-palette-background-tertiary); color: var(--ds-palette-content-primary); }
.btn--ghost,
.btn--tertiary { background-color: var(--ds-palette-background-transparent); color: var(--ds-palette-content-primary); }
.btn--danger,
.btn--primary.btn--destructive { background-color: var(--ds-palette-background-error); color: var(--ds-palette-content-on-high); }
.btn--secondary.btn--destructive { background-color: var(--ds-palette-background-error-low); color: var(--ds-palette-content-error); }
.btn--ghost.btn--destructive { color: var(--ds-palette-content-error); }

.btn:disabled,
.btn[aria-disabled="true"] {
  --btn-overlay: transparent;
  background-color: var(--ds-palette-background-disabled);
  color: var(--ds-palette-content-disabled);
  cursor: not-allowed;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--ds-border-radius-m);
  background: var(--ds-palette-background-transparent);
  cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--ds-palette-interactive-hover); }
.icon-btn:active:not(:disabled) { background: var(--ds-palette-interactive-pressed); }
.icon-btn:focus-visible { outline: none; background: var(--ds-palette-interactive-focus); }
.icon-btn:disabled { color: var(--ds-palette-content-disabled); cursor: not-allowed; }

/* ---------- Balance cards (Figma 164:56461) ---------- */
.balance-row { display: flex; gap: var(--ds-spacing-m); }
.balance-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--ds-spacing-m); }

.balance-card {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ds-spacing-s);
  padding: var(--ds-spacing-l);
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  border-radius: var(--ds-border-radius-l);
  background: var(--ds-palette-background-primary);
}
.balance-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--ds-spacing-l); }
.balance-card__per { color: var(--ds-palette-content-tertiary); white-space: nowrap; }
.balance-card__body { display: flex; flex-direction: column; gap: var(--ds-spacing-s); }
.balance-card__available { display: flex; align-items: baseline; gap: var(--ds-spacing-s); margin: 0; white-space: nowrap; }
.balance-card__available .t-body-s,
.balance-card__caption { color: var(--ds-palette-content-secondary); margin: 0; }

.balance-bar {
  display: flex;
  height: 6px;
  overflow: hidden;
  border-radius: var(--ds-border-radius-2xs);
  background: var(--ds-palette-background-tertiary);
}
.balance-bar__taken { background: var(--ds-palette-background-brand-high); }
.balance-bar__pending { background: var(--ds-palette-background-alert-medium); }

.balance-card--other { flex: 0 0 180px; justify-content: space-between; }
.balance-card__other { display: flex; flex-direction: column; gap: var(--ds-spacing-s); }
.balance-card__other p { margin: 0; color: var(--ds-palette-content-tertiary); }
.balance-card__other-desc--phone { display: none; }

/* Text link button ("View all 12 types") */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  padding: var(--ds-spacing-s) 0;
  border: 0;
  background: none;
  color: var(--ds-palette-content-brand);
  cursor: pointer;
}
.link-btn svg { fill: currentColor; }
.link-btn:hover { text-decoration: underline; }
.link-btn:focus-visible { outline: var(--ds-border-width-xs) solid var(--ds-palette-border-brand); outline-offset: var(--ds-spacing-xxs); border-radius: var(--ds-border-radius-xs); }

/* 4th balance card only on wide screens (decision: hidden below 1280 px) */
@media (max-width: 1279px) { .balance-card--fourth { display: none; } }

/* ---------- Tabs (Figma "Tabs / Requests": underline) ---------- */
.tabs { display: flex; gap: var(--ds-spacing-2xl); }
.tab {
  height: 40px;
  padding: 0;
  border: 0;
  border-bottom: var(--ds-border-width-xs) solid transparent;
  background: none;
  color: var(--ds-palette-content-secondary);
  cursor: pointer;
}
.tab:hover:not(.is-active) { color: var(--ds-palette-content-primary); }
.tab.is-active { border-bottom-color: var(--ds-palette-border-brand); color: var(--ds-palette-content-primary); }
.tab:focus-visible { outline: none; border-radius: var(--ds-border-radius-xs); background: var(--ds-palette-interactive-focus); }

/* ---------- Segmented control (Figma "Segmented" + "Segment Item" 2042:23990) ---------- */
.segmented {
  display: inline-flex;
  gap: var(--ds-spacing-xxs);
  padding: var(--ds-spacing-xxs) 3px;
  border-radius: var(--ds-border-radius-m);
  background: var(--ds-palette-background-tertiary);
}
.segmented__item {
  --seg-overlay: transparent;
  height: 28px;
  padding: 0 var(--ds-spacing-m);
  border: 0;
  border-radius: 6px;
  background: transparent linear-gradient(var(--seg-overlay), var(--seg-overlay));
  font: var(--ds-font-body-s-weight) var(--ds-font-body-s-size)/var(--ds-font-body-s-line-height) var(--ds-ref-font-family-body);
  color: var(--ds-palette-content-secondary);
  cursor: pointer;
}
.segmented__item:hover:not(.is-active) { --seg-overlay: var(--ds-palette-interactive-hover); }
.segmented__item.is-active {
  background-color: var(--ds-palette-background-primary);
  color: var(--ds-palette-content-primary);
  font-weight: var(--ds-ref-font-weight-semibold);
}
.segmented__item:focus-visible { outline: none; --seg-overlay: var(--ds-palette-interactive-focus); }

/* Size S (Figma Segment Item Size=S): 24 px items, radius s; icon-only = 24×24 */
.segmented--s { padding: var(--ds-spacing-xxs); }
.segmented--s .segmented__item { height: 24px; padding: 0 var(--ds-spacing-s); border-radius: var(--ds-border-radius-s); }
.segmented__item--icon { display: inline-flex; align-items: center; justify-content: center; }
.segmented--s .segmented__item--icon { width: 24px; padding: 0; }
.segmented__item--icon svg { fill: currentColor; }

.supervisor strong { font-weight: var(--ds-font-body-strong-s-weight); }

/* ---------- Requests table (single table: toolbar · table · footer) ---------- */
.requests-card {
  display: flex;
  flex-direction: column;
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  border-radius: var(--ds-border-radius-m);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-spacing-m);
  padding: var(--ds-spacing-m);
  border-bottom: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
}
.input--search { width: 240px; padding-left: var(--ds-spacing-s); gap: var(--ds-spacing-xs); }
.input--search .input__icon { flex: none; fill: var(--ds-palette-content-tertiary); }
.input--search input { padding-left: 0; }
input[type="search"]::-webkit-search-cancel-button { display: none; } /* replaced by our own clear button (Material close) */
.input__clear {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-right: var(--ds-spacing-xs);
  padding: 0;
  border: 0;
  border-radius: var(--ds-border-radius-xs);
  background: none;
  color: var(--ds-palette-content-secondary);
  cursor: pointer;
}
.input__clear svg { fill: currentColor; }
.input__clear:hover { background: var(--ds-palette-interactive-hover); }
.input__clear:focus-visible { outline: none; background: var(--ds-palette-interactive-focus); }

.table-wrap { overflow-x: auto; }

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-spacing-m);
  padding: 10px var(--ds-spacing-m);
  border-top: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
}
.table-footer__count { margin: 0; color: var(--ds-palette-content-secondary); }
.cell--empty { height: 160px; text-align: center !important; vertical-align: middle !important; color: var(--ds-palette-content-secondary); }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--ds-spacing-s); white-space: normal; }
.empty-state p { margin: 0; }
.empty-state .t-body-strong-m { color: var(--ds-palette-content-primary); }
.empty-state .btn { margin-top: var(--ds-spacing-s); }

/* Active filter chips (Figma "Active filters") */
.table-toolbar__left { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-spacing-m); min-width: 0; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--ds-spacing-s); }
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: var(--ds-spacing-xs) var(--ds-spacing-s) var(--ds-spacing-xs) 10px;
  border: 0;
  border-radius: var(--ds-border-radius-full);
  background: var(--ds-palette-background-brand-low);
  color: var(--ds-palette-content-brand-high);
  cursor: pointer;
}
.filter-chip:hover { background-image: linear-gradient(var(--ds-palette-interactive-hover), var(--ds-palette-interactive-hover)); }
.filter-chip:focus-visible { outline: none; background-image: linear-gradient(var(--ds-palette-interactive-focus), var(--ds-palette-interactive-focus)); }
.filter-chips__clear { padding: var(--ds-spacing-xs); border: 0; background: none; color: var(--ds-palette-content-brand); cursor: pointer; }
.filter-chips__clear:hover { text-decoration: underline; }
.filter-chips__clear:focus-visible { outline: var(--ds-border-width-xs) solid var(--ds-palette-border-brand); border-radius: var(--ds-border-radius-xs); }

.requests-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed; /* stable column widths: sorting or filtering never shifts them (feedback 9) */
}
/* Column widths; Note takes the rest. Below 1280 Note is hidden and the others share its space. */
.th--type { width: 13%; }
.th--status { width: 13%; }
.th--dates { width: 17%; }
.th--duration { width: 14%; }

.requests-table th,
.requests-table td {
  text-align: left;
  vertical-align: middle; /* feedback 16 */
}
.requests-table th:last-child,
.requests-table td:last-child { border-right: 0; }

.th {
  height: 40px;
  padding: var(--ds-spacing-m);
  border-bottom: var(--ds-border-width-xxs) solid var(--ds-palette-border-medium);
  background: var(--ds-palette-background-secondary);
  color: var(--ds-palette-content-tertiary);
  vertical-align: middle !important;
  white-space: nowrap;
}
.th--updated { width: 160px; }

.th__sort {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-spacing-xs);
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.th__sort svg { fill: currentColor; }
.th__sort:focus-visible { outline: none; }

.th__inner { display: flex; align-items: center; gap: var(--ds-spacing-xs); }
.th__filter {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--ds-border-radius-xs);
  background: none;
  color: inherit;
  cursor: pointer;
  visibility: hidden;
}
.th:hover .th__filter,
.th:focus-within .th__filter,
.th__filter.is-active,
.th__filter[aria-expanded="true"] { visibility: visible; }
.th__filter.is-active { color: var(--ds-palette-content-brand); }
.th__filter:hover { background: var(--ds-palette-interactive-hover); }
.th__filter:focus-visible { outline: none; background: var(--ds-palette-interactive-focus); }
.th.is-filtered { color: var(--ds-palette-content-primary); }

/* Heading cell: hover / focus overlay; filter + sort icons appear */
.th__controls { display: flex; gap: var(--ds-spacing-xs); }
.th__hover-icon { visibility: hidden; }
.th.is-sorted { color: var(--ds-palette-content-primary); }
.th:hover { background-image: linear-gradient(var(--ds-palette-interactive-hover), var(--ds-palette-interactive-hover)); }
.th:has(.th__sort:focus-visible) { background-image: linear-gradient(var(--ds-palette-interactive-focus), var(--ds-palette-interactive-focus)); }
.th:hover .th__hover-icon,
.th:focus-within .th__hover-icon { visibility: visible; }

/* Rows: one <tbody class="req"> per request (row + optional decline note) */
.req + .req > tr:first-child > td { border-top: var(--ds-border-width-xxs) solid var(--ds-palette-border-low); }
/* Cells are opaque (the first column is sticky on phones and must cover what scrolls under it);
   hover / open-menu tints are painted as an overlay on top of that white */
.requests-table td { background-color: var(--ds-palette-background-primary); }
.req:hover td,
.req.is-menu-open td,
.req:has(tr.is-menu-open) td { background-image: linear-gradient(var(--ds-palette-interactive-hover), var(--ds-palette-interactive-hover)); }
.req[data-tip] { cursor: default; }

/* Newly added / "View existing request" row: brief brand-low flash */
@keyframes row-flash { from { background: var(--ds-palette-background-brand-low); } }
.req.is-highlighted td { animation: row-flash 2.5s ease-out; }
@media (prefers-reduced-motion: reduce) {
  .req.is-highlighted td { animation: none; background: var(--ds-palette-background-brand-low); }
}

.cell {
  height: 42px;
  padding: var(--ds-spacing-m);
  color: var(--ds-palette-content-primary);
}
.cell--duration,
.cell--updated { color: var(--ds-palette-content-secondary); }
.cell--dates,
.cell--duration,
.cell--updated { white-space: nowrap; }
.cell--updated { position: relative; padding-right: var(--ds-spacing-4xl); }

.decline-row td { padding: 0 var(--ds-spacing-m) var(--ds-spacing-m); }
.decline-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: var(--ds-spacing-s) 10px;
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  border-radius: var(--ds-border-radius-m);
  background: var(--ds-palette-background-secondary);
}
.decline-note__avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--ds-border-radius-full);
  background: var(--ds-palette-background-brand-low);
  color: var(--ds-palette-content-brand-high);
  font: var(--ds-ref-font-weight-semibold) 9px/1 var(--ds-ref-font-family-body);
}
.decline-note__msg { flex: 1; min-width: 0; margin: 0; color: var(--ds-palette-content-primary); }
.decline-note__action {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--ds-spacing-xs);
  padding: 0;
  border: 0;
  background: none;
  color: var(--ds-palette-content-brand);
  cursor: pointer;
}
.decline-note__action svg { fill: currentColor; }
.decline-note__action:hover { text-decoration: underline; }
.decline-note__action:focus-visible { outline: var(--ds-border-width-xs) solid var(--ds-palette-border-brand); outline-offset: var(--ds-spacing-xxs); border-radius: var(--ds-border-radius-xs); }

/* Row ⋮ — visible on row hover / keyboard focus; always visible on touch */
.row-menu {
  position: absolute;
  top: 50%;
  right: var(--ds-spacing-s);
  transform: translateY(-50%);
}
.row-menu__trigger { opacity: 0; color: var(--ds-palette-content-secondary); }
.row-menu__trigger svg { fill: currentColor; }
.req:hover .row-menu__trigger,
tr.is-menu-open .row-menu__trigger,
.row-menu__trigger:focus-visible { opacity: 1; }
@media (hover: none) { .row-menu__trigger { opacity: 1; } }

/* ---------- Status badge (Figma "Status") ---------- */
.status {
  display: inline-flex;
  align-items: center;
  gap: var(--ds-spacing-xs);
  height: 20px;
  padding: var(--ds-spacing-xxs) var(--ds-spacing-s);
  border-radius: var(--ds-border-radius-full);
  font: var(--ds-font-caption-weight) var(--ds-font-caption-size)/var(--ds-font-caption-line-height) var(--ds-ref-font-family-body);
  white-space: nowrap;
}
.status--approved { background: var(--ds-palette-background-success-low); color: var(--ds-palette-content-success); }
.status--pending { background: var(--ds-palette-background-alert-low); color: var(--ds-palette-content-alert); }
.status--declined { background: var(--ds-palette-background-error-low); color: var(--ds-palette-content-error); }

/* ---------- Pagination (table footer) ---------- */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--ds-spacing-s);
  margin: 0;
  color: var(--ds-palette-content-primary);
}
.pagination__current {
  padding: 0 var(--ds-spacing-xs);
  border: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
  border-radius: var(--ds-border-radius-xs);
}

/* ---------- Tooltip (shared: calendar bars, past rows) — Figma "Tooltip Dark" 186:76561 ----------
   Background only is 80% opaque (content/tertiary mixed with transparent) — text stays solid.
   Gaps: that fill isn't on the transparency ramp (navy-based), and the 2px backdrop blur has
   no token (value from Figma, kept as designed). */
.tooltip {
  position: fixed;
  z-index: 40;
  max-width: 260px;
  padding: var(--ds-spacing-xs) var(--ds-spacing-s);
  border-radius: var(--ds-border-radius-xs);
  background: color-mix(in srgb, var(--ds-palette-content-tertiary) 80%, transparent);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  color: var(--ds-palette-background-primary); /* inverse of its fill: white on grey in Light, dark on light grey in Dark */
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}
.tooltip.is-visible { opacity: 1; }
.tooltip p { margin: 0; }
.tooltip p + p { margin-top: var(--ds-font-body-s-line-height); } /* empty line between blocks, as in Figma */
.tooltip strong { font-weight: var(--ds-font-body-strong-s-weight); }
@media (prefers-reduced-motion: reduce) { .tooltip { transition: none; } }

/* ---------- Decision received (Figma "06 · Decision received") ---------- */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0 var(--ds-spacing-xs);
  border-radius: var(--ds-border-radius-full);
  background: var(--ds-palette-background-brand);
  color: var(--ds-palette-content-on-high);
}
.nav-link { position: relative; }
.unread-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 0 2px var(--ds-spacing-s); /* after the type name, so the text doesn't shift */
  border-radius: var(--ds-border-radius-full);
  background: var(--ds-palette-background-brand);
  vertical-align: middle;
}

/* ---------- Skeletons (Figma "07 · Loading (skeleton)") ---------- */
@keyframes skel-pulse { 50% { opacity: 0.5; } }
.skel {
  display: block;
  height: 12px;
  border-radius: var(--ds-border-radius-xs);
  background: var(--ds-palette-background-tertiary);
  animation: skel-pulse 1.4s ease-in-out infinite;
}
.skel--big { height: 36px; }
.skel--thin { height: 6px; }
.skel--seg { width: 200px; height: 32px; border-radius: var(--ds-border-radius-m); }
.skel--search { width: 240px; height: 32px; border-radius: var(--ds-border-radius-m); }
.skel-rows { display: flex; flex-direction: column; }
.skel-row {
  display: grid;
  grid-template-columns: 13% 12% 15% minmax(0, 1fr) 12% 14%; /* matches the table's columns */
  align-items: center;
  height: 46px;
  border-bottom: var(--ds-border-width-xxs) solid var(--ds-palette-border-low);
}
.skel-row--head { height: 40px; border-bottom-color: var(--ds-palette-border-medium); background: var(--ds-palette-background-secondary); }
.skel-cell { padding: 0 var(--ds-spacing-m); min-width: 0; }
.skel-cell .skel { max-width: 100%; }
.skel--head { height: 10px; }
@media (max-width: 1279px) {
  .skel-row { grid-template-columns: 18% 16% 22% 20% minmax(0, 1fr); }
  .skel-cell--note { display: none; }
}
.balance-card .skel { margin: var(--ds-spacing-xxs) 0; }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---------- Accessibility ---------- */
.skip-link {
  position: absolute;
  top: var(--ds-spacing-s);
  left: var(--ds-spacing-s);
  z-index: 100;
  padding: var(--ds-spacing-s) var(--ds-spacing-m);
  border-radius: var(--ds-border-radius-m);
  background: var(--ds-palette-background-brand);
  color: var(--ds-palette-content-on-high);
  font: var(--ds-font-body-strong-s-weight) var(--ds-font-body-strong-s-size)/var(--ds-font-body-strong-s-line-height) var(--ds-ref-font-family-body);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; outline: var(--ds-border-width-xs) solid var(--ds-palette-border-brand-high); outline-offset: 2px; }
#main:focus { outline: none; }
.balance-card h3 { margin: 0; }

/* Touch screens: 44 px targets for the small controls added in v2 */
@media (pointer: coarse) {
  .filter-chip,
  .filter-chips__clear,
  .free-dates__chip,
  .decline-note__action,
  .link-btn { min-height: 44px; }
  .th__filter { width: 44px; height: 44px; visibility: visible; }
}
.input__clear[hidden] { display: none; }

/* Row with an unseen decision: light lilac until it's clicked (feedback 15) */
.req.is-unread td { background-color: var(--ds-palette-background-brand-low); }
.nav-badge { cursor: default; }
.th__inner .th__sort { flex: 1; min-width: 0; }
