/**
 * @file
 * Styles for Tables.
 */
table {
  width: 100%;
  margin-top: var(--space-l);
  margin-bottom: var(--space-l);
}

@media (max-width: 575.98px) {
  table.sticky-header {
    left: 0 !important;
  }
}

.sticky-header {
  min-width: 0;
}

caption {
  text-align: left;
  /* LTR */
}

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

th {
  position: relative;
  box-sizing: border-box;
  height: var(--space-xl);
  padding: var(--space-xs) var(--space-m);
  text-align: left;
  /* LTR */
  color: var(--color-text);
  background: var(--color-gray-lighter);
  line-height: 1.25rem;
  /* 20px */
}

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

/**
 * Table sort.
 */
/* Table head cell containing sort link. */
.sortable-heading {
  padding: 0 var(--space-m);
}

/* The actual sort link. */
.sortable-heading > a {
  display: block;
  padding: var(--space-xs) 1.5rem var(--space-xs) 0;
  /* LTR */
  text-decoration: none;
  color: inherit;
}

[dir="rtl"] .sortable-heading > a {
  padding-right: 0;
  padding-left: 1.5rem;
}

.sortable-heading > a::before {
  position: absolute;
  z-index: 0;
  top: 0;
  right: 1rem;
  bottom: 0;
  left: 1rem;
  display: block;
  content: "";
  border-bottom: 0.125rem solid transparent;
}

/* stylelint-disable-next-line selector-type-no-unknown */
_:-ms-fullscreen,
.sortable-heading > a::before {
  top: auto;
  height: 100%;
}

.sortable-heading > a::after {
  position: absolute;
  top: 50%;
  right: 1rem;
  width: 0.875rem;
  height: 1rem;
  margin-top: -0.5rem;
  content: "";
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='m1.75,0.25v1.5h10.5v-1.5z m0,3v1.5h7.5v-1.5z m0,3v1.5h4.5v-1.5z' fill='%231b1d47'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 50% 50%;
  background-size: contain;
}

/* stylelint-disable-next-line selector-type-no-unknown */
_:-ms-fullscreen,
.sortable-heading > a::after {
  position: static;
  float: right;
  margin-top: 0.125rem;
  /* 2px */
  margin-right: -1.5rem;
  /* -24px */
}

[dir="rtl"] .sortable-heading > a::after {
  right: auto;
  left: 1rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='8' viewBox='0 0 14 8'%3E%3Cpath d='m12.25,0.25v1.5H1.75v-1.5z m0,3v1.5h-7.5v-1.5z m0,3v1.5h-4.5v-1.5z' fill='%231b1d47'/%3E%3C/svg%3E");
}

/* stylelint-disable-next-line selector-type-no-unknown */
_:-ms-fullscreen,
[dir="rtl"] .sortable-heading > a::after {
  float: left;
  margin-right: 0;
  margin-left: -1.5rem;
  /* -24px */
}

/* Sortable cell's link focus/hover state. */
.sortable-heading > a:focus,
.sortable-heading > a:hover {
  text-decoration: none;
}

.sortable-heading > a:focus::before,
.sortable-heading > a:hover::before {
  border-color: inherit;
}

.sortable-heading > a:focus::after,
.sortable-heading > a:hover::after {
  opacity: 1;
}

/* Sortable cell's active state. */
.sortable-heading.is-active > a {
  color: var(--color-primary);
}

.sortable-heading.is-active > a::before {
  border-bottom: 0.1875rem solid var(--color-primary);
}

.sortable-heading.is-active > a::after {
  content: none;
}

tr:not(:last-child) {
  border-bottom: 0.0625rem solid var(--color-gray-light);
}

tr,
.draggable-table.tabledrag-disabled tr {
  color: var(--color-text);
  background: var(--color-white);
}

thead tr {
  border: 0;
}

tr:hover,
tr:focus {
  color: var(--color-text);
  background: var(--color-gray-lightest);
}

tr.color-warning:hover,
tr.color-warning:focus {
  color: var(--color-text);
  background: #fdf8ed;
}

tr.color-error:hover,
tr.color-error:focus {
  color: var(--color-text);
  background: #fcf4f2;
}

td {
  box-sizing: border-box;
  height: 4rem;
  padding: var(--space-xs) var(--space-m);
  text-align: left;
  /* LTR */
}

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

td .item-list ul {
  margin: 0;
}

/* This is required to win over specificity of [dir="rtl"] .item-list ul */
[dir="rtl"] td .item-list ul {
  margin: 0;
}

td.is-active {
  background: none;
}

/**
 * Target every .form-element input that parent is a form-item of a table cell.
 * This ignores the filter format select of the textarea editor.
 */
td > .form-item > .form-element,
td > .ajax-new-content > .form-item > .form-element {
  width: 100%;
}

/* Win over table-file-multiple-widget. */
th.is-disabled.is-disabled {
  color: var(--input--disabled-fg-color);
}

/* Force browsers to calculate the width of a 'select all' <th> element. */
th.select-all {
  width: 1px;
}

/**
 * Captions.
 */
.caption {
  margin-bottom: 1.25rem;
  /* 20px */
}

tfoot {
  font-weight: bold;
}

tfoot tr:last-child {
  border-bottom: 0;
}

tfoot tr:first-child td {
  border-top: 0.0625rem solid var(--color-gray-dark);
}

/**
 * Responsive table cells.
 */
.tableresponsive-toggle-columns {
  display: none;
}

.tabledrag-toggle-weight-wrapper {
  display: none;
  margin-top: var(--space-l);
  line-height: calc(28rem / 16);
  margin-bottom: var(--space-xs);
}

@media (min-width: 768px) {
  .tabledrag-toggle-weight-wrapper {
    display: block;
  }
}

.tabledrag-toggle-weight-wrapper + table,
.tabledrag-toggle-weight-wrapper + .tableresponsive-toggle-columns + table {
  margin-top: 0;
}

@media (min-width: 768px) and (max-width: 991.98px) {
  .table-responsive {
    overflow-x: auto;
  }
}

@media (max-width: 767.98px) {
  .table-mobile-stack thead {
    display: none;
  }
  .table-mobile-stack tr {
    display: block;
    padding: var(--space-m);
    background-color: transparent;
  }
  .table-mobile-stack tr.selected {
    background-color: var(--color-primary-lighter);
  }
  .table-mobile-stack tr.selected td {
    background-color: transparent;
  }
  .table-mobile-stack td {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    padding: var(--space-xs) 0;
    height: auto;
  }
  .table-mobile-stack td[data-label]:not([data-label=""]):before {
    content: attr(data-label) ":";
    margin-right: .7rem;
    font-weight: bold;
  }
  .table-mobile-stack td:empty, .table-mobile-stack td.views-field-operations:before {
    display: none;
  }
  .table-mobile-stack td ul,
  .table-mobile-stack td .form-type--boolean {
    margin: 0;
  }
  .table-mobile-stack td br {
    display: none;
  }
  .table-mobile-stack .tabledrag-handle {
    display: none;
  }
}
