/* ═══════════════════════════════════════════
   Comerint — Catálogo Público
   Fondo blanco · Rojo marca #C8102E · Gris
   ═══════════════════════════════════════════ */

/* FIX 1: Forzar modo claro — ignora dark mode del sistema */
:root {
    color-scheme: light;
    --red: #C8102E;
    --red-dk: #A00D24;
    --red-lt: #FEF2F2;
    --g50: #F9FAFB; --g100: #F3F4F6; --g200: #E5E7EB; --g300: #D1D5DB;
    --g400: #9CA3AF; --g500: #6B7280; --g600: #4B5563; --g700: #374151;
    --g800: #1F2937; --g900: #111827;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,.06), 0 2px 4px rgba(0,0,0,.04);
    --shadow-lg: 0 10px 20px rgba(0,0,0,.08);
    --radius: 8px;
    --radius-lg: 12px;
    --tr: 180ms ease;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior: smooth; background: var(--white); }
body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 15px; line-height: 1.6;
    color: var(--g800);
    background-color: var(--white) !important;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ── Header ─────────────────────────── */
.site-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--white);
    border-bottom: 1px solid var(--g200);
    box-shadow: var(--shadow-sm);
}
.hdr-inner {
    max-width: 1180px; margin: 0 auto;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
}
.logo { flex-shrink: 0; }
.logo-img { height: 36px; width: auto; }
.main-nav { display: flex; gap: 4px; margin-left: 8px; }
.main-nav a {
    padding: 6px 14px; border-radius: 6px;
    font-size: .9rem; font-weight: 500; color: var(--g600);
    transition: all var(--tr);
}
.main-nav a:hover { background: var(--g100); color: var(--g900); }

/* FIX 5: Buscador del header siempre visible */
.hdr-search {
    margin-left: auto; display: flex; align-items: center;
    background: var(--g50); border: 1px solid var(--g200);
    border-radius: 8px; overflow: hidden; transition: border var(--tr);
    flex: 1; max-width: 320px; min-width: 0;
}
.hdr-search:focus-within { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,16,46,.08); }
.hdr-search input {
    border: none; background: transparent; padding: 8px 12px;
    font-size: .9rem; width: 100%; min-width: 0; outline: none; color: var(--g800);
}
.hdr-search button {
    background: none; border: none; padding: 8px 10px;
    color: var(--g400); cursor: pointer; flex-shrink: 0;
}
.mob-toggle { display: none; background: none; border: none; cursor: pointer; padding: 8px; }
.mob-toggle span { display: block; width: 20px; height: 2px; background: var(--g600); margin: 4px 0; border-radius: 2px; }

/* ── Hero ───────────────────────────── */
.hero {
    background: linear-gradient(135deg, var(--g900) 0%, #2d1018 100%);
    color: var(--white); text-align: center;
    padding: 56px 20px 48px;
}
.hero-eyebrow {
    font-size: .85rem; font-weight: 500; letter-spacing: .5px;
    text-transform: uppercase; color: rgba(255,255,255,.6);
    margin-bottom: 8px;
}
.hero-title { font-size: 2.2rem; font-weight: 700; margin-bottom: 10px; }
.hero-sub { font-size: 1.05rem; color: rgba(255,255,255,.7); margin-bottom: 28px; max-width: 500px; margin-left: auto; margin-right: auto; }
.hero-search {
    display: flex; max-width: 520px; margin: 0 auto;
    background: var(--white); border-radius: 10px; overflow: hidden;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.hero-search input {
    flex: 1; border: none; padding: 16px 20px;
    font-size: 1rem; outline: none; color: var(--g800);
    background: var(--white); min-width: 0;
}
.hero-search .btn { border-radius: 0; padding: 16px 28px; flex-shrink: 0; }

/* ── Sections ───────────────────────── */
.section { padding: 48px 0; }
.section-alt { background: var(--g50); }
.section-title {
    font-size: 1.4rem; font-weight: 700; color: var(--g900);
    margin-bottom: 24px;
}

/* ── Category Cards ─────────────────── */
/* FIX 4: Icono, nombre y flecha siempre en la misma línea */
.cat-grid {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
}
.cat-grid::-webkit-scrollbar { height: 4px; }
.cat-grid::-webkit-scrollbar-track { background: transparent; }
.cat-grid::-webkit-scrollbar-thumb { background: var(--g200); border-radius: 4px; }
.cat-grid::-webkit-scrollbar-thumb:hover { background: var(--g300); }
.cat-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--white); border: 1px solid var(--g200);
    border-radius: var(--radius); transition: all var(--tr);
    white-space: nowrap; flex-shrink: 0;
    text-decoration: none;
}
.cat-card:hover {
    border-color: var(--red); box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

/* FIX 2: Iconos en negro (fondo gris claro) */
.cat-icon {
    width: 38px; height: 38px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--g100); border-radius: 8px; color: var(--g800);
}
.cat-icon svg { width: 20px; height: 20px; color: var(--g800); }
.cat-icon img { width: 20px; height: 20px; object-fit: contain; filter: brightness(0) saturate(100%); }

