/* VirtuSlo design kit — components. Hand-written: the admin's dense parts in plain
   CSS, the reference that preview.html draws and DESIGN.md describes. Use the classes as
   they are, or rebuild them in the admin's own stack from the same tokens — the look is the
   contract, not the class names. Every colour is a token; hover only where a pointer hovers. */

@layer components {
  /* ── Buttons ─────────────────────────────────────────────────────────────────────── */

  .vs-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    height: var(--vs-control-h);
    padding: 0 0.75rem;
    border: 1px solid transparent;
    border-radius: var(--vs-radius-control);
    background: transparent;
    color: var(--vs-ink);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    text-decoration: none;
  }
  .vs-btn svg {
    width: 0.875rem;
    height: 0.875rem;
    flex: none;
  }
  /* The one main action of a screen or a dialog: ink, as the site's Log in. */
  .vs-btn--primary {
    background: var(--vs-ink);
    color: var(--vs-bg);
  }
  .vs-btn--outline {
    border-color: var(--vs-field-line);
  }
  .vs-btn--quiet {
    color: var(--vs-ink-2);
  }
  .vs-btn--danger {
    border-color: color-mix(in srgb, var(--vs-error) 55%, transparent);
    color: var(--vs-error);
  }
  /* Only inside the dialog that confirms a delete. */
  .vs-btn--danger-fill {
    background: var(--vs-error);
    color: var(--vs-error-on);
  }
  /* A row's ⋮ or edit: 24px square, its label in aria-label. */
  .vs-btn--icon {
    width: var(--vs-row-btn);
    height: var(--vs-row-btn);
    padding: 0;
    border-radius: 6px;
    color: var(--vs-ink-2);
  }
  .vs-btn:disabled,
  .vs-btn[aria-disabled='true'] {
    background: var(--vs-chip);
    border-color: transparent;
    color: var(--vs-ink-3);
  }
  @media (hover: hover) {
    .vs-btn--primary:not(:disabled):hover {
      background: color-mix(in oklab, var(--vs-ink) 82%, var(--vs-bg));
    }
    .vs-btn--outline:not(:disabled):hover {
      border-color: var(--vs-ink-3);
    }
    .vs-btn--quiet:not(:disabled):hover,
    .vs-btn--icon:not(:disabled):hover {
      background: var(--vs-chip);
      color: var(--vs-ink);
    }
    .vs-btn--danger:not(:disabled):hover {
      border-color: var(--vs-error);
      background: var(--vs-error-tint);
    }
    .vs-btn--danger-fill:not(:disabled):hover {
      background: color-mix(in oklab, var(--vs-error) 85%, var(--vs-bg));
    }
  }

  /* ── Fields ──────────────────────────────────────────────────────────────────────── */

  .vs-field {
    display: grid;
    gap: 0.25rem;
    align-content: start;
  }
  .vs-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--vs-ink-2);
  }
  .vs-hint {
    font-size: 0.75rem;
    color: var(--vs-ink-3);
  }
  .vs-field-error {
    font-size: 0.75rem;
    color: var(--vs-error);
  }
  .vs-input,
  .vs-select,
  .vs-textarea {
    box-sizing: border-box;
    width: 100%;
    height: var(--vs-control-h);
    padding: 0 0.625rem;
    border: 1px solid var(--vs-field-line);
    border-radius: var(--vs-radius-control);
    background: var(--vs-bg);
    color: var(--vs-ink);
    font: inherit;
    font-size: 0.8125rem;
  }
  .vs-textarea {
    height: auto;
    min-height: 5rem;
    padding: 0.4375rem 0.625rem;
    line-height: 1.5;
    resize: vertical;
  }
  .vs-input::placeholder,
  .vs-textarea::placeholder {
    color: var(--vs-ink-3);
  }
  .vs-select {
    appearance: none;
    padding-right: 1.75rem;
    background-image: linear-gradient(45deg, transparent 50%, var(--vs-ink-3) 50%), linear-gradient(-45deg, transparent 50%, var(--vs-ink-3) 50%);
    background-position: right 0.875rem center, right 0.625rem center;
    background-size: 0.25rem 0.25rem;
    background-repeat: no-repeat;
  }
  .vs-input[aria-invalid='true'],
  .vs-select[aria-invalid='true'],
  .vs-textarea[aria-invalid='true'] {
    border-color: var(--vs-error);
    box-shadow: inset 0 0 0 1px var(--vs-error);
  }
  .vs-input:disabled,
  .vs-select:disabled,
  .vs-textarea:disabled {
    background: var(--vs-chip);
    color: var(--vs-ink-3);
  }
  @media (hover: hover) {
    .vs-input:not(:disabled, [aria-invalid='true']):hover,
    .vs-select:not(:disabled, [aria-invalid='true']):hover,
    .vs-textarea:not(:disabled, [aria-invalid='true']):hover {
      border-color: var(--vs-ink-3);
    }
  }

  /* A colour field: the swatch as the API's colour, beside the hex. */
  .vs-colour {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .vs-colour > i {
    width: 1rem;
    height: 1rem;
    flex: none;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px var(--vs-ring);
  }

  .vs-check {
    appearance: none;
    width: 1rem;
    height: 1rem;
    margin: 0;
    flex: none;
    border: 1.5px solid var(--vs-field-line);
    border-radius: 4px;
    background: transparent;
    display: grid;
    place-content: center;
  }
  .vs-check:checked,
  .vs-check:indeterminate {
    border-color: var(--vs-ink);
    background: var(--vs-ink);
  }
  .vs-check:checked::after {
    content: '';
    width: 0.25rem;
    height: 0.5rem;
    margin-top: -0.125rem;
    border: solid var(--vs-bg);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
  }
  .vs-check:indeterminate::after {
    content: '';
    width: 0.5rem;
    height: 2px;
    background: var(--vs-bg);
  }

  /* All · Men · Women: one edge, the pressed one on the chip, focus drawn inside. */
  .vs-segmented {
    display: inline-flex;
    height: var(--vs-control-h);
    border: 1px solid var(--vs-field-line);
    border-radius: var(--vs-radius-control);
    overflow: hidden;
  }
  .vs-segmented > button {
    border: 0;
    padding: 0 0.75rem;
    background: transparent;
    color: var(--vs-ink-2);
    font: inherit;
    font-size: 0.8125rem;
  }
  .vs-segmented > button + button {
    border-left: 1px solid var(--vs-line);
  }
  .vs-segmented > [aria-pressed='true'] {
    background: var(--vs-chip);
    color: var(--vs-ink);
    font-weight: 600;
  }
  .vs-segmented > button:focus-visible {
    outline-offset: -2px;
  }
  @media (hover: hover) {
    .vs-segmented > [aria-pressed='false']:hover {
      background: color-mix(in srgb, var(--vs-chip) 55%, transparent);
      color: var(--vs-ink);
    }
  }

  /* ── Cards and toolbars ─────────────────────────────────────────────────────────── */

  .vs-card {
    background: var(--vs-surface);
    border: 1px solid var(--vs-line);
    border-radius: var(--vs-radius-card);
    overflow: clip;
  }
  .vs-card__body {
    padding: 0.75rem var(--vs-edge);
  }
  .vs-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: var(--vs-control-h);
    padding: 0.625rem var(--vs-edge);
    border-bottom: 1px solid var(--vs-line-soft);
  }
  .vs-toolbar > :first-child {
    margin-right: auto;
  }
  .vs-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.018em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  .vs-page-title {
    margin: 0;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.02em;
  }
  .vs-count {
    display: inline-flex;
    align-items: center;
    height: 1.125rem;
    padding: 0 0.4375rem;
    border-radius: var(--vs-radius-pill);
    background: var(--vs-chip);
    color: var(--vs-ink-2);
    font-size: 0.75rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  /* ── Tables: 35px rows, real <table>, a hidden caption ─────────────────────────── */

  .vs-table-box {
    overflow: auto;
  }
  .vs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
  }
  .vs-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--vs-surface);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--vs-ink-2);
    padding: 0.4375rem var(--vs-cell-px);
    border-bottom: 1px solid var(--vs-line);
    white-space: nowrap;
  }
  .vs-table th[aria-sort] {
    color: var(--vs-ink);
    font-weight: 700;
  }
  .vs-table th button {
    border: 0;
    padding: 0;
    background: none;
    font: inherit;
    color: inherit;
  }
  .vs-table th button:focus-visible,
  .vs-table td button:focus-visible {
    outline-offset: -2px;
  }
  .vs-table td {
    padding: var(--vs-row-py) var(--vs-cell-px);
    border-bottom: 1px solid var(--vs-line-soft);
    white-space: nowrap;
    vertical-align: middle;
  }
  .vs-table tbody tr:last-child td {
    border-bottom: 0;
  }
  .vs-table :is(th, td):first-child {
    padding-left: var(--vs-edge);
  }
  .vs-table :is(th, td):last-child {
    padding-right: var(--vs-edge);
  }
  .vs-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }
  .vs-table .shrink {
    width: 1px;
  }
  .vs-table tr[aria-selected='true'] {
    background: color-mix(in srgb, var(--vs-ink) 4%, var(--vs-surface));
  }
  @media (hover: hover) {
    .vs-table tbody tr:not([aria-selected='true']):hover {
      background: color-mix(in srgb, var(--vs-ink) 2.5%, var(--vs-surface));
    }
  }
  .vs-strong {
    font-weight: 600;
    color: var(--vs-ink);
  }
  .vs-sub {
    color: var(--vs-ink-3);
  }
  .vs-muted {
    color: var(--vs-ink-2);
  }
  .vs-none {
    color: var(--vs-ink-3);
  }
  /* A rider in a dense row: flag, the name verbatim, the team after it. */
  .vs-rider {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
    max-width: 24rem;
  }
  .vs-rider > .vs-flag {
    align-self: center;
  }
  .vs-rider > b {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .vs-rider > span {
    color: var(--vs-ink-3);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ── Pills, chips, flags, avatars ──────────────────────────────────────────────── */

  /* A status: always its word, a dot before it, colour last. */
  .vs-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3125rem;
    height: var(--vs-chip-h);
    padding: 0 0.5625rem;
    border-radius: var(--vs-radius-pill);
    background: var(--vs-chip);
    color: var(--vs-ink-2);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .vs-pill::before {
    content: '';
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background: currentColor;
  }
  .vs-pill--ok {
    background: var(--vs-brand-tint);
    color: var(--vs-brand-ink);
  }
  .vs-pill--warn {
    background: var(--vs-warn-tint);
    color: var(--vs-warn);
  }
  .vs-pill--bad {
    background: var(--vs-error-tint);
    color: var(--vs-error);
  }

  /* A pen, coloured by penPaint() (colour.ts) on the element or a container: its dot and
     edge in the pen's mark, a 6% wash, the name in ink. */
  .vs-pen {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    height: var(--vs-chip-h);
    padding: 0 0.5625rem;
    border: 1px solid var(--pen-edge, var(--vs-line));
    border-radius: var(--vs-radius-pill);
    background: var(--pen-wash, transparent);
    color: var(--vs-ink);
    font-size: 0.75rem;
    white-space: nowrap;
  }
  .vs-pen::before {
    content: '';
    width: 0.4375rem;
    height: 0.4375rem;
    border-radius: 50%;
    background: var(--pen-mark, var(--vs-ink-3));
  }

  .vs-flag {
    width: 16px;
    height: 12px;
    flex: none;
    border-radius: 2px;
    object-fit: cover;
    box-shadow: 0 0 0 1px var(--vs-ring);
  }
  /* No country — the common case: the same box, empty. */
  span.vs-flag {
    display: inline-block;
    background: var(--vs-chip);
  }

  /* The circle, on a rider's own page or header: the photo (img.vs-photo), else initials
     (initials.ts); with a country, its flag (img.vs-flag) as the badge. */
  .vs-avatar {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 50%;
    background: var(--vs-chip);
    color: var(--vs-ink-2);
    font-size: 11px;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px var(--vs-ring);
  }
  .vs-avatar > .vs-photo {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
  }
  .vs-avatar > .vs-flag {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 44%;
    height: 44%;
    border-radius: 3px;
    box-shadow: 0 0 0 2px var(--vs-surface);
  }

  /* ── Raised: menus, dialogs, toasts ────────────────────────────────────────────── */

  .vs-menu {
    min-width: 12rem;
    margin: 0;
    padding: 0.25rem;
    list-style: none;
    background: var(--vs-raised);
    border: 1px solid var(--vs-field-line);
    border-radius: var(--vs-radius-card);
    box-shadow: var(--vs-pop-shadow);
  }
  .vs-menu [role='menuitem'],
  .vs-menu [role='option'] {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    height: var(--vs-control-h);
    padding: 0 0.5rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--vs-ink);
    font: inherit;
    font-size: 0.8125rem;
    text-align: left;
  }
  .vs-menu :is([role='menuitem'], [role='option']):focus-visible {
    outline-offset: -2px;
  }
  .vs-menu .vs-menu__danger {
    color: var(--vs-error);
  }
  .vs-menu hr {
    margin: 0.25rem 0;
    border: 0;
    border-top: 1px solid var(--vs-line);
  }
  @media (hover: hover) {
    .vs-menu :is([role='menuitem'], [role='option']):hover {
      background: var(--vs-raised-hover);
    }
  }

  .vs-dialog {
    box-sizing: border-box;
    width: min(26rem, calc(100vw - 2 * var(--vs-gutter)));
    padding: 1rem;
    background: var(--vs-raised);
    color: var(--vs-ink);
    border: 1px solid var(--vs-field-line);
    border-radius: var(--vs-radius-card);
    box-shadow: var(--vs-pop-shadow);
  }
  .vs-dialog::backdrop {
    background: rgb(0 0 0 / 0.32);
  }
  .vs-dialog h2 {
    margin: 0 0 0.375rem;
    font-size: 0.9375rem;
    font-weight: 700;
  }
  .vs-dialog p {
    margin: 0 0 0.875rem;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--vs-ink-2);
  }
  .vs-dialog p b {
    color: var(--vs-ink);
    font-weight: 600;
  }
  .vs-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
  }

  .vs-toast {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5625rem 0.875rem;
    border-radius: 10px;
    background: var(--vs-ink);
    color: var(--vs-bg);
    font-size: 0.8125rem;
    font-weight: 600;
    box-shadow: var(--vs-pop-shadow);
  }
  .vs-toast > i {
    display: grid;
    place-items: center;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: var(--vs-brand);
    color: var(--vs-brand-on);
    font-size: 0.6875rem;
    font-style: normal;
  }
  .vs-toast--bad > i {
    background: var(--vs-error);
    color: var(--vs-error-on);
  }

  /* ── States: exactly one of loading, empty, error or content ───────────────────── */

  .vs-skeleton {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: calc(1.375rem + 2 * var(--vs-row-py) + 1px);
    padding: 0 var(--vs-edge);
    border-bottom: 1px solid var(--vs-line-soft);
  }
  .vs-skeleton > i {
    height: 0.625rem;
    border-radius: 4px;
    background: var(--vs-chip);
  }
  .vs-empty,
  .vs-error-state {
    padding: 2rem var(--vs-edge);
    text-align: center;
  }
  .vs-empty b,
  .vs-error-state b {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
  }
  .vs-empty p,
  .vs-error-state p {
    max-width: 44ch;
    margin: 0.25rem auto 0;
    color: var(--vs-ink-2);
    line-height: 1.5;
  }
  .vs-error-state .vs-btn {
    margin-top: 0.75rem;
  }

  /* ── The header and the wordmark ───────────────────────────────────────────────── */

  .vs-header {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    height: var(--vs-header-h);
    padding: 0 var(--vs-gutter);
    background: var(--vs-surface);
    border-bottom: 1px solid var(--vs-line);
  }
  .vs-wordmark {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--vs-ink);
    text-decoration: none;
    margin-right: auto;
  }
  .vs-wordmark img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
  }
  .vs-wordmark b {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.015em;
  }
  .vs-wordmark b em {
    font-style: normal;
    color: var(--vs-brand-ink);
  }
  .vs-wordmark .vs-racing {
    font-family: 'Orbitron', 'Figtree', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--vs-ink-2);
  }
  .vs-wordmark .vs-app {
    margin-left: 0.25rem;
    padding: 0 0.4375rem;
    border-radius: 6px;
    background: var(--vs-chip);
    color: var(--vs-ink-2);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.375rem;
  }
  .vs-nav {
    display: flex;
    gap: 0.25rem;
  }
  .vs-nav a {
    display: inline-flex;
    align-items: center;
    height: var(--vs-control-h);
    padding: 0 0.625rem;
    border-radius: var(--vs-radius-control);
    color: var(--vs-ink-2);
    font-size: 0.8125rem;
    text-decoration: none;
  }
  .vs-nav a[aria-current='page'] {
    background: var(--vs-chip);
    color: var(--vs-ink);
    font-weight: 600;
  }
  @media (hover: hover) {
    .vs-nav a:not([aria-current='page']):hover {
      background: color-mix(in srgb, var(--vs-chip) 55%, transparent);
      color: var(--vs-ink);
    }
  }
}
