/**
 * @file
 * Styles for tables.
 */

table {
  width: 100%;
  margin: 0 0 20px;
  border-collapse: collapse;
}

caption {
  text-align: left; /* LTR */
  [dir="rtl"] & {
    text-align: right;
  }
}

th {
  padding: 10px 12px;
  text-align: left; /* LTR */
  [dir="rtl"] & {
    text-align: right;
  }
  thead & {
    text-transform: uppercase;
    color: #333;
    border: solid #bfbfba;
    border-width: 1px 0;
    background: #f5f5f2;
  }
}

tr {
  padding: 0.1em 0.6em;
  border-bottom: 1px solid #e6e4df;
  thead > & {
    border-bottom: 1px solid #000;
  }
  tbody &:hover,
  tbody &:focus {
    background: #f7fcff;
  }
  /* See colors.css. */
  tbody &.color-warning:hover,
  tbody &.color-warning:focus {
    background: #fdf8ed;
  }
  tbody &.color-error:hover,
  tbody &.color-error:focus {
    background: #fcf4f2;
  }
  table.no-highlight &.selected td {
    background: transparent;
  }
}

td,
th {
  vertical-align: middle;
}

td {
  padding: 10px 12px;
  text-align: left; /* LTR */
  word-wrap: break-word;
  overflow-wrap: break-word;
  [dir="rtl"] & {
    text-align: right;
  }
}

th > a {
  position: relative;
  display: block;
  /* It must match negative bottom padding of the parent <th>. */
  &::after {
    position: absolute;
    top: 0;
    right: 0;
    bottom: -10px; /* 1. */
    left: 0;
    display: block;
    content: "";
    -webkit-transition: all 0.1s;
    transition: all 0.1s;
    border-bottom: 2px solid transparent;
  }
}

th.is-active > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #004875;
  [dir="rtl"] & {
    padding-right: 0;
    padding-left: 15px;
  }
}

th.is-active img {
  position: absolute;
  top: 50%;
  right: 0; /* LTR */
  [dir="rtl"] & {
    right: auto;
    left: 0;
  }
}

th.is-active > a::after {
  border-bottom-color: #004875;
}

th > a:hover,
th > a:focus,
th.is-active > a:hover,
th.is-active > a:focus {
  text-decoration: none;
  color: #008ee6;
}

th > a:hover::after,
th > a:focus::after,
th.is-active > a:hover::after,
th.is-active > a:focus::after {
  border-bottom-color: #008ee6;
}

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

td.is-active {
  background: none;
}

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

.caption {
  margin-bottom: 1.2em;
}

@media screen and (max-width: 37.5em) {
  /* 600px */
  th.priority-low,
  td.priority-low,
  th.priority-medium,
  td.priority-medium {
    display: none;
  }
}

@media screen and (max-width: 60em) {
  /* 920px */
  th.priority-low,
  td.priority-low {
    display: none;
  }
  table {
    display: block;
    overflow: auto;
  }
}

/**
 * Target every .form-text input where its parent is a form-item inside a table
 * cell.
 */
td > .form-item > .form-text,
td > .ajax-new-content > .form-item > .form-text {
  width: 100%;
}

td > .form-item,
td > .ajax-new-content > .form-item {
  width: auto;
}
