/*
 * Tarjeta de producto — componente único usado por la vidriera del home
 * ([abot_shop_home]), el buscador ([abot_product_search], renderizado por
 * product-search.js) y "últimos productos vistos" ([abot_recent_views]).
 * Antes cada uno tenía su propia copia casi idéntica de esta tarjeta —
 * quedó unificada acá para que las tres se vean exactamente igual y sea
 * un solo lugar donde ajustar el diseño.
 *
 * Paleta calcada de Mercado Libre: precio grande en negro, cuotas y envío
 * en verde ML (#00a650), % de descuento en verde junto al precio, marca
 * de vendedor verificado en azul ML (#3483fa).
 */

.abot-pgrid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
    gap: 16px;
}
/* En mobile, 2 por fila: una sola columna de tarjetas cuadradas hace que
   10 productos ocupen 6 pantallas de scroll. */
@media (max-width: 600px) {
    .abot-pgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .abot-pgrid .abot-pcard { padding: 8px 8px 12px; border-radius: 14px; }
    .abot-pgrid .abot-pcard-price { font-size: 18px; }
}

/* Firma visual propia de ElegiFácil — a propósito NO calca el look plano de
   Mercado Libre: esquinas suaves, borde con tinte de marca y sombra apenas
   coloreada. Columna flex para que todas las tarjetas de una fila midan lo
   mismo y el precio quede alineado aunque cambie el largo del título.
   Colores de texto con contraste AA: verde #00814a y gris #6b6b6b (el verde
   ML #00a650 y el #999 no llegan a 4.5:1 sobre blanco en texto chico). */
.abot-pcard {
    position: relative;
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid rgba(52, 131, 250, .12);
    border-radius: 16px;
    padding: 10px 10px 14px;
    box-shadow: 0 2px 12px rgba(26, 26, 26, .04);
    transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

.abot-pcard:hover {
    border-color: rgba(52, 131, 250, .35);
    box-shadow: 0 12px 28px rgba(52, 131, 250, .14);
    transform: translateY(-3px);
}
.abot-pcard:focus-visible {
    outline: 3px solid rgba(52, 131, 250, .45);
    outline-offset: 2px;
}

.abot-pcard-media {
    position: relative;
    margin-bottom: 12px;
    border-radius: 12px;
    background: #f6f6f7;
    overflow: hidden;
}

/* mix-blend-mode: las fotos de ML vienen con fondo blanco; así se funden
   con el gris del contenedor en vez de verse como un recuadro pegado. */
.abot-pcard img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    padding: 8px;
    mix-blend-mode: multiply;
    transition: transform .3s ease;
}
.abot-pcard:hover img { transform: scale(1.04); }

.abot-pcard-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #00814a;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 999px;
    letter-spacing: .01em;
}

.abot-pcard-badge-time {
    position: absolute;
    left: 8px;
    bottom: 8px;
    background: rgba(26, 26, 26, 0.78);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1.4;
}

.abot-pcard-title {
    font-size: 14px;
    line-height: 1.4;
    min-height: calc(1.4em * 2);
    margin: 0 2px 8px;
    color: #1a1a1a;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Precio original tachado — arriba del precio actual, como en ML */
.abot-pcard-original {
    margin: auto 2px 0;
    font-size: 14px;
    color: #6b6b6b;
    text-decoration: line-through;
    display: block;
}

.abot-pcard-price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex-wrap: wrap;
    margin: 0 2px;
}
/* Sin precio tachado arriba, el precio es el que se empuja al fondo. */
.abot-pcard-title + .abot-pcard-price-row { margin-top: auto; }

.abot-pcard-price {
    font-weight: 600;
    font-size: 21px;
    color: #1a1a1a;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}

.abot-pcard-discount {
    font-size: 14px;
    font-weight: 700;
    color: #00814a;
}

.abot-pcard-installments {
    font-size: 13px;
    color: #00814a;
    margin: 2px 2px 0;
}

.abot-pcard-shipping {
    font-size: 14px;
    color: #00814a;
    font-weight: 600;
    margin: 6px 2px 0;
}

.abot-pcard-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 6px 2px 0;
    font-size: 12.5px;
    color: #6b6b6b;
}
.abot-pcard-meta:empty { display: none; }

.abot-pcard-verified {
    color: #2968c8;
    font-weight: 600;
}

