.dads-table {
  --_border-color: var(--color-neutral-solid-gray-420);
  --_padding: calc(20 / 16 * 1rem) calc(16 / 16 * 1rem);
  margin: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  row-gap: calc(16 / 16 * 1rem);
  color: var(--color-neutral-solid-gray-800);
  font-weight: normal;
  font-size: calc(16 / 16 * 1rem);
  line-height: 1.7;
  font-family: var(--font-family-sans);
  letter-spacing: 0.02em;
}

.dads-table[data-size="dense"] {
  --_padding: calc(12 / 16 * 1rem) calc(16 / 16 * 1rem);
  line-height: 1.3;
}

.dads-table__caption {
  font-weight: bold;
  font-size: calc(17 / 16 * 1rem);
}

.dads-table__table {
  border-collapse: collapse;
}

.dads-table__table :is(td, th) {
  padding: var(--_padding);
  text-align: left;
  vertical-align: baseline;
}

.dads-table__table th {
  font-weight: bold;
}

.dads-table__col-header {
  --_border-color: var(--color-neutral-solid-gray-500);
  background-color: var(--color-neutral-solid-gray-100);
  color: var(--color-neutral-solid-gray-900);
}

.dads-table__row-header {
  --_border-color: var(--color-neutral-solid-gray-500);
  background-color: var(--color-neutral-solid-gray-100);
  color: var(--color-neutral-solid-gray-900);
}

/* Stripe */

.dads-table[data-row-stripe] {
  --_border-color: var(--color-neutral-solid-gray-500);
}

.dads-table[data-row-stripe] tr:nth-child(even) {
  background-color: var(--color-neutral-solid-gray-50);
}

/* Hover highlight */

.dads-table[data-row-hover-highlight] {
  --_border-color: var(--color-neutral-solid-gray-500);
}

@media (hover: hover) {
  .dads-table[data-row-hover-highlight] tr:hover {
    background-color: var(--color-primitive-blue-50);
  }
}

/* With checkbox */

.dads-table[data-selectable] {
  --_border-color: var(--color-neutral-solid-gray-500);
}

.dads-table[data-selectable] tr:has(:checked) {
  background-color: var(--color-primitive-blue-100);
}

@supports (selector(:has(.x))) {
  .dads-table td:has(.dads-checkbox:only-child, .dads-radio:only-child),
  .dads-table th:has(.dads-checkbox:only-child, .dads-radio:only-child) {
    position: relative;
    box-sizing: border-box;
    width: calc(40 / 16 * 1rem);
    padding: 0;
  }

  .dads-table td > :is(.dads-checkbox:only-child, .dads-radio:only-child),
  .dads-table th > :is(.dads-checkbox:only-child, .dads-radio:only-child) {
    position: absolute;
    inset: 0;
    display: grid;
    justify-content: center;
    width: auto;
    padding-top: calc(10 / 16 * 1rem);
  }
}

/* Sort and action */

.dads-table__sort-header {
  --_border-color: var(--color-neutral-solid-gray-500);
  background-color: var(--color-neutral-solid-gray-100);
  padding: calc(12 / 16 * 1rem) calc(16 / 16 * 1rem);
  color: var(--color-neutral-solid-gray-900);
}

.dads-table[data-size="dense"] .dads-table__sort-header {
  padding-top: 0;
  padding-bottom: 0;
}

.dads-table__sort-inner {
  display: flex;
  align-items: start;
  justify-content: space-between;
  column-gap: calc(4 / 16 * 1rem);
}

.dads-table__sort-label {
  display: flex;
  align-items: start;
  gap: calc(4 / 16 * 1rem);
  padding-top: calc(8 / 16 * 1rem);
  padding-bottom: calc(8 / 16 * 1rem);
}

.dads-table[data-size="dense"] .dads-table__sort-label {
  padding-top: calc(11 / 16 * 1rem);
  padding-bottom: calc(11 / 16 * 1rem);
}

.dads-table__sort-button {
  display: inline-flex;
  align-items: start;
  column-gap: calc(4 / 16 * 1rem);
  border: 0;
  background-color: transparent;
  padding: 0;
  color: inherit;
  text-align: left;
  font: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: calc(3 / 16 * 1rem);
}

