/**
 * CD Table
 */

table {
  width: 100%;
  margin-bottom: 1rem;
}

th {
  text-align: left;
}

[dir="rtl"] th {
  text-align: right;
}

table caption {
  margin-top: 0.5rem;
  caption-side: bottom;
  text-align: left;
}

[dir="rtl"] table caption {
  text-align: right;
}

.cd-table {
  width: 100%;
  margin: 0 auto 3rem;
  border-collapse: collapse;
}

.cd-table caption {
  padding: 0.25rem 0.5rem;
  background: var(--brand-grey);
}

.cd-table th,
.cd-table td {
  padding: 0.5rem;
  text-align: left;
}

[dir="rtl"] .cd-table th,
[dir="rtl"] .cd-table td {
  text-align: right;
}

.cd-table th {
  color: var(--brand-primary--dark);
  border-bottom: 1px solid white;
  background: var(--brand-grey);
}

.cd-table a {
  word-break: break-word;
}

@media (min-width: 576px) {
  .cd-table th[data-sort-type="numeric"],
  .cd-table .cd-table--amount,
  .cd-table .cd-table--amount-total {
    text-align: right;
  }

  [dir="rtl"] .cd-table th[data-sort-type="numeric"],
  [dir="rtl"] .cd-table .cd-table--amount,
  [dir="rtl"] .cd-table .cd-table--amount-total {
    text-align: left;
  }
}

.cd-table tfoot {
  font-weight: bold;
}

/* Row numbers */
.cd-table--row-numbers {
  counter-reset: rowNumber;
}

.cd-table--row-numbers tbody tr {
  counter-increment: rowNumber;
}

.cd-table--row-numbers tbody tr td.cd-table--row-num:first-child::before {
  min-width: 1em;
  content: counter(rowNumber);
  font-weight: normal;
}

[dir="ltr"] .cd-table--row-numbers tbody tr td.cd-table--row-num:first-child::before {
  margin-right: 0.5em;
}

[dir="rtl"] .cd-table--row-numbers tbody tr td.cd-table--row-num:first-child::before {
  margin-left: 0.5em;
}

/* Striping */
.cd-table--striped tr:nth-child(odd) {
  background: white;
}

.cd-table--striped tr:nth-child(even) {
  background: var(--cd-grey--light);
}

@media (max-width: 575px) {
  /* Force table to not be like tables anymore */
  .cd-table--responsive,
  .cd-table--responsive thead,
  .cd-table--responsive tbody,
  .cd-table--responsive tfoot,
  .cd-table--responsive th,
  .cd-table--responsive td,
  .cd-table--responsive tr {
    display: block;
  }

  .cd-table--responsive caption {
    display: block;
  }

  /* Hide table headers (but not display: none;, for accessibility) */
  .cd-table--responsive thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  .cd-table--responsive tr {
    padding: 0 !important;
    border-bottom: 1px solid var(--cd-grey--light);
  }

  .cd-table--responsive td {
    position: relative;
    min-height: 2rem; /* label should wrap */
    padding: 0.5rem;
    padding-left: 40% !important;
    text-align: left;
    white-space: normal !important;
    /* Behave  like a "row" */
    border: none;
    border-bottom: 1px solid var(--brand-grey);
  }

  [dir="rtl"] .cd-table--responsive td {
    padding-right: 40% !important;
    padding-left: auto !important;
    text-align: right;
  }

  .cd-table--responsive td:before {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    width: 35%;
    padding-right: 1rem;
    /* Label the data */
    content: attr(data-content);
    text-align: left;
    color: var(--brand-primary);
    font-size: 0.875rem;
    font-weight: bold;
  }

  [dir="rtl"] .cd-table--responsive td:before {
    right: 0.5rem;
    left: auto;
    padding-right: 0;
    padding-left: 1rem;
    text-align: right;
  }

  .cd-table--responsive tfoot td {
    border-bottom: 0 none;
  }

  .cd-table--row-numbers tbody tr td.cd-table--row-num {
    height: 3rem;
  }

  .cd-table--row-numbers tbody tr td.cd-table--row-num::before {
    font-size: 1.5rem;
    font-weight: bold;
  }
}
