/* ============================================================
   Gestión de Artículos (/intranet/articulos)
   Incluir en index.html / App.razor después del css de intranet,
   o pegar al final de ese archivo.
   ============================================================ */

.art-page .intranet-page-header {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.art-meta {
    font-size: 0.8rem;
    color: #6c757d;
}

/* ── Filtros ── */
.art-filtros {
    flex-wrap: wrap;
    align-items: flex-end;
    row-gap: 0.5rem;
}

.art-buscar {
    flex: 1 1 320px;
}

    .art-buscar .buscar-input {
        width: 100%;
    }

.art-cliente {
    flex: 0 1 300px;
    position: relative;
}

    .art-cliente .filtro-input {
        width: 100%;
    }

.art-toggles {
    flex-direction: row;
    gap: 1rem;
    align-items: center;
    padding-bottom: 0.35rem;
}

.art-precio-ctx {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    margin: 0.25rem 0 0.5rem;
}

.art-resultado-info {
    font-size: 0.8rem;
    color: #6c757d;
    margin: 0.25rem 0;
}

/* ── Selector de columnas ── */
.art-cols-dropdown {
    position: relative;
}

.art-cols-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
}

.art-cols-panel {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 1050;
    min-width: 220px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    padding: 0.5rem 0.25rem;
    max-height: 70vh;
    overflow-y: auto;
}

.art-cols-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    white-space: nowrap;
}

    .art-cols-item:hover {
        background: #f4f6fa;
    }

    .art-cols-item.disabled {
        opacity: 0.45;
        cursor: not-allowed;
    }

.art-cols-footer {
    border-top: 1px solid #eee;
    margin-top: 0.4rem;
    padding: 0.5rem 0.75rem 0;
    font-size: 0.8rem;
}

.art-export-cols {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0 0.5rem;
}

/* ── Tabla virtualizada (scrollea la página entera) ── */
.art-tabla-wrapper-page {
    overflow: visible;
    border: 1px solid #e3e6ea;
    border-radius: 6px;
}

.art-tabla {
    width: 100%;
    table-layout: fixed; /* anchos fijos por columna; la descripción se queda con el resto */
}

.art-col-cod {
    width: 105px;
}

.art-col-ean {
    width: 135px;
}

.art-col-descripcion {
    width: 440px;
}

.art-col-marcaLinea {
    width: 150px;
}

.art-col-stockComp {
    width: 95px;
}

.art-col-precio {
    width: 120px;
}

.art-col-deposito {
    width: 70px;
}

.art-col-fill { /* sin ancho: absorbe el sobrante a la derecha */
}

/* ── Monitores más chicos: se achican descripción / EAN / marca / imagen, sin ocultar nada ── */
@media (max-width: 1500px) {
    .art-col-ean {
        width: 125px;
    }

    .art-col-descripcion {
        width: 340px;
    }

    .art-col-marcaLinea {
        width: 130px;
    }

    .art-col-precio {
        width: 110px;
    }
}

@media (max-width: 1366px) {
    .art-col-ean {
        width: 118px;
    }

    .art-col-descripcion {
        width: 270px;
    }

    .art-col-marcaLinea {
        width: 120px;
    }

    .art-col-stockComp {
        width: 85px;
    }

    .art-col-precio {
        width: 105px;
    }

    .art-col-deposito {
        width: 60px;
    }

    .art-th-img,
    .art-img-cell {
        width: 70px;
    }

    .art-thumb-wrap,
    .art-thumb {
        width: 60px;
        height: 60px;
    }

    .art-tabla tbody tr {
        height: 72px;
    }

    .art-tabla td {
        padding-left: 6px;
        padding-right: 6px;
        font-size: 0.9rem;
    }

    .art-desc-txt {
        -webkit-line-clamp: 3;
        line-height: 1.2;
    }
}

/* Por debajo de eso, antes que perder columnas: scroll horizontal del listado */
@media (max-width: 1200px) {
    .art-tabla-wrapper-page {
        overflow-x: auto;
    }

    .art-tabla {
        min-width: 1000px;
    }
}

