/* ── Baifumei Catalogue — Frontend Styles ── */

/*
 * Hide WooCommerce product grids immediately on load so there is no flash
 * before the catalogue JS hides them. Only applies to shop/category pages
 * (not the demo page, which never has these elements).
 */
.woocommerce ul.products,
.woocommerce-page ul.products,
.products.columns-4,
.wc-block-grid,
.fwpl-layout,
.fwpl-result,
.woocommerce-result-count,
.woocommerce-ordering,
.fwpl-filter {
    display: none !important;
}

.bmc-catalogue {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #1a1a1a;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

/* ── Sidebar ── */
.bmc-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
}

.bmc-sidebar-section {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.bmc-sidebar-section:last-child {
    margin-bottom: 0;
}

.bmc-section-title {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin: 0 0 12px;
}

/* ── Searchable category dropdown ── */
.bmc-cat-wrap {
    position: relative;
}

.bmc-cat-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 11px;
    font-size: 13px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    color: #374151;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.bmc-cat-display:focus,
.bmc-cat-display--open {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background: #fff;
    outline: none;
}
.bmc-cat-chevron {
    flex-shrink: 0;
    color: #6b7280;
    transition: transform 0.15s;
}
.bmc-cat-display--open .bmc-cat-chevron {
    transform: rotate(180deg);
}

.bmc-cat-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 9999;
    overflow: hidden;
}

.bmc-cat-search {
    width: 100%;
    padding: 9px 12px;
    font-size: 13px;
    border: none;
    border-bottom: 1px solid #e5e7eb;
    outline: none;
    background: #f9fafb;
    color: #374151;
    box-sizing: border-box;
}
.bmc-cat-search:focus {
    background: #fff;
}

.bmc-cat-list {
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 220px;
    overflow-y: auto;
}
.bmc-cat-list__item {
    padding: 8px 12px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: background 0.1s;
}
.bmc-cat-list__item:hover {
    background: #f3f4f6;
}
.bmc-cat-list__item--active {
    background: #eff6ff;
    color: #2563eb;
    font-weight: 600;
}

/* ── Select inside sidebar ── */
.bmc-select {
    width: 100%;
    padding: 9px 32px 9px 11px;
    font-size: 13px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    outline: none;
    color: #374151;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.bmc-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background-color: #fff;
}

/* ── Price range ── */
.bmc-price-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.bmc-price-input {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    color: #374151;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.bmc-price-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
    background: #fff;
}
.bmc-price-sep {
    font-size: 12px;
    color: #9ca3af;
    flex-shrink: 0;
}

.bmc-apply-btn {
    width: 100%;
    padding: 9px;
    font-size: 13px;
    font-weight: 600;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.bmc-apply-btn:hover {
    background: #1d4ed8;
}

/* ── Certification checkboxes ── */
.bmc-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    padding: 4px 0;
    user-select: none;
}
.bmc-checkbox input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #e03b9f;
    cursor: pointer;
    flex-shrink: 0;
}

.bmc-clear-filters {
    display: block;
    width: 100%;
    margin-top: 14px;
    padding: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    background: none;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
    text-align: center;
}
.bmc-clear-filters:hover {
    color: #fff;
    background: #c4298a;
    border-color: #c4298a;
}

/* ── Main content ── */
.bmc-main {
    flex: 1;
    min-width: 0;
}

