/*
 * productos.css — Estilos aislados para productos2.php
 * Todas las clases usan prefijo "p2-" para evitar conflictos con el CSS heredado.
 */
/* ── RESET SCOPE ─────────────────────────────────────────────────────────────
   Neutraliza floats y box-sizing dentro de #p2-scope
   ──────────────────────────────────────────────────────────────────────────── */
#p2-scope *,
#p2-scope *::before,
#p2-scope *::after {
    box-sizing: border-box;
}
#p2-scope {
    /* Crea un BFC que contiene los floats del .wrapper padre */
    display: flow-root;
    width: 100%;
}

/* ── BREADCRUMB ──────────────────────────────────────────────────────────────*/
.p2-breadcrumb {
    padding: 8px 20px 4px;
    max-width: 1400px;
    margin: 0 auto;
}
.p2-breadcrumb ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 13px;
}
.p2-breadcrumb ul li:not(:last-child)::after {
    content: ' ›';
    color: #aaa;
    margin-left: 4px;
}
.p2-breadcrumb ul li a {
    color: #666;
    text-decoration: none;
}
.p2-breadcrumb ul li a:hover {
    color: #FF3232;
}

/* ── PAGE LAYOUT ─────────────────────────────────────────────────────────────*/
#p2-page {
    display: flex;
    align-items: flex-start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px 40px;
}

/* ── SIDEBAR ─────────────────────────────────────────────────────────────────*/
#p2-sidebar {
    width: 240px;
    flex-shrink: 0;
    position: sticky;
    top: 56px;            /* altura del header fijo */
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    border-right: 1px solid #eee;
    padding: 16px 12px 16px 0;
    /* Scrollbar fina */
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}
#p2-sidebar::-webkit-scrollbar { width: 4px; }
#p2-sidebar::-webkit-scrollbar-track { background: transparent; }
#p2-sidebar::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

#p2-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}
#p2-sidebar-header h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: #111;
}
#p2-limpiar {
    font-size: 12px;
    color: #FF3232;
    cursor: pointer;
    text-decoration: none;
    font-weight: 600;
}
#p2-limpiar:hover { text-decoration: underline; }

/* ── FILTER SECTIONS ─────────────────────────────────────────────────────────*/
.p2-filter-section {
    margin-bottom: 20px;
}
.p2-filter-title {
    font-size: 10px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 8px;
}
.p2-filter-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.p2-filter-btn {
    border: 1px solid #FF3232;
    font-size: 12px;
    padding: 4px 10px;
    background: #fff;
    cursor: pointer;
    border-radius: 3px;
    color: #333;
    transition: background 0.12s, color 0.12s;
    line-height: 1.4;
    white-space: nowrap;
}
.p2-filter-btn:hover {
    background: #FF3232;
    color: #fff;
}
.p2-filter-btn.p2-active {
    background: #FF3232;
    color: #fff;
    border-color: #FF3232;
}
.p2-filter-btn.p2-disabled {
    border-color: #ddd;
    color: #ccc;
    cursor: default;
    background: #fff;
}
.p2-filter-btn.p2-disabled:hover {
    background: #fff;
    color: #ccc;
    border-color: #ddd;
}

/* ── MAIN CONTENT ────────────────────────────────────────────────────────────*/
#p2-main {
    flex: 1;
    min-width: 0;
    padding: 0 0 0 24px;
}

/* ── HEADER ──────────────────────────────────────────────────────────────────*/
#p2-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    padding-top: 10px;
}
#p2-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    flex: 1;
    min-width: 160px;
    color: #111;
    float: none;  /* override global h2 floats */
    width: auto;
    padding: 0;
}
#p2-search {
    border: 1px solid #ddd;
    padding: 7px 12px;
    font-size: 13px;
    border-radius: 3px;
    width: 180px;
    outline: none;
    background: #fff;
    color: #333;
    float: none;
}
#p2-search:focus { border-color: #FF3232; }

#p2-orden {
    border: 1px solid #FF3232;
    padding: 7px 10px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    background: #fff;
    border-radius: 3px;
    outline: none;
    float: none;
}

/* ── ACTIVE CHIPS ────────────────────────────────────────────────────────────*/
#p2-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 8px;
}
.p2-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #FF3232;
    color: #fff;
    border-radius: 20px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
    border: none;
    line-height: 1.4;
}
.p2-chip:hover { background: #c0392b; }

/* ── COUNT ───────────────────────────────────────────────────────────────────*/
#p2-count {
    font-size: 13px;
    color: #888;
    margin-bottom: 12px;
    float: none;
    width: auto;
    padding: 0;
}

/* ── PRODUCT GRID ────────────────────────────────────────────────────────────*/
#p2-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    float: none;
    width: auto;
}