.art-tabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    box-shadow: inset 0 -1px 0 #dee2e6;
    white-space: nowrap;
}

.art-th {
    cursor: pointer;
    user-select: none;
}

    .art-th:hover {
        color: var(--color-primary, #00136f);
    }

    .art-th.sorted {
        color: var(--color-primary, #00136f);
    }

.art-sort {
    font-size: 0.65rem;
    margin-left: 0.25rem;
}

/* ── Filtro por marca (checkboxes) ── */
.art-marcas-n {
    display: inline-block;
    margin-left: 5px;
    padding: 0 6px;
    font-size: 0.7rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.08);
}

.art-marcas-dropdown .filtro-btn.activo {
    border-color: var(--color-primary, #00136f);
    color: var(--color-primary, #00136f);
    font-weight: 600;
}

.art-marcas-panel {
    min-width: 260px;
    max-width: 340px;
    padding-top: 0.4rem;
}

.art-marcas-buscar {
    width: calc(100% - 1rem);
    margin: 0 0.5rem 0.4rem;
    font-size: 0.85rem;
}

.art-marcas-lista {
    max-height: 50vh;
    overflow-y: auto;
}

    .art-marcas-lista .art-cols-item span {
        white-space: normal;
    }

.art-marcas-footer {
    display: flex;
    justify-content: space-between;
}

/* Variante compacta dentro del th Marca / Línea */
.art-marcas-compacto {
    display: block;
    margin-top: 3px;
}

.art-marcas-btn-th {
    display: block;
    width: 100%;
    padding: 1px 6px;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    text-align: left;
    color: #495057;
    background: #fff;
    border: 1px solid #cfd6df;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

    .art-marcas-btn-th.activo,
    .art-th.art-th-filtrado .art-marcas-btn-th {
        border-color: var(--color-primary, #00136f);
        color: var(--color-primary, #00136f);
        font-weight: 600;
    }

.art-marcas-compacto .art-cols-panel {
    left: 0;
    right: auto;
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    color: #212529;
}

.art-tabla tbody tr {
    height: 72px;
}

.art-tabla td {
    padding-left: 6px;
    padding-right: 6px;
    font-size: 0.9rem;
}

.art-desc-txt {
    -webkit-line-clamp: 3;
    line-height: 1.2;
}

}

/* Por debajo de eso, antes que perder columnas: scroll horizontal del listado */
@media (max-width: 1200px) {
    .art-tabla-wrapper-page {
        overflow-x: auto;
    }

    .art-tabla {
        min-width: 1000px;
    }
}

.art-tabla thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #fff;
    box-shadow: inset 0 -1px 0 #dee2e6;
    white-space: nowrap;
}

.art-th {
    cursor: pointer;
    user-select: none;
}

    .art-th:hover {
        color: var(--color-primary, #00136f);
    }

    .art-th.sorted {
        color: var(--color-primary, #00136f);
    }

.art-sort {
    font-size: 0.65rem;
    margin-left: 0.25rem;
}

/* Filtro por marca dentro del encabezado Marca / Línea */
.art-th-marca {
    display: block;
    width: 100%;
    max-width: 100%;
    margin-top: 3px;
    padding: 1px 4px;
    font-size: 0.75rem;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #495057;
    background: #fff;
    border: 1px solid #cfd6df;
    border-radius: 4px;
    cursor: pointer;
}

.art-th.art-th-filtrado .art-th-marca {
    border-color: var(--color-primary, #00136f);
    color: var(--color-primary, #00136f);
    font-weight: 600;
}

.art-tabla tbody tr {
    height: 90px;
}

.art-tabla td {
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 8px;
    padding-right: 8px;
}

    /* Fuente FORZADA (!important): el ancho de la columna se calcula en rem asumiendo esta fuente,
   y hay reglas del tema (.intranet-tabla td) que si no la pisan. */
    .art-tabla td.art-cod {
        font-family: Consolas, "Courier New", ui-monospace, Menlo, monospace !important;
        font-size: 0.85rem !important;
        letter-spacing: 0 !important;
    }

.art-ean {
    font-size: 0.85rem;
    color: #555;
}

/* Descripción: hasta 2 líneas (el clamp va en el span, así el td sigue centrando verticalmente) */
.art-desc {
    white-space: normal !important;
}

.art-desc-txt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

/* Zebra (más marcada) + separador entre filas */
.art-tabla tbody td {
    border-bottom: 1px solid #e3e6ea;
}

.art-tabla tbody tr:nth-child(even) td {
    background: #eef1f6;
}

.art-tabla tbody tr:hover td {
    background: #e2e8f3;
}

.art-cero {
    color: #999;
}

/* Inhabilitados: fondo rojizo, borde izquierdo, texto apagado y badge (gana sobre la zebra) */
.art-tabla tbody tr.art-row-inhabilitado td,
.art-tabla tbody tr.art-row-inhabilitado:nth-child(even) td {
    background: #fff1f1;
    color: #8a8a8a;
}

.art-tabla tbody tr.art-row-inhabilitado:hover td {
    background: #ffe6e6;
}

.art-row-inhabilitado td:first-child {
    box-shadow: inset 4px 0 0 #dc3545;
}

.art-row-inhabilitado .art-thumb {
    filter: grayscale(1);
    opacity: 0.6;
}

/* En su propia línea debajo del código: si va inline, el td (nowrap + ellipsis) recorta el código y esconde el badge */
.art-badge-inh {
    display: table;
    margin-top: 4px;
    line-height: 1.3;
    padding: 1px 6px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #fff;
    background: #dc3545;
    border-radius: 3px;
    font-family: system-ui, sans-serif;
}

.art-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    text-decoration: underline dotted;
    cursor: pointer;
}

    .art-link:hover {
        color: var(--color-primary, #00136f);
    }

/* ── Celdas de dos líneas (Marca/Línea, Stock/Comp., Lista/Bonif.) ── */
.art-dos-lineas {
    line-height: 1.25;
}

    .art-dos-lineas .art-l1,
    .art-dos-lineas .art-l2 {
        display: block;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .art-dos-lineas .art-l2 {
        font-size: 0.78rem;
        color: #6c757d;
    }

.art-stock {
    font-weight: 600;
    font-size: 1rem;
}

.art-stock-neg {
    color: #dc3545 !important;
}

.art-precio {
    font-weight: 600;
}

.art-precio-cell {
    line-height: 1.2;
    white-space: nowrap;
}

    .art-precio-cell .art-l1,
    .art-precio-cell .art-l2 {
        display: block;
    }

.art-precio-lista {
    color: #6c757d;
    text-decoration: line-through;
    font-size: 0.85rem;
}

.art-precio-bonif {
    font-size: 0.75rem;
    color: #b45309;
}

.art-depo {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
}

.art-depo-sin {
    color: #999;
    font-style: italic;
}

/* ── Imagen: thumb + popover al hover ── */
.art-th-img,
.art-img-cell {
    width: 92px;
    padding: 4px 6px !important;
}

.art-thumb-wrap {
    position: relative;
    width: 80px;
    height: 80px;
    cursor: zoom-in;
}

.art-thumb {
    width: 80px;
    height: 80px;
    object-fit: contain;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #eee;
    display: block;
}

.art-thumb-empty {
    background: #f4f4f4;
    border-style: dashed;
}

.art-thumb-pop {
    position: fixed;
    z-index: 1100;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    padding: 4px;
    pointer-events: none;
}

    .art-thumb-pop img {
        width: 260px;
        height: 260px;
        object-fit: contain;
        display: block;
    }

/* ── Lightbox ── */
.art-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
}

.art-lightbox-inner {
    position: relative;
    max-width: min(90vw, 900px);
    max-height: 90vh;
    cursor: default;
    text-align: center;
}

    .art-lightbox-inner img {
        max-width: 100%;
        max-height: 80vh;
        object-fit: contain;
        background: #fff;
        border-radius: 6px;
    }

.art-lightbox-close {
    position: absolute;
    top: -36px;
    right: 0;
}

.art-lightbox-caption {
    color: #fff;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* ── Modales ── */
.art-modal {
    background: rgba(0, 0, 0, 0.45);
    z-index: 1200;
}

.art-comp-resumen {
    display: flex;
    gap: 1.5rem;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #f4f6fa;
    border-radius: 6px;
}

.art-comp-tabla {
    width: 100%;
}

    /* Pedido desde el que se abrió el modal (detalle de pedido) */
    .art-comp-tabla tr.art-comp-actual td {
        background: #fff8e1;
        font-weight: 600;
    }

.art-comp-actual-tag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #7a5a00;
    background: #ffe08a;
    border-radius: 3px;
    vertical-align: middle;
}

/* ── Detalle de pedido: columnas Stock / Comp. ── */
.detalle-tabla td.det-stock,
.detalle-tabla th.det-stock {
    text-align: center;
    white-space: nowrap;
}

    .detalle-tabla td.det-stock .det-stock-num {
        display: block;
        font-weight: 600;
    }

    .detalle-tabla td.det-stock .det-stock-comp {
        display: block;
        font-size: 0.8rem;
        color: #6c757d;
    }

        .detalle-tabla td.det-stock .det-stock-comp .art-link {
            font-size: 0.8rem;
            padding: 0;
        }

    .detalle-tabla td.det-stock .det-stock-neg {
        color: #dc3545;
    }

/* Subtítulos Pendientes / Completos dentro del detalle */
.detalle-tabla tr.det-grupo td {
    padding: 0.45rem 0.6rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #6c757d;
    background: #f4f6fa;
    border-top: 1px solid #e3e6ea;
    border-bottom: 1px solid #e3e6ea;
}

.detalle-tabla tr.det-grupo-pendientes td {
    color: #b02a37;
    background: #fff5f5;
}

.detalle-tabla tr.det-grupo-completos td {
    color: #1a7f4b;
    background: #f2faf5;
}

.det-grupo-n {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    font-size: 0.7rem;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.08);
}

/* Renglón sin pendiente: el stock no decide nada → atenuado */
.detalle-tabla tr.det-sin-pendiente td.det-stock {
    opacity: 0.45;
}

.art-export-extras-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6c757d;
    margin: 0.75rem 0 0.25rem;
}

/* ── Auto-refresh ── */
.art-refresh-estado {
    margin-left: 0.5rem;
    color: #6c757d;
}

.art-refresh-error {
    color: #b45309;
}

/* Destello en las filas cuyo stock/precio/maestro cambió en el último ciclo.
   Dos clases idénticas que se alternan por generación, para que la animación se dispare cada vez. */
@keyframes art-flash {
    0% {
        background-color: #fff3c4;
    }

    100% {
        background-color: transparent;
    }
}

.art-tabla tbody tr.art-flash-a td,
.art-tabla tbody tr.art-flash-b td {
    animation: art-flash 2.5s ease-out;
}

/* ── Búsqueda flotante (cuando la barra de filtros scrolleó fuera de pantalla) ── */
.art-buscar-flotante {
    position: fixed;
    top: 12px;
    left: calc(var(--intranet-sidebar-w, 52px) + 16px); /* a la derecha del sidebar; ajustá la var si el ancho es otro */
    z-index: 1100; /* sobre el thead sticky (2) y el popover de imagen */
    display: flex;
    align-items: center;
    gap: 6px;
    width: 340px;
    padding: 6px 8px;
    background: #fff;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    animation: art-flotante-in 0.15s ease-out;
}

    .art-buscar-flotante .buscar-input {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
    }

.art-buscar-flotante-x {
    border: none;
    background: none;
    color: #6c757d;
    font-size: 0.9rem;
    line-height: 1;
    padding: 2px 4px;
    cursor: pointer;
}

    .art-buscar-flotante-x:hover {
        color: #dc3545;
    }

.art-buscar-flotante-n {
    flex: 0 0 auto;
    font-size: 0.75rem;
    color: #6c757d;
    padding: 1px 7px;
    background: #f4f6fa;
    border-radius: 8px;
}

@keyframes art-flotante-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}
