/*
 * Tablas de líneas de formularios (CORE-005)
 * AppForm v1: table.sprdTbl   ·   FormMake: table.fmk-lines-table
 * Esquinas redondeadas y renglones suaves; el padding no cambia.
 * Bootstrap usa border-collapse: collapse, que no admite border-radius, así que
 * aquí se pasa a "separate" y se redondean la tabla y las celdas de las esquinas.
 * Sin overflow: hidden para no recortar el menú del autosearch de las líneas.
 */

:is(table.sprdTbl, table.fmk-lines-table) {
    --tbl-radius: 10px;
    --tbl-radius-in: 9px; /* radio interior (radio - borde) para las celdas */
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #e2e8f0;
    border-radius: var(--tbl-radius);
    background-color: #fff;
}

/* ---------- Cabecera ---------- */
/* El color va en las celdas (no en el tr) para que las esquinas redondeadas no muestren el fondo. */
:is(table.sprdTbl, table.fmk-lines-table) > thead > tr {
    background: transparent;
}
:is(table.sprdTbl, table.fmk-lines-table) > thead > tr > :is(th, td) {
    background-color: #344a65;
    color: #fff;
    font-weight: 600;
    border: 0;
}
:is(table.sprdTbl, table.fmk-lines-table) > thead > tr:first-child > :first-child { border-top-left-radius: var(--tbl-radius-in); }
:is(table.sprdTbl, table.fmk-lines-table) > thead > tr:first-child > :last-child { border-top-right-radius: var(--tbl-radius-in); }

/* ---------- Cuerpo: solo separador horizontal suave ---------- */
:is(table.sprdTbl, table.fmk-lines-table) > tbody > tr > :is(td, th) {
    border: 0;
    border-top: 1px solid #f1f5f9;
}
:is(table.sprdTbl, table.fmk-lines-table) > tbody > tr:first-of-type > :is(td, th) {
    border-top: 0;
}
:is(table.sprdTbl, table.fmk-lines-table) > tbody > tr:hover > :is(td, th) {
    background-color: #f8fafc;
}

/* ---------- Pie (Subtotal / IVA / Total en vistas v1) ---------- */
:is(table.sprdTbl, table.fmk-lines-table) > tfoot > tr > :is(td, th) {
    border: 0;
    border-top: 1px solid #e2e8f0;
    background-color: #f8fafc;
}

/* ---------- Esquinas inferiores ---------- */
/* Último renglón de la tabla. En FormMake el último <tr> es "Sin líneas" (oculto si hay líneas),
   por eso también se redondea el penúltimo. */
:is(table.sprdTbl, table.fmk-lines-table) > :is(tbody, tfoot):last-child > tr:is(:last-child, :nth-last-child(2)) > :first-child,
:is(table.sprdTbl, table.fmk-lines-table) > tfoot:last-child > tr:first-child > td[rowspan]:first-child {
    border-bottom-left-radius: var(--tbl-radius-in);
}
:is(table.sprdTbl, table.fmk-lines-table) > :is(tbody, tfoot):last-child > tr:is(:last-child, :nth-last-child(2)) > :last-child {
    border-bottom-right-radius: var(--tbl-radius-in);
}

/* Tabla sin renglones (cuerpo vacío al final): la cabecera es también el borde inferior. */
:is(table.sprdTbl, table.fmk-lines-table):has(> tbody:last-child):not(:has(> tbody > tr)) > thead > tr:last-child > :first-child {
    border-bottom-left-radius: var(--tbl-radius-in);
}
:is(table.sprdTbl, table.fmk-lines-table):has(> tbody:last-child):not(:has(> tbody > tr)) > thead > tr:last-child > :last-child {
    border-bottom-right-radius: var(--tbl-radius-in);
}
