﻿/* ============================================================================
   quotation-cart-compact.css
   ──────────────────────────────────────────────────────────────────────────────
   Estilos para QuotationCartView compacto. Hereda tokens de quotation.css
   (--qt-*) y se carga después. Solo define las clases nuevas del cart
   rediseñado; la cabecera (qt-cart__header*) y el estado vacío (qt-cart__empty*)
   siguen usando las reglas existentes de quotation.css.

   CÓMO USAR:
     <link rel="stylesheet" href="css/quotation.css" />
     <link rel="stylesheet" href="css/quotation-layout-3col.css" />
     <link rel="stylesheet" href="css/quotation-cart-compact.css" />
   ============================================================================ */


/* ══════════════════════════════════════════════════════════════════════════
   1 · CONTENEDOR Y CABECERA
   ══════════════════════════════════════════════════════════════════════════ */

/* La cabecera del cart ya tiene estilos en quotation.css. Aquí solo
   ajustamos para que sea más compacta en el contexto de 3 columnas. */
.qt-shell--three-col .qt-cart__header {
    padding: 10px 16px;
    gap: 10px;
}

.qt-shell--three-col .qt-cart__header-icon {
    width: 32px;
    height: 32px;
}

    .qt-shell--three-col .qt-cart__header-icon .material-symbols-outlined {
        font-size: 18px;
    }

.qt-shell--three-col .qt-cart__header-title {
    font-size: .88rem;
}

.qt-shell--three-col .qt-cart__header-stats {
    font-size: .72rem;
}

.qt-shell--three-col .qt-cart__back-btn {
    padding: 6px 12px;
    font-size: .75rem;
    gap: 4px;
}

    .qt-shell--three-col .qt-cart__back-btn .material-symbols-outlined {
        font-size: 16px;
    }


/* ══════════════════════════════════════════════════════════════════════════
   2 · ENCABEZADO DE TABLA
   ══════════════════════════════════════════════════════════════════════════ */

.qt-cart__table-head {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) /* producto */
    minmax(100px, 1.2fr) /* bodegas */
    90px /* precio */
    48px /* cant */
    100px /* total */
    36px; /* acciones */
    gap: 0;
    align-items: center;
    padding: 0 16px;
    height: 32px;
    background: linear-gradient( 180deg, rgba(255, 255, 255, 0.95), rgba(248, 250, 253, 0.95) );
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--qt-border-hairline, rgba(0, 0, 0, .08));
    position: sticky;
    top: 0;
    z-index: 4;
}

.qt-cart__th {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--qt-text-tertiary, #94A3B8);
    white-space: nowrap;
    user-select: none;
}

.qt-cart__th--price,
.qt-cart__th--qty,
.qt-cart__th--total {
    text-align: right;
}

.qt-cart__th--actions {
    text-align: center;
}


/* ══════════════════════════════════════════════════════════════════════════
   3 · FILAS DE PRODUCTO
   ══════════════════════════════════════════════════════════════════════════ */