/* ── Top bar (sort + result count) ── */
.bmc-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.bmc-select-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    font-weight: 500;
}
.bmc-sort-tabs {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 3px;
}
.bmc-sort-tab {
    background: transparent;
    border: none;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.bmc-sort-tab:hover { color: #dc2626; }
.bmc-sort-tab.is-active {
    background: #fef2f2;
    color: #dc2626;
    font-weight: 700;
}
.bmc-sort-price { padding: 0 4px; }

.bmc-sort-select {
    width: 170px;
    flex-shrink: 0;
    padding: 9px 32px 9px 11px;
    font-size: 13px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 10px center;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    outline: none;
    color: #374151;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.bmc-sort-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.bmc-result-meta {
    font-size: 13px;
    color: #6b7280;
    white-space: nowrap;
    flex-shrink: 0;
}
.bmc-result-count { font-weight: 600; color: #374151; }
.bmc-exec-time { color: #9ca3af; margin-left: 4px; }

/* ── Grid ── */
.bmc-grid {
    display: grid;
    grid-template-columns: repeat( auto-fill, minmax( 180px, 1fr ) );
    gap: 16px;
}

/* ── Product card ── */
.bmc-card {
    display: flex;
    flex-direction: column;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s, transform 0.2s;
}
.bmc-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
    transform: translateY(-3px);
}

.bmc-card__link {
    display: flex;
    flex-direction: column;
    flex: 1;
    text-decoration: none;
    color: inherit;
}

.bmc-card__thumb {
    position: relative;
    background: #f9fafb;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}
.bmc-card__img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    transition: transform 0.3s;
}
.bmc-card:hover .bmc-card__img {
    transform: scale(1.04);
}

/* Bulk actions — always visible, sits next to the price dropdown */
.bmc-bulk-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.bmc-btn {
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.bmc-btn:disabled {
    background: #fca5a5 !important;
    border-color: #fca5a5 !important;
    color: #fff !important;
    cursor: not-allowed;
    opacity: 1;
}
.bmc-btn--primary {
    background: #dc3545;
    color: #fff;
    border-color: #dc3545;
}
.bmc-btn--primary:hover:not(:disabled) { background: #c82333; border-color: #c82333; }
.bmc-btn--outline {
    background: #fff;
    color: #666;
    border-color: #ddd;
}
.bmc-btn--outline:hover:not(:disabled) { background: #f5f5f5; }
.bmc-btn--outline:disabled {
    background: #fff !important;
    border-color: #e5e7eb !important;
    color: #d1d5db !important;
}

/* Card controls container (Add to Cart row + Qty/Box row) */
.bmc-card__controls {
    padding: 8px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Card actions (ATC button + select checkbox) */
.bmc-card__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.bmc-card__select {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    cursor: pointer;
}
.bmc-card__select-check { cursor: pointer; margin: 0; }
.bmc-card__actions .bmc-card__atc { flex: 1; }

/* Qty/Box inline row (below Add to Cart) — mimics: "Qty  1   Box  0" */
.bmc-card__qty-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    justify-content: flex-start;
}
.bmc-card__qty-lbl {
    color: #dc3545;
    font-weight: 700;
    font-size: 11px;
    margin: 0;
}
.bmc-card__qty-input,
.bmc-card__box-input {
    width: 48px;
    padding: 2px 4px;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    font-size: 11px;
    text-align: center;
    font-family: inherit;
    color: #111827;
    background: #fff;
    height: 22px;
    box-sizing: border-box;
}
.bmc-card__qty-input::-webkit-outer-spin-button,
.bmc-card__qty-input::-webkit-inner-spin-button,
.bmc-card__box-input::-webkit-outer-spin-button,
.bmc-card__box-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.bmc-card__qty-input,
.bmc-card__box-input {
    appearance: textfield;
    -moz-appearance: textfield;
}
.bmc-card__qty-input:focus,
.bmc-card__box-input:focus {
    outline: none;
    border-color: #dc3545;
}
.bmc-card__box-input:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}
/* Give a bit more breathing space between Qty group and Box group */
.bmc-card__qty-row .bmc-card__qty-lbl + .bmc-card__qty-input + .bmc-card__qty-lbl {
    margin-left: 6px;
}

/* ── Add to cart button (outlined, matches sample screenshot) ── */
.bmc-card__atc {
    display: block;
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    background: #fff;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    flex-shrink: 0;
    height: 26px;
    box-sizing: border-box;
    line-height: 1;
}
.bmc-card__atc:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}
.bmc-card__atc--loading {
    background: #6b7280 !important;
    cursor: wait !important;
}
.bmc-card__atc--added {
    background: #16a34a !important;
}
.bmc-card__atc--error {
    background: #dc2626 !important;
}
.bmc-card__img--placeholder {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.bmc-card__badges {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    z-index: 1;
}
.bmc-card__certs {
    position: absolute;
    top: 8px;
    left: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 2;
}
.bmc-card__cert {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.03em;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.bmc-card__cert--cpnp { background: #1e3a8a; border: 2px solid #1d4ed8; }
.bmc-card__cert--scpn { background: #111827; border: 2px solid #374151; }
.bmc-card__top-right {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.bmc-card__info {
    font-size: 11px;
    color: #374151;
    margin: 2px 0;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.bmc-card__info-lbl { color: #6b7280; font-weight: 500; }
.bmc-card__info-val { color: #111827; text-decoration: underline; text-decoration-color: #d1d5db; }
.bmc-card__info--barcode .bmc-card__info-val { color: #2563eb; }
.bmc-card__info--stock { margin-top: 6px; }
.bmc-card__stock-pill {
    background: #fecaca;
    color: #991b1b;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    text-transform: none;
}
.bmc-card__stock-pill--oos { background: #fee2e2; color: #dc2626; }
.bmc-card__stock-num { font-weight: 600; color: #111827; font-size: 11px; }
.bmc-card__ppb { color: #6b7280; font-size: 10px; margin-left: auto; }
.bmc-card__badge {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.bmc-card__badge--oos {
    background: #fee2e2;
    color: #dc2626;
}
.bmc-card__badge--in {
    background: #dcfce7;
    color: #16a34a;
}
.bmc-card__badge--eu {
    background: #dbeafe;
    color: #1d4ed8;
}

.bmc-card__body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
}
.bmc-card__brand {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0;
    font-weight: 600;
}
.bmc-card__title {
    font-size: 13px;
    font-weight: 500;
    margin: 0;
    line-height: 1.4;
    color: #1a1a1a;
}
.bmc-card__sku {
    font-size: 11px;
    color: #9ca3af;
    margin: 0;
}
.bmc-card__qty {
    font-size: 11px;
    color: #6b7280;
    margin: 0;
}
.bmc-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 0;
}
.bmc-card__chip {
    font-size: 11px;
    color: #6b7280;
    white-space: nowrap;
}
.bmc-card__chip--cat {
    background: #f3f4f6;
    color: #555;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 500;
}
.bmc-card__chip--code {
    background: #eef2ff;
    color: #4338ca;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 600;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 10px;
}
.bmc-card__price {
    font-size: 16px;
    font-weight: 700;
    margin-top: auto;
    padding-top: 8px;
    color: #dc2626;
}
.bmc-card__price-cur { font-size: 12px; font-weight: 600; color: #6b7280; }
.bmc-card__price-val { font-size: 16px; font-weight: 700; color: #dc2626; }
.bmc-card__price--login {
    font-size: 13px;
    font-weight: 600;
    color: #FF13A3;
    text-decoration: underline;
}

/* ── Loading / states ── */
.bmc-loading {
    text-align: center;
    padding: 32px 0;
    font-size: 14px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.bmc-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2.5px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: bmc-spin 0.7s linear infinite;
    flex-shrink: 0;
}
@keyframes bmc-spin {
    to { transform: rotate(360deg); }
}

.bmc-no-results,
.bmc-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 0;
    font-size: 15px;
    color: #9ca3af;
    margin: 0;
}
.bmc-error { color: #dc2626; }

.bmc-sentinel {
    text-align: center;
    padding: 16px 0;
    font-size: 13px;
    color: #9ca3af;
}

/* ── Mobile ── */
@media ( max-width: 768px ) {
    .bmc-catalogue {
        flex-direction: column;
        gap: 0;
    }

    .bmc-sidebar {
        width: 100%;
        position: static;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        margin-bottom: 16px;
    }

    .bmc-sidebar-section {
        flex: 1 1 calc(50% - 5px);
        margin-bottom: 0;
        min-width: 140px;
    }

    /* Price section takes full width on mobile */
    .bmc-sidebar-section--price {
        flex: 1 1 100%;
    }

    .bmc-topbar {
        flex-wrap: wrap;
    }

    .bmc-sort-select {
        width: 100%;
    }

    .bmc-result-meta {
        width: 100%;
    }

    .bmc-grid {
        grid-template-columns: repeat( 2, 1fr );
        gap: 10px;
    }

    .bmc-card__title { font-size: 12px; }
    .bmc-card__price { font-size: 14px; }

    .bmc-clear-filters {
        margin-top: 0;
    }
}

@media ( max-width: 480px ) {
    .bmc-sidebar {
        flex-direction: column;
    }
    .bmc-sidebar-section {
        flex: 1 1 100%;
    }
    .bmc-grid {
        gap: 8px;
    }
    .bmc-card__body { padding: 8px 10px 10px; }
}
