/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Brand colors */
    --primary: #10b981;
    --primary-dark: #059669;
    --primary-light: #d1fae5;
    --primary-bg: #ecfdf5;

    /* Neutrals */
    --bg: #f9fafb;
    --white: #ffffff;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;

    /* Accents */
    --discount: #fb923c;
    --discount-bg: #fed7aa;
    --green-tag: #d1fae5;
    --green-text: #065f46;
    --blue: #3b82f6;
    --pink: #ec4899;
    --star: #fbbf24;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.05), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 6px 16px -4px rgba(16, 24, 40, 0.08), 0 2px 4px -1px rgba(16, 24, 40, 0.05);
    --shadow-lg: 0 18px 30px -10px rgba(16, 24, 40, 0.12), 0 8px 12px -4px rgba(16, 24, 40, 0.05);
    --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, 0.18);
    --shadow-glow: 0 0 0 4px rgba(16, 185, 129, 0.12);
    --scrollbar-size: 8px;
    --scrollbar-thumb: rgba(16, 185, 129, 0.42);
    --scrollbar-thumb-hover: rgba(5, 150, 105, 0.68);
    --scrollbar-track: rgba(241, 245, 249, 0.72);

    /* Spacing */
    --radius: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-2xl: 24px;

    /* Easing */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}

* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

.categories-scroll,
.thumbnails-large,
.description-content,
.offers-grid,
.related-list,
.product-gallery-col {
    scrollbar-gutter: stable;
}

*::-webkit-scrollbar {
    width: var(--scrollbar-size);
    height: var(--scrollbar-size);
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border: 2px solid transparent;
    border-radius: 999px;
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
    background-clip: padding-box;
}

*::-webkit-scrollbar-corner {
    background: transparent;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
img, svg { display: block; max-width: 100%; }
ul { list-style: none; }
input { font-family: inherit; }

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ===== HEADER ===== */
.header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.6);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow 0.3s var(--ease-out), background 0.3s var(--ease-out);
}

.header.scrolled {
    box-shadow: var(--shadow-md);
    background: rgba(255, 255, 255, 0.95);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.menu-toggle {
    width: 28px;
    height: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    cursor: pointer;
}

.menu-toggle span {
    display: block;
    width: 100%;
    height: 2.5px;
    background: var(--text);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.open span:nth-child(1) {
    transform: translateY(10px) rotate(45deg);
}
.menu-toggle.open span:nth-child(2) {
    opacity: 0;
}
.menu-toggle.open span:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-img {
    height: 38px;
    width: auto;
}

.nav-desktop {
    display: none;
    gap: 32px;
    align-items: center;
    flex: 1;
    justify-content: center;
}

.nav-link {
    color: var(--text);
    font-weight: 500;
    font-size: 15px;
    padding: 8px 4px;
    position: relative;
    transition: color 0.2s;
}

.nav-link:hover { color: var(--primary); }

.nav-link.active {
    color: var(--primary);
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text);
    border-radius: 50%;
    transition: background 0.2s;
}

.icon-btn:hover { background: var(--border-light); }

.btn-ingresar {
    padding: 10px 22px;
    border: 2px solid var(--primary);
    color: var(--primary);
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.25s var(--ease-out);
    background: var(--white);
    position: relative;
    overflow: hidden;
}

.btn-ingresar:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: 0 8px 20px -6px rgba(16, 185, 129, 0.5);
}

.btn-ingresar:active { transform: translateY(0); }

/* Mobile navigation */
.nav-mobile {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 16px 20px;
    background: var(--white);
    border-top: 1px solid var(--border-light);
}

.nav-mobile.open { display: flex; }

.nav-mobile .nav-link {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}

.btn-mobile {
    margin-top: 12px;
    align-self: flex-start;
}

@media (max-width: 767px) {
    .container {
        padding: 0 12px;
    }

    .header-container {
        padding: 12px 16px;
        gap: 12px;
    }

    .logo-img {
        height: 30px;
        max-width: 112px;
    }

    .header-actions {
        gap: 8px;
        flex-shrink: 0;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .btn-ingresar {
        padding: 8px 16px;
        font-size: 14px;
        white-space: nowrap;
    }
}

@media (max-width: 360px) {
    .container {
        padding: 0 10px;
    }

    .header-container {
        padding: 10px 12px;
        gap: 9px;
    }

    .logo-img {
        height: 28px;
        max-width: 96px;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
    }

    .btn-ingresar {
        padding: 7px 12px;
        font-size: 13px;
    }
}

/* ===== HERO ===== */
.hero {
    padding: 36px 0 24px;
    background:
        radial-gradient(ellipse 80% 50% at 50% 0%, rgba(16, 185, 129, 0.15), transparent 70%),
        linear-gradient(180deg, var(--primary-bg) 0%, var(--bg) 100%);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.08), transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 8px;
    line-height: 1.15;
    letter-spacing: -0.02em;
    position: relative;
}

.hero-subtitle {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    position: relative;
}

.search-bar {
    background: var(--white);
    border-radius: 30px;
    padding: 6px 6px 6px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    max-width: 720px;
    position: relative;
    transition: box-shadow 0.3s var(--ease-out), transform 0.3s var(--ease-out);
    border: 1px solid rgba(255,255,255,0.6);
}

