/**
 * BAOLIAN Product Selector — Product Grid & Cards
 * 
 * Dark premium grid layout for product listing.
 * Prefix: blps-
 */

/* ─── Top Bar (count + sort + chips) ─────── */
/* ─── Search Bar ──────────────────────────── */
.blps-search-bar {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 16px;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.blps-search-bar:focus-within {
    border-color: #c41e3a;
}

.blps-search-icon {
    padding: 0 0 0 14px;
    font-size: 16px;
    opacity: 0.5;
    flex-shrink: 0;
}

.blps-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    padding: 12px 10px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
    min-width: 0;
}
.blps-search-input::placeholder {
    color: #d4d4d8;
}

.blps-search-clear {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 16px;
    padding: 8px 14px;
    flex-shrink: 0;
    transition: color 0.15s;
    line-height: 1;
}
.blps-search-clear:hover {
    color: #c41e3a;
}

@media (max-width: 576px) {
    .blps-search-input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 10px 8px;
    }
    .blps-search-icon {
        padding-left: 10px;
        font-size: 13px;
    }
}

/* ─── Top Bar ─────────────────────────────── */
.blps-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

@media (max-width: 768px) {
    .blps-top-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .blps-top-bar > div:last-child {
        display: flex;
        justify-content: space-between;
        gap: 8px;
    }
}

.blps-product-count {
    color: #fff;
    font-size: 16px;
}
.blps-product-count strong {
    color: #ff6b85;
    font-weight: 700;
}

.blps-sort-dropdown {
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 15px;
    cursor: pointer;
}

/* ─── Selected Filter Chips ──────────────── */
.blps-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.blps-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(196, 30, 58, 0.15);
    border: 1px solid rgba(196, 30, 58, 0.3);
    color: #c41e3a;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}
.blps-filter-chip:hover {
    background: rgba(196, 30, 58, 0.25);
}

.blps-filter-chip__remove {
    font-size: 16px;
    line-height: 1;
    opacity: 0.7;
}

/* ─── Product Grid ────────────────────────── */
.blps-product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    align-items: stretch;
}

@media (max-width: 992px) {
    .blps-product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 576px) {
    .blps-product-grid {
        grid-template-columns: 1fr;
    }
}

/* ─── Product Card ────────────────────────── */
.blps-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.blps-product-card:hover {
    border-color: #c41e3a;
    box-shadow: 0 4px 16px rgba(196, 30, 58, 0.1);
}

.blps-product-card__image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    background: #111;
    padding: 12px;
    box-sizing: border-box;
}

.blps-product-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 14px 16px;
}

.blps-product-card__title {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.blps-product-card__meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: #fff;
    font-size: 14px;
}

.blps-product-card__code {
    color: #e0e0e0;
    font-size: 13px;
    line-height: 1.2;
    border: 1px solid rgba(255, 79, 86, 0.85);
    border-radius: 5px;
    padding: 4px 8px;
    min-width: 0;
    max-width: 70%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(204, 0, 0, 0.08);
}

.blps-product-card__specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
    margin-bottom: 12px;
}

.blps-product-card__spec-tag {
    background: #2a2a2a;
    color: #fff;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 13px;
}

/* ─── Compare Checkbox ────────────────────── */
.blps-compare-check {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 10px;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
    transition: color 0.2s;
}
.blps-compare-check:hover {
    color: #c41e3a;
}
.blps-compare-check input[type="checkbox"] {
    accent-color: #c41e3a;
}

/* ─── Pagination ────────────────────────── */
.blps-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #2a2a2a;
    flex-wrap: wrap;
}

.blps-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.blps-page-btn:hover:not(.blps-page-btn--disabled) {
    border-color: #c41e3a;
    color: #c41e3a;
    background: #222;
}
.blps-page-btn--active {
    background: #c41e3a;
    border-color: #c41e3a;
    color: #fff;
    font-weight: 600;
}
.blps-page-btn--disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.blps-page-ellipsis {
    color: #555;
    padding: 0 4px;
}
.blps-page-info {
    color: #fff;
    font-size: 14px;
    margin-left: 12px;
    white-space: nowrap;
}

/* ─── View Mode Switcher ────────────────── */
.blps-view-switcher {
    display: flex;
    gap: 4px;
    margin-left: 12px;
}

.blps-view-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #333;
    border-radius: 4px;
    background: #1a1a1a;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    padding: 0;
    line-height: 1;
}
.blps-view-btn:hover {
    border-color: #666;
    color: #fff;
}
.blps-view-btn--active {
    border-color: #c41e3a;
    color: #fff;
    background: rgba(196, 30, 58, 0.2);
}

/* Hide compact (4-col) on small phones */
@media (max-width: 576px) {
    .blps-view-btn[data-mode="grid-4"] {
        display: none;
    }
    .blps-view-btn {
        width: 28px;
        height: 28px;
        font-size: 13px;
    }
}

/* ─── View Mode Grid Variations ─────────── */
.blps-product-grid.blps-grid-2 {
    grid-template-columns: repeat(2, 1fr);
}
.blps-product-grid.blps-grid-3 {
    grid-template-columns: repeat(3, 1fr);
}
.blps-product-grid.blps-grid-4 {
    grid-template-columns: repeat(4, 1fr);
}
.blps-product-grid.blps-grid-list {
    grid-template-columns: 1fr;
}
.blps-grid-list .blps-product-card {
    display: flex;
    flex-direction: row;
}
.blps-grid-list .blps-product-card__image {
    width: 200px;
    aspect-ratio: auto;
    flex-shrink: 0;
}
.blps-grid-list .blps-product-card__body {
    flex: 1;
    padding: 16px 20px;
}

@media (max-width: 992px) {
    .blps-product-grid.blps-grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .blps-page-btn {
        min-width: 30px;
        height: 30px;
        font-size: 12px;
        padding: 0 6px;
    }
    .blps-page-info {
        display: none;
    }
}

@media (max-width: 576px) {
    .blps-product-grid.blps-grid-3,
    .blps-product-grid.blps-grid-4 {
        grid-template-columns: 1fr;
    }
    /* Center single-column cards via margin auto (most reliable) */
    .blps-product-grid.blps-grid-3 .blps-product-card,
    .blps-product-grid.blps-grid-4 .blps-product-card {
        max-width: 400px;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    /* Larger touch targets for cards */
    .blps-product-card__body {
        padding: 12px;
    }
    .blps-compare-check {
        font-size: 14px;
        padding: 6px 0;
    }
    .blps-compare-check input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }
    .blps-product-card__title {
        font-size: 15px;
    }
}