.cat-text { flex-shrink: 0; }
.cat-name { display: block; font-weight: 600; font-size: .9rem; color: var(--g800); line-height: 1.2; }
.cat-count { display: block; font-size: .75rem; color: var(--g400); margin-top: 1px; }
.cat-arrow { color: var(--g300); flex-shrink: 0; transition: color var(--tr); }
.cat-card:hover .cat-arrow { color: var(--red); }

/* ── Product Grid ───────────────────── */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
}
.product-card {
    background: var(--white); border: 1px solid var(--g200);
    border-radius: var(--radius-lg); overflow: hidden;
    transition: all var(--tr);
}
.product-card:hover { border-color: var(--g300); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.pc-img {
    aspect-ratio: 1; overflow: hidden;
    background: var(--g50); display: flex; align-items: center; justify-content: center;
}
.pc-img img { width: 100%; height: 100%; object-fit: contain; padding: 12px; transition: transform .3s; }
.product-card:hover .pc-img img { transform: scale(1.05); }
.pc-noimg { color: var(--g300); display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.pc-body { padding: 14px 16px 16px; }
.pc-cat { font-size: .75rem; color: var(--red); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.pc-name { font-size: .9rem; font-weight: 600; color: var(--g800); margin: 4px 0; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pc-brand { font-size: .8rem; color: var(--g400); }

/* ── Breadcrumb ─────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--g400); margin-bottom: 20px; flex-wrap: wrap; }
.breadcrumb a { color: var(--g500); }
.breadcrumb a:hover { color: var(--red); }
.breadcrumb span { color: var(--g800); }

/* ── Filters ────────────────────────── */
.filter-bar { display: flex; gap: 8px; margin-bottom: 24px; flex-wrap: wrap; }
.filter-chip {
    padding: 7px 16px; border-radius: 20px; font-size: .85rem; font-weight: 500;
    border: 1px solid var(--g200); color: var(--g600);
    transition: all var(--tr);
}
.filter-chip:hover { border-color: var(--g300); background: var(--g50); }
.filter-chip.active { background: var(--red); color: var(--white); border-color: var(--red); }

/* ── Product Detail ─────────────────── */
.prod-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.gallery-main {
    aspect-ratio: 1; background: var(--g50); border-radius: var(--radius-lg);
    border: 1px solid var(--g200); overflow: hidden;
    display: flex; align-items: center; justify-content: center;
}
.gallery-main img { max-width: 90%; max-height: 90%; object-fit: contain; }
.gallery-empty { flex-direction: column; gap: 8px; color: var(--g300); }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 12px; }
.thumb {
    width: 64px; height: 64px; border-radius: 8px; overflow: hidden;
    border: 2px solid var(--g200); cursor: pointer; padding: 4px;
    background: var(--white); transition: border var(--tr);
}
.thumb.active, .thumb:hover { border-color: var(--red); }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.prod-brand { font-size: .8rem; font-weight: 600; color: var(--red); text-transform: uppercase; letter-spacing: .4px; }
.prod-name { font-size: 1.6rem; font-weight: 700; color: var(--g900); margin: 8px 0 16px; line-height: 1.3; }
.prod-sdesc { font-size: 1rem; color: var(--g500); margin-bottom: 20px; line-height: 1.5; }
.prod-desc { margin-bottom: 24px; }
.prod-desc h3 { font-size: .9rem; font-weight: 600; color: var(--g700); margin-bottom: 8px; }
.prod-desc p { color: var(--g600); line-height: 1.6; }
.prod-skus { margin-bottom: 24px; }
.prod-skus h3 { font-size: .9rem; font-weight: 600; color: var(--g700); margin-bottom: 10px; }
.sku-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.sku-table th { text-align: left; padding: 8px 12px; background: var(--g50); font-weight: 600; font-size: .8rem; color: var(--g500); text-transform: uppercase; letter-spacing: .3px; border-bottom: 1px solid var(--g200); }
.sku-table td { padding: 10px 12px; border-bottom: 1px solid var(--g100); color: var(--g600); }
.prod-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--g200); }
.prod-cat-tag { font-size: .8rem; padding: 4px 12px; background: var(--g100); border-radius: 20px; color: var(--g600); }

/* ── Search ─────────────────────────── */
.search-form { display: flex; gap: 10px; margin-bottom: 24px; }
.search-form input {
    flex: 1; padding: 12px 16px; border: 1px solid var(--g200);
    border-radius: var(--radius); font-size: 1rem; outline: none;
    transition: border var(--tr); background: var(--white); color: var(--g800);
}
.search-form input:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,16,46,.08); }
.result-count { font-size: .9rem; color: var(--g500); margin-bottom: 20px; display: block; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--g500); }
.empty-state p { margin-bottom: 16px; }