.search-bar:focus-within {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(-2px);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: color 0.2s;
}

.search-bar:focus-within .search-icon { color: var(--primary); }

#searchInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 10px 0;
    background: transparent;
    min-width: 0;
}

#searchInput::placeholder { color: var(--text-muted); }

.search-submit {
    background: var(--primary);
    color: var(--white);
    padding: 10px 24px;
    border-radius: 24px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.25s var(--ease-out);
    box-shadow: 0 2px 8px -2px rgba(16, 185, 129, 0.4);
}

.search-submit:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 8px 16px -4px rgba(16, 185, 129, 0.5);
}
.search-submit:active { transform: translateY(0); }

/* ===== CATEGORIES ===== */
.categories {
    padding: 16px 0;
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
}

.categories-scroll {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 4px;
}

.category-chip {
    padding: 9px 20px;
    border-radius: 22px;
    background: var(--border-light);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.25s var(--ease-out);
    flex-shrink: 0;
    border: 1px solid transparent;
}

.category-chip:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.category-chip.active {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 4px 12px -2px rgba(16, 185, 129, 0.4);
}

/* ===== SECTIONS ===== */
.featured { padding: 32px 0; }

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.link-all {
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
    transition: color 0.2s;
}

.link-all:hover { color: var(--primary-dark); }

/* ===== PRODUCT GRID & CARDS (NEW RICH DESIGN) ===== */
.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.product-card {
    background: var(--white);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition:
        transform 0.35s var(--ease-out),
        box-shadow 0.35s var(--ease-out),
        border-color 0.25s ease;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-light);
    animation: cardIn 0.5s var(--ease-out) backwards;
}

@keyframes cardIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-card:nth-child(1) { animation-delay: 0.04s; }
.product-card:nth-child(2) { animation-delay: 0.08s; }
.product-card:nth-child(3) { animation-delay: 0.12s; }
.product-card:nth-child(4) { animation-delay: 0.16s; }
.product-card:nth-child(5) { animation-delay: 0.20s; }
.product-card:nth-child(n+6) { animation-delay: 0.24s; }

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: var(--primary-light);
}

/* Image area with carousel */
.product-image-wrap {
    position: relative;
    aspect-ratio: 16/10;
    background: linear-gradient(180deg, #f9fafb, #ffffff);
    overflow: hidden;
}

.product-images-row {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: pan-y;
    cursor: grab;
}
.product-images-row.dragging { cursor: grabbing; transition: none; }

.product-images-row img {
    flex: 0 0 100%;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 14px;
    pointer-events: none;
}

/* Pagination dots */
.card-dots {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 5px;
    z-index: 2;
}
.card-dots .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.25);
    transition: all 0.2s;
}
.card-dots .dot.active {
    background: var(--primary);
    width: 18px;
    border-radius: 3px;
}

.product-card:hover .product-images-row img { transform: scale(1.03); }

.discount-tag {
    position: absolute;
    top: 12px;
    left: 12px;
    background: var(--discount-bg);
    color: #c2410c;
    padding: 5px 12px;
    border-radius: 14px;
    font-size: 13px;
    font-weight: 700;
    z-index: 2;
    box-shadow: 0 2px 8px -2px rgba(251, 146, 60, 0.4);
}

.fav-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s var(--ease-bounce);
    z-index: 2;
    color: var(--primary);
    border: 1px solid var(--primary-light);
    box-shadow: var(--shadow-xs);
}

.fav-btn:hover { background: var(--primary); color: var(--white); transform: scale(1.1); }
.fav-btn.active { background: var(--pink); border-color: var(--pink); color: var(--white); animation: heartBeat 0.6s var(--ease-bounce); }
.fav-btn.active svg { fill: currentColor; }

@keyframes heartBeat {
    0%, 100% { transform: scale(1); }
    40% { transform: scale(1.3); }
    60% { transform: scale(0.95); }
}

/* Card carousel arrows */
.card-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    color: var(--text);
    z-index: 3;
    opacity: 0;
    transition: all 0.25s var(--ease-out);
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.product-card:hover .card-nav { opacity: 1; }
.card-nav:hover { background: var(--primary); color: var(--white); transform: translateY(-50%) scale(1.1); }
.card-nav.prev { left: 10px; }
.card-nav.next { right: 10px; }

/* On touch devices show arrows always */
@media (hover: none) {
    .card-nav { opacity: 0.9; }
}

/* Info section */
.product-info {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1 1 auto;
}

.product-category {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: 1.2px;
    text-transform: uppercase;
}

.product-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.35;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 40px;
    transition: color 0.2s;
}

.product-card:hover .product-name { color: var(--primary-dark); }

/* Price + mini chart row */
.product-stats-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.price-block { display: flex; flex-direction: column; gap: 4px; }

.product-price {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.product-price sup {
    font-size: 12px;
    font-weight: 700;
    vertical-align: top;
    margin-left: 1px;
}

.product-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
}

.star-icon { color: var(--star); }

