/* =====================================================================
 * FullGrid: CARD VIEW en celular (<= 767px)
 * Cada fila de la grilla se muestra como una tarjeta "Titulo: valor".
 * Computadora y tablet siguen viendo la tabla normal.
 * Requiere fullgrid.jquery.js con data-label en las celdas (clase fg-cards).
 * Para que una grilla siga como tabla en celular: tCardView: false
 * ===================================================================== */
@media (max-width: 767.98px) {

    /* la tabla deja de ser tabla */
    table.fullgrid.fg-cards,
    table.fullgrid.fg-cards > thead,
    table.fullgrid.fg-cards > tbody,
    table.fullgrid.fg-cards > tfoot { display: block; width: 100% !important; border: 0 !important; }
    table.fullgrid.fg-cards { background: transparent !important; margin: 0; }

    /* cabecera de titulos: no se usa (cada tarjeta trae sus titulos) */
    table.fullgrid.fg-cards > thead > tr:first-child { display: none; }

    /* filtros: uno debajo de otro, cada uno con su titulo */
    table.fullgrid.fg-cards > thead > tr:nth-child(2) { display: block; padding: 8px 0 4px; }
    table.fullgrid.fg-cards > thead > tr:nth-child(2) > th { display: none; }
    table.fullgrid.fg-cards > thead > tr:nth-child(2) > th.fg-filtro {
        display: flex !important; align-items: center; gap: 10px;
        height: auto !important; padding: 3px 0 !important; border: 0 !important; background: transparent !important;
    }
    table.fullgrid.fg-cards > thead > tr:nth-child(2) > th.fg-filtro::before {
        content: attr(data-label); flex: 0 0 34%; font-size: 12px; font-weight: 600; opacity: .75; text-align: left;
    }
    table.fullgrid.fg-cards > thead > tr:nth-child(2) > th.fg-filtro > .input-group { flex: 1 1 auto; min-width: 0; }

    /* cada fila es una tarjeta */
    table.fullgrid.fg-cards > tbody > tr {
        display: flex; flex-direction: column;
        border: 1px solid rgba(120, 130, 145, .35); border-radius: 10px;
        margin: 0 0 10px; padding: 8px 12px; background-clip: padding-box;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
    }
    /* titulo a la izquierda (40%), contenido a la derecha; el contenido puede bajar de linea */
    table.fullgrid.fg-cards > tbody > tr > td {
        display: block; position: relative;
        width: auto !important; min-height: 30px; padding: 6px 0 6px 42% !important;
        border: 0 !important; border-bottom: 1px dashed rgba(120, 130, 145, .25) !important;
        text-align: left !important; background: transparent !important;
        white-space: normal !important; word-break: break-word; overflow-wrap: anywhere;
    }
    table.fullgrid.fg-cards > tbody > tr > td::before {
        content: attr(data-label); position: absolute; left: 0; top: 6px; width: 39%;
        font-weight: 600; font-size: 12px; opacity: .75; white-space: normal;
    }
    table.fullgrid.fg-cards > tbody > tr > td:not([data-label]),
    table.fullgrid.fg-cards > tbody > tr > td[data-label=""] { padding-left: 0 !important; }
    table.fullgrid.fg-cards > tbody > tr > td:not([data-label])::before,
    table.fullgrid.fg-cards > tbody > tr > td[data-label=""]::before { content: none; }
    table.fullgrid.fg-cards > tbody > tr > td * { max-width: 100%; }
    table.fullgrid.fg-cards > tbody > tr > td img { height: auto; max-height: 90px; width: auto; }
    table.fullgrid.fg-cards > tbody > tr > td input.form-control,
    table.fullgrid.fg-cards > tbody > tr > td select.form-control { width: 100% !important; }

    /* arriba: numero de fila; abajo: acciones */
    table.fullgrid.fg-cards > tbody > tr > td.fg-num {
        order: -2; border-bottom: 0 !important; padding: 0 0 2px !important; min-height: 0; font-size: 12px; opacity: .6;
    }
    table.fullgrid.fg-cards > tbody > tr > td.fg-num::before { content: "#"; position: static; width: auto; }
    table.fullgrid.fg-cards > tbody > tr > td.fg-check { order: -1; padding-left: 0 !important; border-bottom: 0 !important; text-align: left !important; }
    table.fullgrid.fg-cards > tbody > tr > td.fg-acciones {
        order: 99; padding: 8px 0 0 !important; border-bottom: 0 !important; text-align: right !important;
    }
    table.fullgrid.fg-cards > tbody > tr > td.fg-acciones .dropdown-menu { right: 0; left: auto; }
    table.fullgrid.fg-cards > tbody > tr > td:last-of-type:not(.fg-acciones) { border-bottom: 0 !important; }

    /* sin registros */
    table.fullgrid.fg-cards > tbody > tr > td[colspan] { display: block; text-align: center; border: 0 !important; }
    table.fullgrid.fg-cards > tbody > tr:has(> td[colspan]) { border: 0; box-shadow: none; padding: 0; }

    /* totales (tfoot): como una tarjeta resumen */
    table.fullgrid.fg-cards > tfoot > tr { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px 14px; padding: 8px 12px; }
    table.fullgrid.fg-cards > tfoot > tr > td,
    table.fullgrid.fg-cards > tfoot > tr > th { display: block; border: 0 !important; padding: 0 !important; width: auto !important; }
    table.fullgrid.fg-cards > tfoot > tr > td:empty,
    table.fullgrid.fg-cards > tfoot > tr > th:empty { display: none; }

    /* el contenedor no debe agregar desplazamiento lateral */
    .table-responsive:has(> table.fullgrid.fg-cards) { overflow-x: visible; }

    /* barra superior y paginacion acomodadas al ancho */
    .fullgrid-dt-toolbar { float: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
    .fullgrid-dt-toolbar-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
    .fullgrid-dt-toolbar-footer > * { float: none !important; width: auto !important; max-width: 100%; padding: 0 !important; }
    .fullgrid_paginate, .fullgrid-dt-toolbar-footer .pagination { float: none; margin: 0; }
}
