:root {
  --bg-tr-color: var(--lighter-tertiary);
  --bg-th-color: var(--secondary-color);
  --bg-td-col-color: var(--lighter-tertiary);
  --border-th-color: var(--darker-secondary);
  --border-td-col-color: var(--light-tertiary);
  --bg-tr-color-alter: var(--lightest-tertiary);
  --bg-seccion-color: var(--darker-tertiary); 
}

table {
  font-size: var(--p-size);
  border-collapse: collapse;
  margin: 1.2rem auto;
  width: 100%;
  outline: 1px solid var(--light-tertiary);
  outline-offset: -1px;
  border-radius: 4px;
  overflow: hidden;
  
  tbody tr:first-child td {
    border-top: none; 
    border-bottom: 0;
  }
  tr:last-child td {
    border-bottom: none !important; 
  }
  tr td:first-child {
    border-left: none !important; 
    border-bottom: 0;
  }
  tr td:last-child {
    border-right: none !important;  
  }

  & thead {
    & tr {
      & th {
        background-color: var(--bg-th-color);
        padding: 10px 15px;
        color: white;
        /*border: 1px solid var(--border-th-color);*/
        line-height: var(--p-line-height);
        vertical-align: middle;
        text-align: center;
      }
    }
  }

  & tbody {
    & tr {
      & td {
        vertical-align: middle;
        text-align: center;
        padding: 10px 15px;
        border: 1px solid var(--border-td-col-color);
        font-weight: var(--p-weight);
        line-height: var(--p-line-height);
      }
    }
  }
}

.aemps-tabla__00 {
  & thead {
    & tr {
      & th {
        background-color: transparent;
        color: #000;
        border-color: var(--border-td-col-color);
        border-bottom: 1px solid var(--border-td-col-color);
      }
    }
  }
}

.aemps-tabla__01 {
  & tr {
    &:nth-child(even) { 
      background-color: var(--bg-tr-color-alter); 
    }
  }
}

.aemps-tabla__02 {
  & td:first-child { 
    font-weight: bold;  
    }
  & td:first-child {
    background-color: var(--bg-td-col-color);
    border-color: var(--border-td-col-color);
    }
}

.aemps-tabla__legislacion,
.aemps-tabla__notas,
.aemps-tabla__03 {
  & td:first-child { 
    font-weight: bold;
  }
  & tr {
    &:nth-child(even) { 
      background-color: var(--bg-tr-color-alter); 
    }
  }
  & td:first-child {
    background-color: var(--bg-td-col-color);
    border-color: var(--border-td-col-color);
  }
}

/* Alineación izquierda para tablas de legislación y notas */
.aemps-tabla__legislacion,
.aemps-tabla__notas {
  td:nth-child(2) {
    text-align: left;
  }
}

.aemps-tabla__04 {
  tr td[rowspan] {
      background-color: var(--bg-td-col-color);
      font-weight: bold;
  }
  tr:nth-child(even) { 
    background-color: var(--bg-tr-color-alter);
  }
  tr:nth-child(odd) {
      background-color: white;
  }
}

.aemps-tabla__menor {
  width: 75%;
  }
.tabla__menor {
  width: 75%;
  margin: auto;
  }

.aemps-tabla__seccion {
  background-color: var(--bg-seccion-color) !important;
  padding: 10px 15px;
  color: white;
  /*border-top: 1px solid var(--bg-seccion-color) !important;*/
  border-bottom: 1px solid var(--bg-seccion-color) !important;
  font-weight: bold;
  }

/* Tabla antigua de legislación, modernizada */  
/*
.aemps-tabla__legislacion,
.aemps-tabla__notas {
  background-color: var(--bg-tr-color-alter);
  outline: 1px solid var(--light-tertiary);
  & thead {
    & tr {
      & th {
        background-color: var(--bg-tr-color);
        padding: 20px 20px;
        border-bottom: 1px solid var(--border-td-col-color);
        line-height: var(--p-line-height);
        vertical-align: middle;
        color: #000;
      }
    }
  }
  & tbody {
    & tr {
      & td {
        border: 0;
        border-bottom: 1px solid var(--border-td-col-color);
        padding: 20px 15px 20px 0;
      }
      & td:nth-child(2) {
        text-align: left;
        font-weight: var(--p-weight-b);
        color: var(--darker-tertiary);
      }
    }
    & tr:last-child {
      & td {
      border-bottom: 0 !important;
      }
    }
  }
}
*/

