/* ============================================
   RESPONSIVE TABLE - Container Query Edition
   ============================================
   Usa CSS Container Queries para activar el
   modo fichas/tarjetas cuando el CONTENEDOR
   de la tabla mide menos de 800px, sin importar
   el ancho del viewport.
   ============================================ */

/* ============================================
   1. CONTENEDOR: cualquier padre directo
      de .tableresponsive se vuelve container
   ============================================ */
.card-body:has(.tableresponsive),
.container-responsive {
  container-type: inline-size;
  container-name: tablacontainer;
}

/* ============================================
   2. ESTILOS BASE (modo tabla normal)
   ============================================ */
.tableresponsive {
  width: 100%;
  border-collapse: collapse;
}

.tableresponsive td,
.tableresponsive th {
  padding: 12px 15px;
  border: 1px solid #ddd;
  text-align: left;
  font-size: 15px !important;
}

.tableresponsive th {
  background-color: #f5f5f5;
  color: #000000;
  font-weight: bold;
}

.tableresponsive tbody tr:nth-child(even) {
  background-color: #f5f5f5;
}

/* ============================================
   3. MODO FICHAS - Container Query (<800px)
   ============================================
   Se activa cuando el contenedor padre mide
   menos de 800px. Funciona perfectamente con
   dos columnas col-md-6 en pantallas de 1440px
   donde cada contenedor tiene ~650px.
   ============================================ */
@container tablacontainer (max-width: 800px) {

  .tableresponsive thead {
    display: none;
  }

  .tableresponsive,
  .tableresponsive tbody,
  .tableresponsive tr,
  .tableresponsive td {
    display: inline-block;
    width: 100%;
    font-size: 15px !important;
  }

  .tableresponsive tr {
    margin-bottom: 5px;
  }

  .tableresponsive td {
    text-align: left;
    padding-left: 5%;
    position: relative;
    font-size: 15px !important;
  }

  .tableresponsive td::before {
    content: attr(data-label);
    display: inline-block;
    position: relative;
    left: 0;
    width: 100%;
    padding-left: 5px;
    font-size: 15px !important;
    font-weight: bold;
    text-align: left;
  }

  .tableresponsive tfoot td::before {
    content: none;
    position: absolute;
    left: 0;
    width: 0%;
  }

  .tableresponsive tfoot td {
    text-align: center;
    padding-left: 5px;
    position: relative;
    font-size: 15px !important;
    width: 100%;
  }
}

/* ============================================
   4. FALLBACK - @media para navegadores que
      no soporten Container Queries (muy viejos)
   ============================================
   Se mantiene el media query original como
   respaldo. En navegadores modernos, el
   container query tiene prioridad por ser
   más específico al contexto.
   ============================================ */
@supports not (container-type: inline-size) {
  @media (max-width: 1080px) {

    .tableresponsive thead {
      display: none;
    }

    .tableresponsive,
    .tableresponsive tbody,
    .tableresponsive tr,
    .tableresponsive td {
      display: inline-block;
      width: 100%;
      font-size: 15px !important;
    }

    .tableresponsive tr {
      margin-bottom: 5px;
    }

    .tableresponsive td {
      text-align: left;
      padding-left: 5%;
      position: relative;
      font-size: 15px !important;
    }

    .tableresponsive td::before {
      content: attr(data-label);
      display: inline-block;
      position: relative;
      left: 0;
      width: 100%;
      padding-left: 5px;
      font-size: 15px !important;
      font-weight: bold;
      text-align: left;
    }

    .tableresponsive tfoot td::before {
      content: none;
      position: absolute;
      left: 0;
      width: 0%;
    }

    .tableresponsive tfoot td {
      text-align: center;
      padding-left: 5px;
      position: relative;
      font-size: 15px !important;
      width: 100%;
    }
  }
}