#p2-empty {
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 16px;
    display: none;
}

/* ── PRODUCT CARD ────────────────────────────────────────────────────────────*/
.p2-card-wrap {
    display: block;
    text-decoration: none;
    color: inherit;
    position: relative;
    cursor: pointer;
    /* Anula estilos heredados */
    float: none;
    border: none;
    margin: 0;
    padding: 0;
}
.p2-card-wrap:hover { text-decoration: none; color: inherit; }
.p2-card-wrap:hover .p2-card-over { opacity: 1; }

.p2-card-over {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .75);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .25s ease;
    z-index: 10;
    pointer-events: none;
}
.p2-card-view {
    font-family: Helvetica, Arial, sans-serif;
    font-weight: 700;
    color: #fff;
    font-size: 14px;
    padding: 6px 12px;
    border: 1px solid #fff;
    white-space: nowrap;
}

.p2-card {
    position: relative;
    width: 100%;
    padding: 16px;
    border: 1px solid #e0e0e0;
    background: #fff;
    /* reset floats */
    float: none;
    display: block;
}

/* Badge (SIN STOCK / % OFF) */
.p2-card-badge {
    position: absolute;
    top: 10px;
    left: 0;
    background-color: #FF3232;
    height: 24px;
    line-height: 24px;
    font-size: 11px;
    color: #fff;
    padding: 0 10px;
    font-weight: 600;
    z-index: 5;
    white-space: nowrap;
}
.p2-card-badge--stock {
    background-color: #9E9E9E;
}

/* Imagen */
.p2-card-image {
    width: 100%;
    padding-top: 100%;   /* cuadrado 1:1 */
    background-position: center;
    background-repeat: no-repeat;
    background-size: contain;
    float: none;
}

/* Título */
.p2-card-title {
    width: 100%;
    padding: 10px 0 6px;
    margin: 0;
    color: #111;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid #222;
    float: none;
}

/* Precio */
.p2-card-price {
    width: 100%;
    padding: 8px 0 4px;
    margin: 0;
    color: #111;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    float: none;
}

/* Descuento efectivo */
.p2-card-discount {
    width: 100%;
    padding: 4px 0 0;
    margin: 0;
    font-size: 10px;
    color: #555;
    float: none;
    line-height: 1.4;
}

/* ── MOBILE FAB ──────────────────────────────────────────────────────────────*/
.p2-btn-filtros-mobile {
    display: none;   /* visible sólo en mobile via media query */
    align-items: center;
    gap: 6px;
    background: #FF3232;
    color: #fff;
    border: none;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 3px;
}

/* ── MOBILE BADGE ────────────────────────────────────────────────────────────*/
.p2-badge {
    background: #fff;
    color: #FF3232;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

/* ── MOBILE MODAL ────────────────────────────────────────────────────────────*/
.p2-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1099;
    display: none;
}
.p2-overlay.open { display: block; }

.p2-modal {
    position: fixed;
    inset: 0;
    background: #fff;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transform: translateY(100%);
    transition: transform .3s ease;
}
.p2-modal.open { transform: translateY(0); }

.p2-modal-header {
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #eee;
    font-weight: 700;
    font-size: 16px;
}
.p2-modal-header button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: #333;
    padding: 0;
}

.p2-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.p2-modal-footer {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #eee;
}

.p2-btn-ver {
    flex: 1;
    background: #FF3232;
    color: #fff;
    border: none;
    padding: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 3px;
}
.p2-btn-ver:hover { background: #c0392b; }

.p2-btn-limpiar-mobile {
    background: none;
    border: 1px solid #333;
    padding: 14px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: 3px;
    color: #333;
}
.p2-btn-limpiar-mobile:hover { background: #f5f5f5; }

/* ── FAMILIA DESCRIPCIÓN ─────────────────────────────────────────────────────*/
.p2-desc-wrap {
    padding: 30px 0;
}
.p2-desc-titulo {
    font-size: 20px;
    font-weight: 800;
    padding: 30px 0 10px;
    color: #111;
    float: none;
}
.p2-desc-texto {
    font-size: 15px;
    margin-bottom: 20px;
    font-weight: 300;
    color: #444;
    float: none;
}

/* ── RESPONSIVE ──────────────────────────────────────────────────────────────*/
@media (max-width: 768px) {
    #p2-sidebar {
        display: none;
    }
    #p2-page {
        flex-direction: column;
        padding: 0 12px 40px;
    }
    #p2-main {
        padding: 0;
        width: 100%;
    }
    #p2-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .p2-btn-filtros-mobile {
        display: flex;
    }
    #p2-header h2 {
        font-size: 18px;
    }
    #p2-search {
        width: 100%;
    }
}
