/**
 * Estilo unificado de tablas MegaTraza (custom-table).
 * Referencia: tablas de procesos (mezcla, insumos, etc.).
 * Uso: class="table table-bordered table-sm table-striped custom-table"
 */

.custom-table {
    width: 100%;
    margin-bottom: 0;
    background-color: #ffffff;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 4px;
    /* hidden recortaba el borde inferior de la última fila */
    overflow: visible;
    font-size: 12px;
    line-height: 1.45;
    color: #333333;
    word-wrap: break-word;
}

.custom-table td,
.custom-table th {
    word-wrap: break-word;
    vertical-align: middle;
    border-color: #dee2e6 !important;
}

/* Borde inferior visible (Bootstrap + border-collapse: separate) */
.table-bordered.custom-table > :not(caption) > * > * {
    border-bottom-width: 1px;
    border-bottom-color: #dee2e6 !important;
}

.custom-table > tbody > tr:last-child > th,
.custom-table > tbody > tr:last-child > td,
.custom-table > tfoot > tr:last-child > th,
.custom-table > tfoot > tr:last-child > td {
    border-bottom: 1px solid #dee2e6 !important;
}

/* Encabezado vino corporativo */
.custom-table thead th,
.custom-table thead.table-light th,
.table.custom-table > :not(caption) > * > th {
    background: #7f0000 !important;
    color: #ffffff !important;
    font-weight: 600 !important;
    text-align: center;
    border-bottom: 1px solid #5c0000 !important;
    border-color: #6b0000 !important;
    white-space: nowrap;
}

.custom-table thead a {
    color: #ffffff !important;
    font-weight: 600;
    text-decoration: none;
}

.custom-table thead a:hover {
    color: #f8f9fa !important;
    text-decoration: underline;
}

/* Celdas compactas */
.custom-table.table-sm th,
.custom-table.table-sm td {
    padding: 0.4rem 0.5rem;
}

/* Rayas zebra (prioridad sobre Bootstrap table-striped) */
.table-striped.custom-table > tbody > tr:nth-of-type(odd) > * {
    --bs-table-bg-type: transparent;
    background-color: #f3f3f3 !important;
    box-shadow: none;
}

.table-striped.custom-table > tbody > tr:nth-of-type(even) > * {
    --bs-table-bg-type: transparent;
    background-color: #ffffff !important;
    box-shadow: none;
}

.custom-table:not(.table-striped) tbody tr:nth-child(odd) {
    background-color: #f3f3f3;
}

.custom-table:not(.table-striped) tbody tr:nth-child(even) {
    background-color: #ffffff;
}

.custom-table tbody tr:hover:not(.cloned-row) > * {
    background-color: #e8e8e8 !important;
    transition: background-color 0.15s ease;
}

/* Cantidades / valores numéricos destacados (azul, negrita) */
.custom-table tbody td.text-primary.fw-bold,
.custom-table tbody td.celda-cantidad,
.custom-table tbody td.celda-numero {
    color: #0d6efd !important;
    font-weight: 700 !important;
    text-align: center;
}

.custom-table tbody td.text-end.fw-bold,
.custom-table tbody td.text-end.fw-semibold {
    font-weight: 600;
}

/* Pie de tabla */
.custom-table tfoot th,
.custom-table tfoot td,
.custom-table tr.custom-table-tfoot th,
.custom-table tr.custom-table-tfoot td,
.custom-table tbody tr.custom-table-tfoot th,
.custom-table tbody tr.custom-table-tfoot td {
    background-color: #ececec !important;
    font-weight: 600;
    border-top: 2px solid #dee2e6;
}

/* Botones de acción en tablas */
.custom-table .btn-action {
    color: #660000;
    background-color: #f9f9f9;
    border: 1px solid #660000;
    transition: all 0.2s ease;
    padding: 0.3rem 0.5rem;
    border-radius: 4px;
}

.custom-table .btn-action:hover {
    background-color: #a52a2a;
    color: #ffffff;
    transform: scale(1.05);
}

/* Filas clonadas / destacadas (mezcla, empaque) — prioridad sobre zebra y hover */
.custom-table tbody tr.cloned-row {
    --cloned-row-bg: #e8f4fc;
    --cloned-row-bg-hover: #d4e9f7;
    --cloned-row-control-bg: #f4faff;
}

.table-striped.custom-table > tbody > tr.cloned-row:nth-of-type(odd) > *,
.table-striped.custom-table > tbody > tr.cloned-row:nth-of-type(even) > *,
.custom-table tbody tr.cloned-row > * {
    --bs-table-bg-type: transparent;
    background-color: var(--cloned-row-bg) !important;
    box-shadow: none;
}

.custom-table tbody tr.cloned-row:hover > * {
    background-color: var(--cloned-row-bg-hover) !important;
}

.custom-table tbody tr.cloned-row .form-select:not(:disabled),
.custom-table tbody tr.cloned-row .form-control:not(:disabled):not([readonly]) {
    background-color: var(--cloned-row-control-bg);
}

/* Acciones y controles centrados sin romper ancho de celda (evitar d-flex en <td>) */
.custom-table td.table-cell-actions,
.custom-table th.table-cell-actions {
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

.custom-table td.table-cell-actions .table-cell-actions-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

/* x-button-icon envuelve cada botón en div.d-flex justify-content-start */
.custom-table td.table-cell-actions .table-cell-actions-inner > .d-flex {
    display: inline-flex;
    justify-content: center;
    margin: 0;
}

.custom-table td.table-cell-center-input {
    text-align: center;
    vertical-align: middle;
}

.custom-table td.table-cell-center-input .table-cell-center-inner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Paginación asociada a listados con custom-table */
.pagination-custom .page-link {
    color: #660000;
}

.pagination-custom .page-item.active .page-link {
    background-color: #a52a2a;
    border-color: #660000;
}
