/* ================================================================
   PC Builder Quotation – Frontend Styles
   Compatible: WooCommerce / WoodMart / Elementor
   ================================================================ */

/* ---- Reset / Variables ---------------------------------------- */
.pcb-wrapper {
    --pcb-accent:      #e91e8c;
    --pcb-accent-dark: #c4166f;
    --pcb-sidebar-bg:  #f8f9fa;
    --pcb-border:      #e0e0e0;
    --pcb-radius:      8px;
    --pcb-shadow:      0 2px 8px rgba(0,0,0,.08);
    --pcb-text:        #2d2d2d;
    --pcb-text-light:  #777;
    --pcb-green:       #28a745;
    --pcb-red:         #dc3545;
    --pcb-font:        inherit;

    display: flex;
    gap: 24px;
    font-family: var(--pcb-font);
    color: var(--pcb-text);
    box-sizing: border-box;
    position: relative;
}

.pcb-wrapper *, .pcb-wrapper *::before, .pcb-wrapper *::after {
    box-sizing: border-box;
}

/* ================================================================
   SIDEBAR
================================================================ */
.pcb-sidebar {
    width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.pcb-sidebar-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0 0 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--pcb-accent);
}

/* Categorías lista */
.pcb-category-list {
    list-style: none;
    margin: 0 0 20px;
    padding: 0;
    background: var(--pcb-sidebar-bg);
    border: 1px solid var(--pcb-border);
    border-radius: var(--pcb-radius);
    overflow: hidden;
}

.pcb-category-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-left: 4px solid transparent;
    transition: background .15s, border-color .15s;
    border-bottom: 1px solid var(--pcb-border);
    user-select: none;
}

.pcb-category-item:last-child { border-bottom: none; }

.pcb-category-item:hover {
    background: rgba(233, 30, 140, .06);
    border-left-color: var(--pcb-accent);
}

.pcb-category-item.active {
    background: rgba(233, 30, 140, .1);
    border-left-color: var(--pcb-accent);
    font-weight: 600;
}

.pcb-category-item .dashicons {
    color: var(--pcb-accent);
    font-size: 18px;
    width: 20px;
    flex-shrink: 0;
}

.pcb-cat-label { flex: 1; font-size: .9rem; }

.pcb-cat-badge {
    min-width: 20px;
    height: 20px;
    background: var(--pcb-accent);
    color: #fff;
    font-size: .7rem;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

.pcb-cat-badge.has-items { display: flex; }

/* ================================================================
   PANEL RESUMEN / COTIZACIÓN
================================================================ */
.pcb-summary-panel {
    background: var(--pcb-sidebar-bg);
    border: 1px solid var(--pcb-border);
    border-radius: var(--pcb-radius);
    padding: 16px;
    flex: 1;
}

.pcb-summary-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 12px;
    border-bottom: 1px solid var(--pcb-border);
    padding-bottom: 8px;
}

.pcb-summary-list {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.pcb-summary-list li {
    font-size: .82rem;
    padding: 4px 0;
    border-bottom: 1px dashed var(--pcb-border);
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.pcb-summary-list li:last-child { border-bottom: none; }
.pcb-summary-empty { color: var(--pcb-text-light); font-style: italic; }
.pcb-summary-item-name { flex: 1; line-height: 1.3; }
.pcb-summary-item-price { white-space: nowrap; color: var(--pcb-accent); font-weight: 600; }
.pcb-summary-item-cat { font-size: .72rem; color: var(--pcb-text-light); display: block; }

.pcb-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 700;
    padding: 10px 0;
    border-top: 2px solid var(--pcb-border);
    border-bottom: 2px solid var(--pcb-border);
    margin-bottom: 12px;
}

.pcb-grand-total { color: var(--pcb-accent); font-size: 1.1rem; }

/* ================================================================
   BOTONES
================================================================ */
.pcb-summary-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pcb-btn {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: var(--pcb-radius);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: opacity .2s, transform .1s;
    line-height: 1.2;
}

.pcb-btn:disabled { opacity: .45; cursor: not-allowed; }
.pcb-btn:not(:disabled):hover { opacity: .88; }
.pcb-btn:not(:disabled):active { transform: scale(.98); }

.pcb-btn-primary {
    background: var(--pcb-accent);
    color: #fff;
}

.pcb-btn-whatsapp {
    background: #25d366;
    color: #fff;
}

.pcb-btn-secondary {
    background: transparent;
    color: var(--pcb-text-light);
    border: 1px solid var(--pcb-border);
}

/* ================================================================
   MAIN – CABECERA
================================================================ */
.pcb-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
}

.pcb-products-header {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pcb-products-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    flex: 1;
}

.pcb-current-cat-label {
    font-size: .95rem;
    color: var(--pcb-text-light);
    font-weight: 400;
}

.pcb-search-wrap {
    flex: 0 0 260px;
}

.pcb-search-input {
    width: 100%;
    padding: 8px 14px;
    border: 1px solid var(--pcb-border);
    border-radius: 24px;
    font-size: .9rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23aaa' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") no-repeat 12px center;
    padding-left: 36px;
}

