/* ============================================================
   TiendaPocket — Lista de Favoritos (tabla)
   Se carga en la página /favoritos/ y en la sección Favoritos
   de Mi Cuenta. Depende de las variables de main.css.
   ============================================================ */

/* ── Página ─────────────────────────────────────────────────────────────────── */
.tp-wishlist-page__title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .625rem;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: clamp(1.125rem, 2.4vw, 1.5rem);
    font-weight: 600;
}
.tp-wishlist-page__title-icon {
    flex: none;
    color: var(--color-accent, #6366f1);
}
.tp-wishlist-page__header {
    background: var(--color-surface, #f8fafc);
    border-bottom: 1px solid var(--color-border, #e2e8f0);
    padding: clamp(1.5rem, 4vw, 2.25rem) 0;
}
.tp-wishlist-page__header .container {
    justify-content: center;
}
.tp-wishlist-page__body {
    padding: clamp(2rem, 5vw, 3.5rem) 0 clamp(3rem, 7vw, 5rem);
}

/* ── Wrapper ────────────────────────────────────────────────────────────────── */
.tp-wl {
    --tp-wl-gap: clamp(.75rem, 1.5vw, 1.25rem);
    /* La tabla se apila cuando el espacio disponible es chico, no cuando lo es
       el viewport: así el panel angosto de Mi Cuenta usa las tarjetas apiladas
       en desktop igual que la página completa en mobile. */
    container-type: inline-size;
    container-name: tpwl;
}
/* El bloque alterna sus partes con el atributo `hidden`, pero varias llevan un
   `display` propio por clase, que le gana a la regla de user-agent. */
.tp-wl [hidden] { display: none; }
.tp-wl__table-wrap {
    /* La tabla es ancha: en pantallas medianas se desplaza sola en vez de
       desbordar el documento. En mobile pasa a tarjetas apiladas. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Tabla ──────────────────────────────────────────────────────────────────── */
.tp-wl__table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9375rem;
    /* Piso de ancho para que en contenedores angostos (Mi Cuenta) la tabla
       scrollee en su wrapper en vez de estrujar las columnas. */
    min-width: 46rem;
}
.tp-wl__table thead th {
    padding: 0 var(--tp-wl-gap) .875rem;
    text-align: left;
    font-family: var(--font-heading, inherit);
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--color-accent, #6366f1);
    white-space: nowrap;
    border-bottom: 1px solid var(--color-border, #e2e8f0);
}
.tp-wl__table thead th.tp-wl-cell--check { width: 2.5rem; padding-left: 0; }
.tp-wl__table thead th.tp-wl-cell--actions { text-align: right; padding-right: 0; }

.tp-wl-row + .tp-wl-row .tp-wl-cell { border-top: 1px solid var(--color-border, #e2e8f0); }
.tp-wl-cell {
    padding: 1.125rem var(--tp-wl-gap);
    vertical-align: middle;
}
.tp-wl-cell--check   { width: 2.5rem; padding-left: 0; }
.tp-wl-cell--product { width: 40%; min-width: 15rem; }
.tp-wl-cell--qty     { width: 6.5rem; }
.tp-wl-cell--price   { white-space: nowrap; }
.tp-wl-cell--stock   { white-space: nowrap; }
.tp-wl-cell--actions { padding-right: 0; }

/* ── Checkbox ───────────────────────────────────────────────────────────────── */
.tp-wl-check {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.tp-wl-check__input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.tp-wl-check__box {
    display: block;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--color-border, #e2e8f0);
    border-radius: 3px;
    background: var(--color-bg, #fff);
    transition: border-color var(--transition, .2s), background var(--transition, .2s);
}
.tp-wl-check:hover .tp-wl-check__box { border-color: var(--color-accent, #6366f1); }
.tp-wl-check__input:checked + .tp-wl-check__box {
    background: var(--color-accent, #6366f1) no-repeat center / 11px 11px;
    border-color: var(--color-accent, #6366f1);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}
.tp-wl-check__input:focus-visible + .tp-wl-check__box {
    outline: 2px solid var(--color-accent, #6366f1);
    outline-offset: 2px;
}

/* ── Celda producto ─────────────────────────────────────────────────────────── */
.tp-wl-product {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.tp-wl-product__thumb {
    flex: none;
    width: 64px;
    height: 64px;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    background: var(--color-surface, #f8fafc);
}
.tp-wl-product__thumb img,
.tp-wl-product__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.tp-wl-product__info {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    min-width: 0;
}
.tp-wl-product__title {
    font-weight: 500;
    line-height: 1.35;
    color: var(--color-accent, #6366f1);
    /* Mi Cuenta subraya los enlaces de su contenido; acá no corresponde. */
    text-decoration: none;
    transition: color var(--transition, .2s);
}
.tp-wl-product__title:hover { color: var(--color-accent-hover, #4f46e5); }
.tp-wl-product__sku {
    font-size: .75rem;
    color: var(--color-text-muted, #64748b);
}
.tp-wl-product__sku span { color: var(--color-text, #1e293b); }

/* ── Cantidad ───────────────────────────────────────────────────────────────── */
.tp-wl-qty {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    overflow: hidden;
    background: var(--color-bg, #fff);
}
.tp-wl-qty__btn {
    width: 26px;
    height: 34px;
    display: grid;
    place-items: center;
    font-size: 1rem;
    line-height: 1;
    color: var(--color-text-muted, #64748b);
    transition: color var(--transition, .2s), background var(--transition, .2s);
}
.tp-wl-qty__btn:hover {
    color: var(--color-bg, #fff);
    background: var(--color-accent, #6366f1);
}
.tp-wl-qty__input {
    width: 2.25rem;
    height: 34px;
    border: none;
    border-inline: 1px solid var(--color-border, #e2e8f0);
    text-align: center;
    font-size: .875rem;
    color: var(--color-text, #1e293b);
    background: transparent;
    -moz-appearance: textfield;
}
.tp-wl-qty__input::-webkit-outer-spin-button,
.tp-wl-qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tp-wl-qty__input:focus-visible { outline: 2px solid var(--color-accent, #6366f1); outline-offset: -2px; }

/* ── Precio ─────────────────────────────────────────────────────────────────── */
.tp-wl-price {
    font-weight: 600;
    color: var(--color-primary, #0f172a);
}
.tp-wl-price del { font-weight: 400; opacity: .55; margin-right: .35rem; }
.tp-wl-price ins { text-decoration: none; }

/* ── Estado de stock ────────────────────────────────────────────────────────── */
.tp-wl-stock {
    display: inline-flex;
    align-items: center;
    gap: .375rem;
    font-size: .875rem;
    font-weight: 500;
}
.tp-wl-stock--in,
.tp-wl-stock--backorder { color: var(--color-success, #10b981); }
.tp-wl-stock--low       { color: #d97706; }
.tp-wl-stock--out       { color: var(--color-text-muted, #64748b); }

/* ── Acciones de fila ───────────────────────────────────────────────────────── */
.tp-wl-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .5rem;
}
.tp-wl-icon-btn {
    flex: none;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-bg, #fff);
    color: var(--color-text, #1e293b);
    transition: border-color var(--transition, .2s), color var(--transition, .2s), background var(--transition, .2s);
}
.tp-wl-icon-btn:hover {
    border-color: var(--color-accent, #6366f1);
    color: var(--color-accent, #6366f1);
}
.tp-wl-icon-btn--danger:hover {
    border-color: var(--color-danger, #ef4444);
    color: var(--color-danger, #ef4444);
}

.tp-wl-atc {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 1.125rem;
    border: 1px solid var(--color-primary, #0f172a);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-primary, #0f172a);
    color: #fff;
    font-family: var(--font-heading, inherit);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: background var(--transition, .2s), border-color var(--transition, .2s), color var(--transition, .2s), opacity var(--transition, .2s);
}
.tp-wl-atc:hover {
    background: var(--color-accent, #6366f1);
    border-color: var(--color-accent, #6366f1);
    color: #fff;
}
.tp-wl-atc[disabled],
.tp-wl-atc.is-loading { opacity: .6; pointer-events: none; }
.tp-wl-atc--link { background: transparent; color: var(--color-primary, #0f172a); }
.tp-wl-atc--link:hover { color: #fff; }

/* Fila saliendo de la lista */
.tp-wl-row.is-removing {
    opacity: 0;
    transition: opacity .25s ease;
}

/* ── Barra de acciones ──────────────────────────────────────────────────────── */
.tp-wl__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border, #e2e8f0);
}
.tp-wl__bulk,
.tp-wl__main-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .625rem;
}

.tp-wl-select { position: relative; display: inline-flex; }
.tp-wl-select__field {
    appearance: none;
    -webkit-appearance: none;
    height: 40px;
    padding: 0 2.25rem 0 .875rem;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-bg, #fff);
    color: var(--color-text, #1e293b);
    font-size: .875rem;
    cursor: pointer;
}
.tp-wl-select__field:focus-visible { outline: 2px solid var(--color-accent, #6366f1); outline-offset: 2px; }
.tp-wl-select__arrow {
    position: absolute;
    right: .875rem;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--color-text-muted, #64748b);
}

.tp-wl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    height: 40px;
    padding: 0 1.25rem;
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: var(--radius-sm, 6px);
    background: var(--color-bg, #fff);
    color: var(--color-text, #1e293b);
    font-family: var(--font-heading, inherit);
    font-size: .6875rem;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
    transition: background var(--transition, .2s), border-color var(--transition, .2s), color var(--transition, .2s), opacity var(--transition, .2s);
}
.tp-wl-btn--ghost:hover {
    border-color: var(--color-accent, #6366f1);
    color: var(--color-accent, #6366f1);
}
.tp-wl-btn--dark {
    background: var(--color-primary, #0f172a);
    border-color: var(--color-primary, #0f172a);
    color: #fff;
}
.tp-wl-btn--dark:hover {
    background: var(--color-accent, #6366f1);
    border-color: var(--color-accent, #6366f1);
    color: #fff;
}
.tp-wl-btn[disabled],
.tp-wl-btn.is-loading { opacity: .6; pointer-events: none; }

/* ── Estado vacío / carga ───────────────────────────────────────────────────── */
.tp-wl__empty {
    text-align: center;
    padding: clamp(2.5rem, 8vw, 4.5rem) 1rem;
    color: var(--color-text-muted, #64748b);
}
.tp-wl__empty svg { display: block; margin: 0 auto 1.25rem; opacity: .25; }
.tp-wl__empty p { font-size: 1.0625rem; margin: 0 0 1.5rem; }

.tp-wl__loading { display: grid; place-items: center; padding: 3rem 1rem; }

/* ── Lista compartida ───────────────────────────────────────────────────────── */
.tp-wl--shared .tp-wl-cell--actions { text-align: right; }

/* ── Dentro de Mi Cuenta ────────────────────────────────────────────────────── */
.twm-favorites .tp-wl { --tp-wl-gap: .75rem; }
.twm-favorites .tp-wl-product__title { text-decoration: none; }

/* ── Espacio angosto: la tabla pasa a tarjetas apiladas ─────────────────────── */
@container tpwl (max-width: 780px) {
    .tp-wl__table,
    .tp-wl__table tbody,
    .tp-wl-row,
    .tp-wl-cell { display: block; width: auto; }

    .tp-wl__table { min-width: 0; }

    .tp-wl__table thead { display: none; }
    .tp-wl__table-wrap { overflow-x: visible; }

    .tp-wl-row {
        position: relative;
        border: 1px solid var(--color-border, #e2e8f0);
        border-radius: var(--radius-md, 10px);
        padding: 1rem;
        margin-bottom: .875rem;
    }
    .tp-wl-row + .tp-wl-row .tp-wl-cell { border-top: none; }

    .tp-wl-cell {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        padding: .5rem 0;
        min-width: 0;
    }
    /* Etiqueta de columna, tomada del data-label de cada celda */
    .tp-wl-cell[data-label]::before {
        content: attr(data-label);
        flex: none;
        font-family: var(--font-heading, inherit);
        font-size: .6875rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: var(--color-text-muted, #64748b);
    }

    /* El producto ocupa el ancho completo, sin etiqueta */
    .tp-wl-cell--product {
        padding-top: 0;
        padding-bottom: .875rem;
        border-bottom: 1px solid var(--color-border, #e2e8f0);
        margin-bottom: .25rem;
    }
    .tp-wl-cell--product::before { display: none; }
    .tp-wl-product { width: 100%; padding-right: 2rem; }

    /* El checkbox se ancla a la esquina de la tarjeta */
    .tp-wl-cell--check {
        position: absolute;
        top: 1rem;
        right: 1rem;
        padding: 0;
    }

    .tp-wl-cell--actions {
        padding-top: .875rem;
        margin-top: .25rem;
        border-top: 1px solid var(--color-border, #e2e8f0);
    }
    .tp-wl-cell--actions::before { display: none; }
    .tp-wl-actions { width: 100%; justify-content: flex-start; }
    .tp-wl-atc { flex: 1; }

    .tp-wl__toolbar { flex-direction: column; align-items: stretch; }
    .tp-wl__bulk > .tp-wl-select { flex: 1; }
    .tp-wl__bulk > .tp-wl-select .tp-wl-select__field { width: 100%; }
    .tp-wl__main-actions { flex-direction: column; align-items: stretch; }
}