/* Alineación a la izquierda dentro de tablas */

.tabla-text-left {
  th,
  td {
    text-align: left;
  }
}
.tabla-text-left__00 {
  td {
    text-align: left;
  }
}
.tabla-text-left__01 {
  th:first-child,
  td:first-child {
    text-align: left;
  }
}
.tabla-text-left__02 {
  th:nth-child(2),
  td:nth-child(2) {
    text-align: left;
  }
}
.tabla-text-left__03 {
  th:nth-child(3),
  td:nth-child(3) {
    text-align: left;
  }
}
.tabla-text-left__04 {
  th:last-child,
  td:last-child {
    text-align: left;
  }
}

/* Específicos body y head */ 

.thead-left thead th {
    text-align: left;
}
.thead-center thead th {
    text-align: center;
}
.thead-right thead th {
    text-align: right;
}

.tbody-left tbody td {
  text-align: left;
}
.tbody-center tbody td {
    text-align: center;
}
.tbody-right tbody td {
  text-align: right;
}

/* Imágenes dentro de tablas */ 

table {
  & tbody {
    & tr {
      & td:has(img) {
        padding: 10px;
        line-height: 0;
        & img {
          /*width: 100%;*/
          border-radius: 4px;
          margin: 0 auto !important;
        }
      }
      & td div.img-aemps-gallery {
        margin-top: 0;
        gap: 10px;
        & div.img-aemps {
          margin: 0;
        }
      }
    }
  }
}

/* Tags dentro de tablas */ 

table tbody tr td .aemps-tags__container {
padding: 1rem 0 0.4rem;
}

table tbody tr td {
  & .aemps-tags__container {
  padding: 0.4rem 0 0.4rem;
  }
  a + div.aemps-tags__container {
  padding-top: 1rem;
  }
}
div.aemps-tags__container:not(:has(a)) {
  padding: 0!important;
}

/* Tablas duales */ 

.aemps-tabla-dual_container {
  display: flex;
  gap: 1.5rem;
}

@media only screen and (max-width: 768px) {
  .aemps-tabla-dual_container {
    display: inline;
  }
}

/* Titular destacado para tablas */

th.table-head {
  background-color: var(--darker-secondary);
}

/* Corrección rowspan */ 

td.no-bold {
  font-weight: var(--p-weight)!important;
}
td.bg-even { 
  background-color: var(--bg-tr-color-alter)!important;
}
td.bg-odd {
  background-color: white!important;
}

/* Overflow */

.table-overflow {
  overflow-x: auto;
  padding-left: .1rem;
  padding-right: .1rem;
}

@media only screen and (max-width: 768px) {
  .aemps-tabla__contenedor {
    max-width: 100%;
    overflow-x: auto;
  }
  .aemps-tabla__legislacion thead,
  .aemps-tabla__notas thead {
    visibility: collapse;
   }

  .aemps-tabla__legislacion thead th,
  .aemps-tabla__legislacion tbody tr,
  .aemps-tabla__notas thead th,
  .aemps-tabla__notas tbody tr {
    display: flex;
    flex-direction: column;
  }
  .aemps-tabla__legislacion thead th.col-3,
  .aemps-tabla__notas thead th.col-3 {
    max-width: 100%;
  }
  .aemps-tabla__legislacion thead th.col-9, 
  .aemps-tabla__notas thead th.col-9 {
    max-width: 100%;
  }
  .aemps-tabla__legislacion td:nth-child(1),
  .aemps-tabla__notas td:nth-child(1) {
    border-bottom: none;
    padding: 20px 0 0;
  }
  .aemps-tabla__legislacion td:nth-child(2),
  .aemps-tabla__notas td:nth-child(2) {
    border-bottom: 1px solid var(--border-td-col-color);
    padding: 20px;
  }
}