/* ── Pagination ─────────────────────── */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 32px; }
.page-link {
    width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: .9rem; font-weight: 500;
    border: 1px solid var(--g200); color: var(--g600);
    transition: all var(--tr);
}
.page-link:hover { border-color: var(--red); color: var(--red); }
.page-link.active { background: var(--red); color: var(--white); border-color: var(--red); }

/* ── Badges ─────────────────────────── */
.badge { font-size: .75rem; font-weight: 600; padding: 3px 10px; border-radius: 20px; text-transform: uppercase; letter-spacing: .3px; }
.badge-active { background: #ECFDF5; color: #065F46; }
.badge-inactive { background: var(--g100); color: var(--g500); }

/* ── Buttons ────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 10px 22px; border-radius: var(--radius);
    font-size: .9rem; font-weight: 600; border: none;
    cursor: pointer; transition: all var(--tr); gap: 6px;
}
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dk); }
.btn-outline { background: transparent; border: 1px solid var(--g300); color: var(--g700); }
.btn-outline:hover { border-color: var(--g400); background: var(--g50); }

/* ── Misc ──────────────────────────── */
.pg-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* ── Footer ─────────────────────────── */
.site-footer { background: var(--g900); color: rgba(255,255,255,.5); padding: 32px 0; margin-top: 48px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.footer-logo { height: 28px; opacity: .7; }
.footer-inner p { font-size: .85rem; }

/* ═══════════════════════════════════════════
   RESPONSIVE — Mobile
   ═══════════════════════════════════════════ */
@media (max-width: 768px) {

    /* Header: logo + search + hamburger en una línea */
    .hdr-inner { padding: 8px 12px; gap: 8px; }
    .logo-img { height: 30px; }
    .main-nav {
        display: none; position: fixed; top: 52px; left: 0; right: 0;
        background: var(--white); flex-direction: column; padding: 12px;
        border-bottom: 1px solid var(--g200); box-shadow: var(--shadow-lg); z-index: 99;
    }
    .main-nav.open { display: flex; }
    .mob-toggle { display: block; margin-left: 0; flex-shrink: 0; }

    /* FIX 5: Buscador visible en móvil, tamaño correcto */
    .hdr-search {
        flex: 1; max-width: none; min-width: 0;
        font-size: 16px; /* Evita zoom en iOS */
    }
    .hdr-search input {
        font-size: 16px; padding: 10px 12px;
    }

    /* FIX 3: Hero más grande en móvil */
    .hero { padding: 36px 16px 32px; }
    .hero-eyebrow { font-size: .8rem; }
    .hero-title { font-size: 1.5rem; }
    .hero-sub { font-size: .95rem; margin-bottom: 22px; }
    .hero-search {
        flex-direction: row; /* Mantener en línea */
        border-radius: 10px;
        max-width: 100%;
    }
    .hero-search input {
        font-size: 16px; padding: 14px 14px;
        min-width: 0; flex: 1;
    }
    .hero-search .btn {
        padding: 14px 18px; font-size: .85rem;
        border-radius: 0 10px 10px 0;
        flex-shrink: 0;
    }

    /* FIX 4: Categorías — todo en una línea en móvil */
    .cat-grid { gap: 8px; }
    .cat-card {
        flex-direction: row;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
    }
    .cat-icon { width: 32px; height: 32px; border-radius: 7px; }
    .cat-icon svg { width: 16px; height: 16px; }
    .cat-icon img { width: 16px; height: 16px; }
    .cat-name { font-size: .85rem; }
    .cat-count { font-size: .7rem; }

    /* Secciones */
    .section { padding: 32px 0; }
    .section-title { font-size: 1.2rem; margin-bottom: 16px; }

    /* Product grid */
    .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

    /* Product detail */
    .prod-layout { grid-template-columns: 1fr; gap: 24px; }
    .prod-name { font-size: 1.3rem; }

    /* Search form */
    .search-form input { font-size: 16px; }
}

/* Extra small phones */
@media (max-width: 380px) {
    .hero-title { font-size: 1.3rem; }
    .hero-search .btn { padding: 12px 14px; font-size: .8rem; }
    .cat-card { padding: 8px 10px; gap: 8px; }
    .cat-icon { width: 28px; height: 28px; }
}

/* FIX 1: Prevenir dark mode del navegador */
@media (prefers-color-scheme: dark) {
    html, body {
        background-color: var(--white) !important;
        color: var(--g800) !important;
    }
    .site-header { background: var(--white) !important; }
    .cat-card { background: var(--white) !important; }
    .product-card { background: var(--white) !important; }
    input, select, textarea { background: var(--white) !important; color: var(--g800) !important; }
    .section-alt { background: var(--g50) !important; }
}




/* ═══════════════════════════════════════════
   CATEGORY CARDS — Clean, icon + color, no photo
   ═══════════════════════════════════════════ */

.cat-card-grid {
    display: flex;
    flex-direction: row;
    gap: 12px;
}

.cat-card-new {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    background: var(--cat-bg, #FEF2F2);
    border: 1.5px solid rgba(0,0,0,.08);
    border-radius: 14px;
    text-decoration: none;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    position: relative;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}
/* Borde izquierdo accent */
.cat-card-new::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--cat-accent, #C8102E);
    border-radius: 14px 0 0 14px;
}
.cat-card-new:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.10);
    border-color: rgba(0,0,0,.18);
}

