/* Timesheet code display shared by the Purchase Order's Timesheet Codes tab
   (deal_timesheet_codes/_row) and the Project Consultants tab
   (projects/_consultant_timesheet_codes); markup from TimesheetCodeDisplayHelper.
   Collapsed: chevron, code chip, icon-only flags. Expanded: a details panel of
   icon + label + value lines. */

/* The TS code chip. */
.ts-code-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--bs-border-color);
  border-radius: 0.375rem;
  background: var(--bs-tertiary-bg);
  color: inherit; /* the dark theme recolours body text, not --bs-body-color */
  font-size: 0.9rem;
  font-weight: 700;
  word-break: break-all;
  min-height: 1.75rem;
}
.ts-code-chip > .bi {
  color: var(--bs-secondary-color);
  font-weight: normal;
}
.ts-code-chip-sm {
  min-height: 1.35rem;
  padding: 0.05rem 0.4rem;
  font-size: 0.78rem;
  font-weight: 600;
}

/* Icon-only pill on the collapsed line (colours from the bg/text/border-*-subtle
   utilities, which the dark theme remaps). */
.ts-code-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45rem;
  height: 1.3rem;
  padding: 0 0.3rem;
  border-radius: 50rem;
  font-size: 0.72rem;
  line-height: 1;
}

/* Purchase Order pill: indigo, so it reads apart from the blue profile pill,
   the green / amber TIA flag and the grey label. */
.ts-code-po-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.5rem;
  border: 1px solid #c29ffa; /* indigo-200 */
  border-radius: 50rem;
  background: #efe7fe;
  color: #3d0a91; /* indigo-700 */
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  text-align: start;
  word-break: break-word;
}
.ts-code-po-pill:hover,
.ts-code-po-pill:focus-visible {
  background: #e0cffc; /* indigo-100 */
  color: #290661; /* indigo-800 */
}
body.dark-theme .ts-code-po-pill {
  border-color: #520dc2; /* indigo-600 */
  background: #1d0846;
  color: #c29ffa;
}
body.dark-theme .ts-code-po-pill:hover,
body.dark-theme .ts-code-po-pill:focus-visible {
  background: #290661;
  color: #e0cffc;
}

/* The collapsed line: a native <summary> (Consultants tab), a Bootstrap
   collapse button (Timesheet Codes tab) or a plain line when there is nothing
   to expand. The chevron leads; the chip, pills and flags wrap in .ts-code-line
   so a wrapped flag lines up under the chip, not under the chevron. */
.ts-code-toggle {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: start;
  cursor: pointer;
  list-style: none;
}
.ts-code-toggle::-webkit-details-marker {
  display: none;
}
.ts-code-toggle-static {
  cursor: default;
}
.ts-code-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}
.ts-code-toggle:focus-visible {
  outline: 2px solid var(--bs-primary);
  outline-offset: 2px;
  border-radius: 0.25rem;
}
/* As tall as the chip, so it centres on the first line. */
.ts-code-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1.75rem;
  flex-shrink: 0;
  color: var(--bs-secondary-color);
  font-size: 0.75rem;
  transition: transform 0.15s;
}
details[open] > .ts-code-toggle .ts-code-chevron,
.ts-code-toggle[aria-expanded="true"] .ts-code-chevron {
  transform: rotate(90deg);
}
.ts-code-toggle-sm .ts-code-chevron {
  height: 1.35rem;
}
.ts-code-toggle:hover .ts-code-chevron {
  color: inherit;
}

/* Consultants tab: every code line, within one Purchase Order and across
   them, gets the same breathing room, so a consultant with several codes does
   not read as one cramped block. */
.timesheet-code-stack,
.timesheet-code-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Details panel: icon + label column, value column. */
.ts-code-details {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  column-gap: 1rem;
  row-gap: 0.4rem;
  margin: 0.5rem 0 0.25rem 1.35rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--bs-border-color);
  border-left: 3px solid var(--bs-primary-border-subtle);
  border-radius: 0.375rem;
  background: var(--bs-tertiary-bg);
  font-size: 0.82rem;
}
.ts-code-detail {
  display: contents;
}
.ts-code-detail > dt {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--bs-secondary-color);
  font-weight: 600;
  white-space: nowrap;
}
.ts-code-detail > dt > .bi {
  width: 1rem;
  text-align: center;
}
.ts-code-detail > dd {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