.mini-chart {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex: 1;
    max-width: 160px;
}

.mini-chart-icon {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.mini-chart-svg {
    width: 100%;
    max-width: 150px;
    height: 42px;
}

/* KPI pills */
.product-kpis {
    display: flex;
    gap: 6px;
    margin-top: 4px;
    flex-wrap: wrap;
}

.kpi {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    color: var(--text);
    padding: 6px 11px;
    border-radius: 18px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.25s var(--ease-out);
    flex: 1;
    justify-content: center;
    min-width: 0;
    white-space: nowrap;
}

.kpi:hover {
    background: var(--primary-bg);
    border-color: var(--primary-light);
    transform: translateY(-1px);
}

.kpi-down { color: var(--primary-dark); background: linear-gradient(135deg, #ecfdf5, #d1fae5); border-color: #a7f3d0; }
.kpi-down svg { stroke: var(--primary); }
.kpi-up { color: #b91c1c; background: linear-gradient(135deg, #fef2f2, #fee2e2); border-color: #fecaca; }
.kpi-up svg { stroke: #ef4444; }
.kpi-stable { color: var(--text-secondary); }
.kpi-savings { color: #c2410c; background: linear-gradient(135deg, #fff7ed, #fed7aa); border-color: #fdba74; }
.kpi-savings svg { stroke: #fb923c; }

/* ===== CARDS ===== */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

/* ===== FOOTER ===== */
.footer {
    background: var(--white);
    border-top: 1px solid var(--border-light);
    padding: 32px 0 20px;
    margin-top: 40px;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.footer-logo {
    height: 36px;
    margin-bottom: 12px;
}

.footer-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.footer-col h4 {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.footer-col a {
    display: block;
    padding: 6px 0;
    font-size: 14px;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.footer-col a:hover { color: var(--primary); }

.footer-bottom {
    border-top: 1px solid var(--border-light);
    padding-top: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== v2.2-force-two-columns-home =====
   Force home/product card sections to show two cards per row on any viewport
   with enough physical room. This lives in styles.css because it is loaded
   before responsive.css, and responsive.css already agrees with 2 columns >=640px.
*/
@media (min-width: 560px) {
    #productsGrid.products-grid,
    #topDealsGrid.products-grid,
    #historyCards.products-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 559px) {
    #productsGrid.products-grid,
    #topDealsGrid.products-grid,
    #historyCards.products-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ===== v2.9 marketplace header: search arriba, menú abajo ===== */
.header {
    background: rgba(255,255,255,0.96);
}

.header-container {
    display: grid;
    grid-template-columns: auto minmax(260px, 720px) auto;
    align-items: center;
    justify-content: center;
    column-gap: 24px;
    row-gap: 10px;
    padding-top: 10px;
    padding-bottom: 10px;
}

.header-search-wrap {
    width: min(720px, 52vw);
    justify-self: center;
}

.search-bar-header {
    max-width: none;
    width: 100%;
    margin: 0;
    border-radius: 10px;
    box-shadow: 0 6px 18px -12px rgba(15, 23, 42, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.35);
    padding-left: 16px;
}

.search-bar-header .search-submit {
    border-radius: 8px;
}

.header-nav-row {
    border-top: 1px solid rgba(229, 231, 235, 0.8);
    background: rgba(255,255,255,0.72);
}

.header-nav-row .nav-desktop {
    max-width: 1400px;
    margin: 0 auto;
    padding: 8px 32px 10px;
    display: none;
    flex: none;
    justify-content: center;
    gap: clamp(18px, 2.4vw, 38px);
}

.header-nav-row .nav-link {
    padding: 6px 4px;
    white-space: nowrap;
}

.header-container > .nav-desktop {
    display: none !important;
}

.hero {
    padding-top: 42px;
}

@media (min-width: 1024px) {
    .header-nav-row .nav-desktop {
        display: flex;
    }

    .header-container {
        padding: 10px 32px 8px;
    }
}

@media (max-width: 1023px) {
    .header-container {
        grid-template-columns: auto 1fr auto;
        padding: 10px 16px;
    }

    .header-search-wrap {
        width: 100%;
    }

    .search-bar-header {
        padding: 5px 5px 5px 12px;
    }

    .search-bar-header .search-submit {
        padding: 9px 14px;
    }
}

@media (max-width: 767px) {
    .header-container {
        grid-template-columns: auto 1fr auto;
        column-gap: 10px;
    }

    .logo-img {
        height: 30px;
        max-width: 100px;
    }

    .header-actions .search-btn {
        display: none;
    }

    .btn-ingresar {
        padding: 8px 12px;
    }

    .search-bar-header {
        border-radius: 999px;
        gap: 8px;
    }

    .search-bar-header .search-submit {
        display: none;
    }

    #searchInput {
        font-size: 14px;
    }

    .hero {
        padding-top: 32px;
    }
}

@media (max-width: 430px) {
    .header-container {
        grid-template-columns: auto 1fr;
    }

    .header-actions {
        grid-column: 2;
        justify-self: end;
        margin-top: -2px;
    }

    .header-search-wrap {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .logo-img {
        max-width: 116px;
    }
}