.abot-pcard-stock-out { font-weight: 700; color: #6b6b6b; }
.abot-pcard-stock-low { font-weight: 700; color: #b45309; }

/* Skeleton de carga (mientras llega la respuesta AJAX) */
.abot-pcard-skeleton {
    border: 1px solid #eee;
    border-radius: 16px;
    padding: 10px 10px 14px;
    background: #fff;
}
.abot-pcard-skeleton-img,
.abot-pcard-skeleton-line,
.abot-skel-line {
    display: block;
    border-radius: 6px;
    background: linear-gradient(90deg, #eee 25%, #f6f6f6 37%, #eee 63%);
    background-size: 400% 100%;
    animation: abot-shimmer 1.4s ease infinite;
}
.abot-pcard-skeleton-img { aspect-ratio: 1 / 1; margin-bottom: 12px; border-radius: 12px; }
.abot-pcard-skeleton-line { height: 12px; margin-bottom: 8px; }
.abot-pcard-skeleton-line.short,
.abot-skel-line.short { width: 60%; margin-bottom: 0; }
.abot-skel-line { height: 14px; width: 180px; max-width: 100%; margin-bottom: 8px; }
@keyframes abot-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ── Primitivas de interacción compartidas ─────────────────────────────────
   Usadas por el buscador general Y el buscador de regalos (y cualquier otra
   pantalla que hable con la IA): el wrapper con glow animado mientras
   "piensa", el indicador de "pensando", los chips de sugerencia, y las
   animaciones de entrada (pop-in para banners, cascada para tarjetas). */

.abot-glow-wrap {
    position: relative;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}
.abot-glow-wrap::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 16px;
    background: linear-gradient(120deg, #3483fa, #ffe600, #00a650, #3483fa);
    background-size: 300% 300%;
    opacity: 0;
    z-index: -1;
    transition: opacity .3s ease;
}
.abot-glow-wrap.is-thinking::before {
    opacity: 1;
    animation: abot-gradient-spin 3s linear infinite;
}
@keyframes abot-gradient-spin {
    0%   { background-position: 0% 50%; }
    100% { background-position: 300% 50%; }
}
.abot-glow-icon {
    display: flex;
    color: #3483fa;
    flex-shrink: 0;
}
.abot-glow-wrap.is-thinking .abot-glow-icon { animation: abot-icon-pulse 1.2s ease-in-out infinite; }
@keyframes abot-icon-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.abot-suggestions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #5c5c5c;
}
.abot-suggestion-chip {
    background: #f5f5f5;
    border: 1px solid #ececec;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-decoration: none; /* el chip también se reusa como <a> (búsquedas rápidas del hero) */
    cursor: pointer;
    transition: border-color .2s ease, background .2s ease, transform .2s ease;
}
.abot-suggestion-chip:hover {
    border-color: #3483fa;
    background: #f5f9ff;
    color: #2968c8;
    transform: translateY(-1px);
}

.abot-thinking {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #2968c8;
    margin: 0 0 18px;
}
.abot-thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3483fa;
    animation: abot-thinking-blink 1s ease-in-out infinite;
}
@keyframes abot-thinking-blink { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .3; transform: scale(.7); } }

.abot-pop-in { animation: abot-pop-in .35s cubic-bezier(.2,.8,.3,1.3) both; }
@keyframes abot-pop-in {
    from { opacity: 0; transform: translateY(-6px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.abot-card-enter { animation: abot-card-in .45s ease both; }
@keyframes abot-card-in {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .abot-glow-wrap.is-thinking::before,
    .abot-glow-wrap.is-thinking .abot-glow-icon,
    .abot-thinking-dot,
    .abot-pop-in,
    .abot-card-enter {
        animation: none;
    }
}

/* ── Tabs por categoría (usado por "Recomendados para vos" en el
   buscador de productos) — cada tab es un panel con su propia grilla
   scrolleable de .abot-pcard, cacheado un día completo del lado del
   servidor (ver ABot_ML_API::deals_by_category). ───────────────────────── */
.abot-tabs-title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.abot-tabs-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    margin-bottom: 18px;
    padding-bottom: 4px;
    scrollbar-width: none;
}
.abot-tabs-nav::-webkit-scrollbar { display: none; }
.abot-tab-btn {
    flex-shrink: 0;
    min-height: 44px;
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid #ececec;
    background: #fff;
    color: #444;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}
.abot-tab-btn:hover { border-color: #3483fa; transform: translateY(-1px); }
.abot-tab-btn.is-active {
    background: #2968c8;
    border-color: #2968c8;
    color: #fff;
}

.abot-tab-panel {
    opacity: 0;
    transition: opacity .3s ease;
}
.abot-tab-panel.is-active { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .abot-tab-panel { transition: none; }
}

/* ── Carrusel (usado por "Ideas para inspirarte" en el buscador de
   regalos, pero genérico — cualquier lista de .abot-pcard puede ir en un
   carrusel en vez de en una grilla). ────────────────────────────────────── */
.abot-carousel-head {
    margin-bottom: 14px;
}
.abot-carousel-head h2 {
    font-size: 17px;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}
/* Las flechas van centradas verticalmente sobre las tarjetas (como un
   carrusel de e-commerce de verdad), no arriba al lado del título — ahí
   quedaban perdidas y no se leían como controles del carrusel. */
.abot-carousel-body { position: relative; }
.abot-carousel-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid #ececec;
    background: #fff;
    color: #444;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0,0,0,.12);
    transition: border-color .2s ease, color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.abot-carousel-arrow[data-dir="-1"] { left: -8px; }
.abot-carousel-arrow[data-dir="1"] { right: -8px; }
.abot-carousel-arrow:hover { border-color: #3483fa; color: #3483fa; box-shadow: 0 6px 18px rgba(52,131,250,.22); }
.abot-carousel-arrow:hover:not(:disabled) { transform: translateY(-50%) scale(1.06); }
.abot-carousel-arrow:disabled { opacity: .35; cursor: default; pointer-events: none; }
.abot-carousel-arrow:disabled:hover { transform: translateY(-50%); }

@media (max-width: 640px) {
    .abot-carousel-arrow { display: none; } /* en touch se desliza con el dedo */
    .abot-carousel-track .abot-pcard { flex-basis: 46%; }
    .abot-carousel-arrow[data-dir="-1"] { left: -4px; }
    .abot-carousel-arrow[data-dir="1"] { right: -4px; }
}

.abot-carousel-track {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    /* Oculta la scrollbar nativa — la navegación es por las flechas o
       arrastrando, no hace falta mostrarla. */
    scrollbar-width: none;
}
.abot-carousel-track::-webkit-scrollbar { display: none; }
.abot-carousel-track .abot-pcard {
    flex: 0 0 196px;
    scroll-snap-align: start;
}

@media (max-width: 640px) {
    .abot-pgrid.abot-pgrid-scroll {
        display: flex;
        gap: 12px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 8px;
        -webkit-overflow-scrolling: touch;
    }
    .abot-pgrid.abot-pgrid-scroll .abot-pcard {
        flex: 0 0 44%;
        scroll-snap-align: start;
    }
}