.qt-cart__rows {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.qt-cart__row {
    display: grid;
    grid-template-columns: minmax(180px, 2fr) minmax(100px, 1.2fr) 90px 48px 100px 36px;
    gap: 0;
    align-items: center;
    padding: 6px 16px;
    min-height: 48px;
    border-bottom: 1px solid var(--qt-border-hairline, rgba(0, 0, 0, .06));
    transition: background .15s ease, box-shadow .15s ease;
}

    .qt-cart__row:last-child {
        border-bottom: none;
    }

    .qt-cart__row:hover {
        background: rgba(37, 99, 235, .025);
    }

    /* Barra de acento al hover — guía la lectura */
    .qt-cart__row::before {
        content: '';
        position: absolute;
        left: 0;
        top: 4px;
        bottom: 4px;
        width: 3px;
        border-radius: 0 99px 99px 0;
        background: transparent;
        transition: background .15s ease;
    }

.qt-cart__row {
    position: relative;
}

    .qt-cart__row:hover::before {
        background: linear-gradient( 180deg, var(--qt-primary-400, #60A5FA), var(--qt-primary-600, #2563EB) );
    }

/* Fila con faltante de stock */
.qt-cart__row--warn {
    background: rgba(251, 191, 36, .06);
}

    .qt-cart__row--warn::before {
        background: linear-gradient( 180deg, #FBBF24, #D97706 ) !important;
    }


/* ══════════════════════════════════════════════════════════════════════════
   4 · CELDAS
   ══════════════════════════════════════════════════════════════════════════ */

.qt-cart__cell {
    min-width: 0;
    padding: 0 6px;
}

/* ── Producto ── */
.qt-cart__cell--product {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-left: 0;
}

.qt-cart__thumb {
    flex: 0 0 36px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--qt-bg-surface-2, #F8FAFC);
    border: 1px solid var(--qt-border-hairline, rgba(0, 0, 0, .08));
    display: grid;
    place-items: center;
}

    .qt-cart__thumb img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

    .qt-cart__thumb .material-symbols-outlined {
        font-size: 16px;
        color: var(--qt-text-tertiary, #94A3B8);
    }

.qt-cart__product-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.qt-cart__product-code {
    font-family: var(--qt-font-mono, ui-monospace, 'Cascadia Mono', Consolas, monospace);
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .04em;
    color: var(--qt-text-primary, #0F172A);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.qt-cart__product-name {
    font-size: .7rem;
    color: var(--qt-text-secondary, #64748B);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

/* ── Bodegas ── */
.qt-cart__cell--whs {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.qt-cart__wh-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: .62rem;
    font-weight: 500;
    letter-spacing: .02em;
    color: var(--qt-text-secondary, #64748B);
    background: var(--qt-bg-surface-2, #F1F5F9);
    border: 1px solid var(--qt-border-hairline, rgba(0, 0, 0, .06));
    white-space: nowrap;
    line-height: 1.6;
}

    .qt-cart__wh-chip strong {
        font-family: var(--qt-font-mono, ui-monospace, Consolas, monospace);
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        color: var(--qt-text-primary, #0F172A);
    }

.qt-cart__wh-chip--over {
    color: #92400E;
    background: #FEF3C7;
    border-color: rgba(245, 158, 11, .3);
}

    .qt-cart__wh-chip--over strong {
        color: #92400E;
    }

.qt-cart__wh-over-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #F59E0B;
    flex: 0 0 5px;
    animation: qt-cart-pulse 1.8s ease-in-out infinite;
}

@keyframes qt-cart-pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: .3;
    }
}

/* ── Precio ── */
.qt-cart__cell--price {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
}

.qt-cart__price-old {
    font-size: .6rem;
    color: var(--qt-text-tertiary, #94A3B8);
    text-decoration: line-through;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

.qt-cart__price-final {
    font-family: var(--qt-font-mono, ui-monospace, Consolas, monospace);
    font-size: .75rem;
    font-weight: 600;
    color: var(--qt-text-primary, #0F172A);
    font-variant-numeric: tabular-nums;
    line-height: 1.3;
}

.qt-cart__discount-tag {
    font-size: .55rem;
    font-weight: 700;
    color: #059669;
    background: #ECFDF5;
    padding: 0 4px;
    border-radius: 3px;
    line-height: 1.6;
    letter-spacing: .02em;
}

/* ── Cantidad ── */
.qt-cart__cell--qty {
    text-align: right;
}

.qt-cart__qty-val {
    font-family: var(--qt-font-mono, ui-monospace, Consolas, monospace);
    font-size: .82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--qt-text-primary, #0F172A);
}

/* ── Total ── */
.qt-cart__cell--total {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
}

.qt-cart__line-total {
    font-family: var(--qt-font-mono, ui-monospace, Consolas, monospace);
    font-size: .82rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--qt-text-primary, #0F172A);
    line-height: 1.3;
}

.qt-cart__line-saved {
    font-size: .58rem;
    font-weight: 600;
    color: #059669;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* ── Eliminar ── */
.qt-cart__cell--actions {
    display: flex;
    justify-content: center;
}

.qt-cart__remove-btn {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--qt-text-tertiary, #94A3B8);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .12s ease;
}

    .qt-cart__remove-btn .material-symbols-outlined {
        font-size: 16px;
    }

    .qt-cart__remove-btn:hover {
        background: #FEE2E2;
        color: #DC2626;
        transform: scale(1.08);
    }

    .qt-cart__remove-btn:active {
        transform: scale(.95);
    }

    .qt-cart__remove-btn:focus-visible {
        outline: 2px solid var(--qt-primary-500, #3B82F6);
        outline-offset: 2px;
    }


/* ══════════════════════════════════════════════════════════════════════════
   5 · ANIMACIÓN DE ENTRADA
   ══════════════════════════════════════════════════════════════════════════ */

.qt-cart__row {
    animation: qt-cart-row-in .25s ease both;
}

@keyframes qt-cart-row-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* Escalonado: máx 12 filas animadas, el resto aparece de golpe */
.qt-cart__row:nth-child(1) {
    animation-delay: .02s;
}

.qt-cart__row:nth-child(2) {
    animation-delay: .04s;
}

.qt-cart__row:nth-child(3) {
    animation-delay: .06s;
}

.qt-cart__row:nth-child(4) {
    animation-delay: .08s;
}

.qt-cart__row:nth-child(5) {
    animation-delay: .10s;
}

.qt-cart__row:nth-child(6) {
    animation-delay: .12s;
}

.qt-cart__row:nth-child(7) {
    animation-delay: .14s;
}

.qt-cart__row:nth-child(8) {
    animation-delay: .16s;
}

.qt-cart__row:nth-child(9) {
    animation-delay: .18s;
}

.qt-cart__row:nth-child(10) {
    animation-delay: .20s;
}

.qt-cart__row:nth-child(11) {
    animation-delay: .22s;
}

.qt-cart__row:nth-child(12) {
    animation-delay: .24s;
}

.qt-cart__row:nth-child(n+13) {
    animation-delay: .25s;
}


/* ══════════════════════════════════════════════════════════════════════════
   6 · ZEBRA SUTIL
   Filas pares con un tinte que no interfiere con el hover ni con el warn.
   ══════════════════════════════════════════════════════════════════════════ */

.qt-cart__row:nth-child(even):not(.qt-cart__row--warn) {
    background: rgba(248, 250, 253, .6);
}

    .qt-cart__row:nth-child(even):not(.qt-cart__row--warn):hover {
        background: rgba(37, 99, 235, .03);
    }


/* ══════════════════════════════════════════════════════════════════════════
   7 · RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 1279px) {
    .qt-cart__table-head,
    .qt-cart__row {
        grid-template-columns: minmax(140px, 2fr) minmax(80px, 1fr) 80px 40px 90px 32px;
    }

    .qt-cart__product-name {
        max-width: 120px;
    }
}

@media (max-width: 900px) {
    /* Colapsar bodegas debajo del producto */
    .qt-cart__table-head,
    .qt-cart__row {
        grid-template-columns: minmax(120px, 1fr) 72px 40px 80px 32px;
    }

    .qt-cart__th--whs,
    .qt-cart__cell--whs {
        display: none;
    }
}

@media (max-width: 600px) {
    .qt-cart__table-head {
        display: none;
    }

    .qt-cart__row {
        display: flex;
        flex-wrap: wrap;
        gap: 4px 12px;
        padding: 10px 12px;
    }

    .qt-cart__cell--product {
        flex: 1 1 100%;
    }

    .qt-cart__cell--whs {
        flex: 1 1 100%;
        display: flex !important;
    }

    .qt-cart__cell--price,
    .qt-cart__cell--qty,
    .qt-cart__cell--total {
        flex: 0 0 auto;
    }

    .qt-cart__cell--actions {
        flex: 0 0 auto;
        margin-left: auto;
    }
}


/* ══════════════════════════════════════════════════════════════════════════
   8 · REDUCED MOTION
   ══════════════════════════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
    .qt-cart__row {
        animation: none;
    }

    .qt-cart__wh-over-dot {
        animation: none;
    }
}