.dads-table__sort-button:hover {
  text-decoration-thickness: calc(3 / 16 * 1rem);
}

.dads-table__sort-button:focus-visible {
  outline: calc(4 / 16 * 1rem) solid var(--color-neutral-black);
  outline-offset: calc(2 / 16 * 1rem);
  border-radius: calc(4 / 16 * 1rem);
  background-color: var(--color-primitive-yellow-300);
  box-shadow: 0 0 0 calc(2 / 16 * 1rem) var(--color-primitive-yellow-300);
}

.dads-table__sort-icon {
  flex-shrink: 0;
  padding-top: calc(2 / 16 * 1rem);
}

.dads-table[data-size="dense"] .dads-table__sort-icon {
  margin-top: calc(-2 / 16 * 1rem);
  padding-top: 0;
}

.dads-table__sort-svg {
  display: block;
  width: calc(24 / 16 * 1rem);
  height: calc(24 / 16 * 1rem);
}

.dads-table__action {
  margin-right: calc(-16 / 16 * 1rem);
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: calc(44 / 16 * 1rem);
  height: calc(44 / 16 * 1rem);
  border-radius: calc(4 / 16 * 1rem);
  border: 0;
  background-color: transparent;
  padding: 0;
  color: inherit;
}

.dads-table__action:focus-visible {
  outline: calc(4 / 16 * 1rem) solid var(--color-neutral-black);
  outline-offset: calc(2 / 16 * 1rem);
  border-radius: calc(4 / 16 * 1rem);
  background-color: var(--color-primitive-yellow-300);
  box-shadow: 0 0 0 calc(2 / 16 * 1rem) var(--color-primitive-yellow-300);
}

.dads-table__action-svg {
  display: block;
  width: calc(24 / 16 * 1rem);
  height: calc(24 / 16 * 1rem);
}

/* Utilities */

.dads-table [data-width="full"] {
  width: 100%;
}

.dads-table [data-layout="fixed"] {
  table-layout: fixed;
}

.dads-table [data-cell-border=""] :where(td, th) {
  border: 1px solid var(--_border-color);
}

.dads-table [data-cell-border~="top"] :where(td, th) {
  border-top: 1px solid var(--_border-color);
}

.dads-table [data-cell-border~="right"] :where(td, th) {
  border-right: 1px solid var(--_border-color);
}

.dads-table [data-cell-border~="bottom"] :where(td, th) {
  border-bottom: 1px solid var(--_border-color);
}

.dads-table [data-cell-border~="left"] :where(td, th) {
  border-left: 1px solid var(--_border-color);
}

/* Header cell's black border should take precedence over [data-cell-border] */
:last-of-type > .dads-table__col-header,
:last-of-type > .dads-table__sort-header {
  border-bottom: 1px solid var(--color-neutral-black);
}
.dads-table__row-header:last-of-type {
  border-right: 1px solid var(--color-neutral-black);
}

.dads-table [data-border=""] {
  border: 1px solid var(--_border-color);
}

.dads-table [data-border~="top"] {
  border-top: 1px solid var(--_border-color);
}

.dads-table [data-border~="right"] {
  border-right: 1px solid var(--_border-color);
}

.dads-table [data-border~="bottom"] {
  border-bottom: 1px solid var(--_border-color);
}

.dads-table [data-border~="left"] {
  border-left: 1px solid var(--_border-color);
}

.dads-table [data-border="hidden"] {
  border-style: hidden;
}

.dads-table [data-border~="top-hidden"] {
  border-top-style: hidden;
}

.dads-table [data-border~="right-hidden"] {
  border-right-style: hidden;
}

.dads-table [data-border~="bottom-hidden"] {
  border-bottom-style: hidden;
}

.dads-table [data-border~="left-hidden"] {
  border-left-style: hidden;
}

.dads-table [data-bg="white"] {
  background-color: var(--color-neutral-white);
}

.dads-table [data-bg="solid-gray-50"] {
  --_border-color: var(--color-neutral-solid-gray-500);
  background-color: var(--color-neutral-solid-gray-50);
}

.dads-table [data-bg="solid-gray-100"] {
  --_border-color: var(--color-neutral-solid-gray-500);
  background-color: var(--color-neutral-solid-gray-100);
}

.dads-table [data-bg="transparent"] {
  background-color: transparent;
}
