/* =====================================================================
   table.css — Tabla de productos
   ---------------------------------------------------------------------
   .table-outer    → marco con border-radius + overflow: hidden (recorta
                     las 4 esquinas, incluidas las del cruce de barras).
   .table-wrapper  → scroll real (vertical y horizontal).
   thead           → sticky.
   ===================================================================== */

/* ---------------------------------------------------------------------
   Contenedor principal
   --------------------------------------------------------------------- */
.table-main-container {
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
    height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ---------------------------------------------------------------------
   Marco exterior: redondea y RECORTA las esquinas
   --------------------------------------------------------------------- */
.table-outer {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;

    border-radius: 12px;
    overflow: hidden;               /* ← esto recorta las 4 esquinas */

    border-left: 1px solid var(--header-blue);
    border-right: 1px solid var(--header-blue);
    border-bottom: 1px solid var(--header-blue);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    background-color: var(--color-table);
    transition: background-color 0.3s ease;
}

/* ---------------------------------------------------------------------
   Wrapper interno: scroll en ambos ejes
   --------------------------------------------------------------------- */
.table-wrapper {
    flex-grow: 1;
    min-height: 0;
    min-width: 0;
    overflow: auto;                 /* scroll vertical + horizontal */

    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
}

/* Scrollbars personalizadas */
.table-wrapper::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
.table-wrapper::-webkit-scrollbar-track {
    background: var(--scroll-track);
}
.table-wrapper::-webkit-scrollbar-thumb {
    background-color: var(--scroll-thumb);
    border-radius: 10px;
}
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: rgba(14, 31, 78, 0.85);
}
.table-wrapper::-webkit-scrollbar-corner {
    background: var(--scroll-track);
}

[data-theme="light"] .table-wrapper::-webkit-scrollbar-track {
    background: #e4e4e7;
}
[data-theme="light"] .table-wrapper::-webkit-scrollbar-corner {
    background: #e4e4e7;
}

/* ---------------------------------------------------------------------
   Tabla
   --------------------------------------------------------------------- */
#products-table {
    display: block;
    width: max-content;
    min-width: 100%;
    font-size: 14px;
    text-align: left;
}

/* Cabecera fija */
#products-table thead {
    display: block;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--header-blue);
    width: 100%;
}

#products-table thead tr,
#products-table tbody tr {
    display: flex;
    width: 100%;
    box-sizing: border-box;
}

#products-table th {
    box-sizing: border-box;
    color: #ffffff;
    font-weight: 600;
    padding: 14px 16px;
    user-select: none;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 2px solid rgba(0, 0, 0, 0.2);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    display: block;
    line-height: 20px;
    flex-shrink: 0;
}

#products-table th:last-child {
    border-right: none;
}

#products-table th .sort-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 12px;
    vertical-align: middle;
}

/* ---------------------------------------------------------------------
   Cuerpo
   --------------------------------------------------------------------- */
#products-table tbody {
    display: block;
    width: 100%;
    background-color: var(--color-table);
}

#products-table tbody tr {
    background-color: var(--color-table);
    color: var(--text-color);
    transition: background-color 0.2s ease, color 0.3s ease;
}

#products-table tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.03);
}

[data-theme="light"] #products-table tbody tr:nth-child(even) {
    background-color: rgba(0, 0, 0, 0.03);
}

#products-table tbody tr:hover {
    background-color: rgba(95, 123, 202, 0.15) !important;
}

#products-table td {
    box-sizing: border-box;
    padding: 12px 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    display: block;
    line-height: 21px;
    flex-shrink: 0;
}

[data-theme="light"] #products-table td {
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    border-right: 1px solid rgba(0, 0, 0, 0.08);
}

#products-table tbody tr td:last-child {
    border-right: none;
}

/* ---------------------------------------------------------------------
   Columna espaciadora final
   --------------------------------------------------------------------- */
#products-table [data-column="spacer"] {
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    border-right: none;
}

/* ---------------------------------------------------------------------
   Resize handle
   --------------------------------------------------------------------- */
.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: col-resize;
    z-index: 11;
}
.resize-handle:hover,
.resize-handle.resizing {
    background-color: #5f7bca;
}

/* ---------------------------------------------------------------------
   Interacción
   --------------------------------------------------------------------- */
.product-row {
    cursor: pointer;
}

.product-row.selected-row {
    background-color: rgba(95, 123, 202, 0.25) !important;
}