.cat-card-icon {
    flex-shrink: 0;
    width: 56px; height: 56px;
    border-radius: 12px;
    background: white;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.cat-card-icon img {
    width: 32px; height: 32px;
    object-fit: contain;
    /* Colorear ícono con el accent de la categoría */
    filter: brightness(0) saturate(100%);
    /* Se sobreescribe con el color real via JS si se quiere, de lo contrario queda negro */
}
.cat-card-icon svg { color: var(--cat-accent, #C8102E); }

.cat-card-info {
    flex: 1;
    min-width: 0;
}
.cat-card-name {
    display: block;
    font-size: .95rem;
    font-weight: 700;
    color: var(--g900);
    line-height: 1.3;
    margin-bottom: 3px;
}
.cat-card-count {
    display: block;
    font-size: .78rem;
    color: var(--g400);
}

.cat-card-arrow {
    flex-shrink: 0;
    color: var(--cat-accent, #C8102E);
    opacity: .6;
    transition: opacity .18s, transform .18s;
}
.cat-card-new:hover .cat-card-arrow {
    opacity: 1;
    transform: translateX(3px);
}


/* ═══════════════════════════════════════════
   PAGE HERO — Imagen tramada de fondo
   Usada en category.php y product.php
   ═══════════════════════════════════════════ */

.page-hero {
    position: relative;
    padding: 48px 0 40px;
    background: var(--g900);
    overflow: hidden;
}

/* Imagen real de producto — muy tenue, tramada */
.page-hero-bg {
    position: absolute; inset: 0;
    background-size: cover;
    background-position: center;
    opacity: .10;
    filter: blur(2px) grayscale(30%);
    transform: scale(1.04); /* evita bordes del blur */
}

/* Textura de punto sobre la imagen — efecto tramado */
.page-hero::after {
    content: '';
    position: absolute; inset: 0;
    background-image: radial-gradient(circle, rgba(255,255,255,.06) 1px, transparent 1px);
    background-size: 18px 18px;
    pointer-events: none;
}

.page-hero-inner {
    position: relative;
    z-index: 1;
}

.breadcrumb--light {
    color: rgba(255,255,255,.5);
    margin-bottom: 14px;
}
.breadcrumb--light a { color: rgba(255,255,255,.65); }
.breadcrumb--light a:hover { color: white; }
.breadcrumb--light span { color: rgba(255,255,255,.9); }
.breadcrumb--light svg { color: rgba(255,255,255,.35); }

.page-hero-eyebrow {
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .5px;
    text-transform: uppercase;
    color: var(--red);
    margin-bottom: 6px;
}
.page-hero-title {
    font-size: 2rem;
    font-weight: 800;
    color: white;
    line-height: 1.2;
    margin-bottom: 6px;
}
.page-hero-count {
    font-size: .9rem;
    color: rgba(255,255,255,.55);
}


/* ═══════════════════════════════════════════
   RESPONSIVE — cat-card-grid + page-hero
   ═══════════════════════════════════════════ */

@media (max-width: 900px) {
    .cat-card-grid {
        flex-wrap: wrap;
    }
    .cat-card-new {
        flex: 1 1 calc(50% - 6px);
        min-width: calc(50% - 6px);
    }
}

@media (max-width: 560px) {
    .cat-card-grid { gap: 8px; }
    .cat-card-new {
        flex: 1 1 100%;
        padding: 12px 14px;
    }
    .cat-card-icon { width: 42px; height: 42px; }
    .cat-card-icon img { width: 24px; height: 24px; }
    .page-hero { padding: 36px 0 30px; }
    .page-hero-title { font-size: 1.5rem; }
}