.pcb-search-input:focus {
    border-color: var(--pcb-accent);
    box-shadow: 0 0 0 3px rgba(233,30,140,.12);
}

/* ================================================================
   GRID DE PRODUCTOS
================================================================ */
.pcb-products-grid {
    display: grid;
    gap: 14px;
}

.pcb-cols-1 { grid-template-columns: 1fr; }
.pcb-cols-2 { grid-template-columns: repeat(2, 1fr); }
.pcb-cols-3 { grid-template-columns: repeat(3, 1fr); }
.pcb-cols-4 { grid-template-columns: repeat(4, 1fr); }

/* Tarjeta producto */
.pcb-product-card {
    border: 2px solid var(--pcb-border);
    border-radius: var(--pcb-radius);
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
    overflow: hidden;
    position: relative;
}

.pcb-product-card:hover {
    border-color: var(--pcb-accent);
    box-shadow: var(--pcb-shadow);
}

.pcb-product-card.selected {
    border-color: var(--pcb-accent);
    box-shadow: 0 0 0 3px rgba(233,30,140,.18);
    background: rgba(233,30,140,.03);
}

.pcb-product-card.out-of-stock {
    opacity: .6;
}

.pcb-product-card-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    cursor: pointer;
    width: 100%;
}

/* Checkbox personalizado */
.pcb-product-check {
    position: relative;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 2px;
}

.pcb-product-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.pcb-checkmark {
    display: block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--pcb-border);
    border-radius: 4px;
    background: #fff;
    transition: background .15s, border-color .15s;
    position: relative;
}

.pcb-product-checkbox:checked ~ .pcb-checkmark {
    background: var(--pcb-accent);
    border-color: var(--pcb-accent);
}

.pcb-product-checkbox:checked ~ .pcb-checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 8px;
    height: 12px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg);
}

.pcb-product-checkbox:disabled ~ .pcb-checkmark {
    background: #eee;
    border-color: #ccc;
    cursor: not-allowed;
}

/* Imagen */
.pcb-product-image {
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border-radius: 6px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcb-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Info */
.pcb-product-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pcb-product-name {
    font-size: .82rem;
    font-weight: 600;
    color: var(--pcb-text);
    text-decoration: none;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pcb-product-name:hover { color: var(--pcb-accent); }

.pcb-price {
    font-size: .95rem;
    font-weight: 700;
    color: var(--pcb-accent);
}

.pcb-stock {
    font-size: .75rem;
}

.pcb-stock.in-stock  { color: var(--pcb-green); }
.pcb-stock.out-of-stock { color: var(--pcb-red); }

/* ================================================================
   PAGINACIÓN
================================================================ */
.pcb-pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.pcb-pagination-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--pcb-border);
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: .88rem;
    transition: background .15s, border-color .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pcb-pagination-btn:hover       { background: var(--pcb-sidebar-bg); border-color: var(--pcb-accent); }
.pcb-pagination-btn.active      { background: var(--pcb-accent); color: #fff; border-color: var(--pcb-accent); font-weight: 700; }
.pcb-pagination-btn:disabled    { opacity: .4; cursor: default; }

/* ================================================================
   LOADER
================================================================ */
.pcb-loader {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.75);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--pcb-radius);
    z-index: 10;
}

.pcb-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--pcb-border);
    border-top-color: var(--pcb-accent);
    border-radius: 50%;
    animation: pcb-spin .7s linear infinite;
}

@keyframes pcb-spin { to { transform: rotate(360deg); } }

.pcb-no-products {
    text-align: center;
    color: var(--pcb-text-light);
    padding: 40px;
    grid-column: 1 / -1;
}

/* ================================================================
   RESPONSIVE
================================================================ */
@media (max-width: 900px) {
    .pcb-wrapper { flex-direction: column; }
    .pcb-sidebar { width: 100%; }
    .pcb-category-list { display: flex; flex-wrap: wrap; gap: 0; }
    .pcb-category-item { flex: 0 0 auto; border-bottom: none; border-left: none; border-bottom: 3px solid transparent; padding: 10px 14px; }
    .pcb-category-item.active { border-bottom-color: var(--pcb-accent); border-left: none; }
    .pcb-summary-panel { max-height: none; }
}

@media (max-width: 600px) {
    .pcb-cols-2, .pcb-cols-3, .pcb-cols-4 { grid-template-columns: 1fr; }
    .pcb-products-header { flex-direction: column; align-items: stretch; }
    .pcb-search-wrap { flex: none; width: 100%; }
}

/* ================================================================
   COMPATIBILIDAD WOODMART – resetear estilos que pueden interferir
================================================================ */
.pcb-wrapper input[type="checkbox"] { margin: 0; }
.pcb-wrapper ul { margin: 0; padding: 0; }
.pcb-wrapper a { text-decoration: none; }
.pcb-wrapper button { font-family: inherit; }
