/**
 * Product Grid Styles
 * * MODIFIED:
 * - Mobile view defaults to 2 columns (768px).
 * - Mobile Price Stack (480px).
 * - NEW: Mobile Footer Stack (Sales & Rating stack vertically on 480px).
 * - Style: Minimalist Boxy Buttons (Black Border + Blue Shadow).
 */

/* Container */
.bagus-product-grid {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Category Filter */
.bagus-product-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 40px;
    flex-wrap: wrap;
    justify-content: center;
}

/* --- Tombol Filter Kategori (Gaya Box Minimalis + Border Hitam + Shadow) --- */
.bagus-category-btn {
    /* Ukuran & Spasi */
    padding: 8px 20px;  
    font-size: 14px !important;
    font-weight: 700 !important;
    
    /* Warna Default */
    background: #f3f4f6; 
    color: #374151;
    
    /* Border Hitam Tipis */
    border: 1px solid #000000; 
    
    /* Bentuk Kotak Minimalis */
    border-radius: 6px !important;

    /* Shadow Tipis (Warna Biru #180D7A) */
    box-shadow: 0 4px 10px -2px rgba(24, 13, 122, 0.15); 
    
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Hover State */
.bagus-category-btn:hover {
    background: #e5e7eb;
    color: #111827;
    border-color: #000000;
    
    /* Shadow menebal & tombol naik */
    box-shadow: 0 6px 15px -3px rgba(24, 13, 122, 0.25);
    transform: translateY(-2px); 
}

/* Active State */
.bagus-category-btn.active {
    background: #000000;
    color: #ffffff;
    border-color: #000000;
    
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3); 
    transform: none;
}

/* Thumbnail di dalam tombol kategori */
.bagus-category-btn .bagus-category-thumbnail {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
  margin-right: 8px;
}

.bagus-product-categories br {
    display: none;
}

/* Products Grid */
.bagus-products-container {
    position: relative;
}

.bagus-products-grid {
    display: grid;
    grid-template-columns: repeat(var(--columns, 4), 1fr);
    gap: 24px;
    margin-bottom: 40px;
    transition: opacity 0.3s ease;
}

@media (max-width: 1024px) {
    .bagus-products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .bagus-products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

/* Product Card */
.bagus-product-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.bagus-product-card:hover {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transform: translateY(-4px);
}

/* Thumbnail */
.bagus-card-thumbnail {
    position: relative;
    aspect-ratio: 3/2;
    overflow: hidden;
    background: #f9fafb;
}

.bagus-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.bagus-card-thumbnail:hover img {
    transform: scale(1.05);
}

/* Label Badge */
.bagus-card-label {
    position: absolute;
    top: 3px;
    right: 3px;
    z-index: 999;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    width: fit-content;
}

/* Discount Badge */
.bagus-card-discount {
    position: absolute;
    top: 3px;
    left: 3px;
    z-index: 10;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    background: #ef4444;
    color: #fff;
    border-radius: 6px;
}

/* Card Body */
.bagus-card-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

/* Title */
.bagus-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 2.8em;
}

.bagus-card-title a {
    color: #111827;
    text-decoration: none;
    transition: color 0.2s ease;
}

.bagus-card-title a:hover {
    color: #6366f1;
}

/* Price */
.bagus-card-price {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
    flex-wrap: wrap;
}

.bagus-price-sale {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

.bagus-price-regular {
    font-size: 14px;
    color: #9ca3af;
    text-decoration: line-through;
}

.bagus-price-current {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}

/* Footer */
.bagus-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
    margin-top: auto;
}

/* Sales Count */
.bagus-card-sales {
    font-size: 12px;
    color: #6b7280;
}

/* Star Rating */
.bagus-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
}

.bagus-stars {
    color: #fbbf24;
    font-size: 14px;
    line-height: 1;
}

.bagus-stars.empty {
    color: #d1d5db;
}

.bagus-rating-value {
    color: #111827;
    font-weight: 600;
}

.bagus-review-count {
    color: #9ca3af;
}

/* Live Demo Button */
.bagus-card-button {
    --background-color: attr(data-button-color raw-string, inherit);
    display: block;
    width: 100%;
    padding: 8px 16px;
    margin-top: 12px;
    background: var(--background-color);
    border: 1px solid #e5e7eb;
    color: #374151;
    text-align: center;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.bagus-card-button:hover {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* Pagination */
.bagus-products-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 40px;
}

.bagus-pagination {
    display: flex;
    gap: 6px;
}

.bagus-page-btn {
    width: 32px;
    height: 32px;
    line-height: 30px;
    padding: 0;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 12px;
    font-weight: 500;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.bagus-page-btn:hover {
    background: #f3f4f6;
}

.bagus-page-btn.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* Loading Indicator */
.bagus-products-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
}

.bagus-loading-text {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
    text-align: center;
}

.bagus-loading-text span {
    animation: blink 1.4s infinite both;
}
.bagus-loading-text span:nth-child(1) {
    animation-delay: 0.2s;
}
.bagus-loading-text span:nth-child(2) {
    animation-delay: 0.4s;
}
.bagus-loading-text span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes blink {
    0% { opacity: 0.2; }
    20% { opacity: 1; }
    100% { opacity: 0.2; }
}

.bagus-no-products {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
    font-size: 16px;
    grid-column: 1 / -1;
}

.bagus-card-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 14px;
}

/* ===================================================================
 * KHUSUS MOBILE (Max-Width 480px)
 * ===================================================================
 * 1. Harga ditumpuk
 * 2. Footer (Terjual & Rating) ditumpuk
 */
@media (max-width: 480px) {
    /* Harga Tumpuk */
    .bagus-card-price {
        flex-direction: column; 
        align-items: flex-start; 
        gap: 0; 
        line-height: 1.3;
    }

    .bagus-price-sale {
        font-size: 18px; 
        order: 1; 
    }
    
    .bagus-price-regular {
        font-size: 14px; 
        order: 2; 
    }

    .bagus-price-current {
        font-size: 18px;
    }

    /* --- MODIFIKASI BARU: Footer Tumpuk (2 Baris) --- */
    .bagus-card-footer {
        flex-direction: column;      /* Susun vertikal (atas-bawah) */
        align-items: flex-start;     /* Rata kiri */
        gap: 6px;                    /* Jarak antar baris */
    }

    /* Pastikan elemen di dalamnya tidak berantakan */
    .bagus-card-sales, 
    .bagus-card-rating {
        width: 100%;                 /* Full width biar aman */
        font-size: 11px;             /* Kecilkan dikit font biar muat enak */
    }
    
    /* Pastikan bintang tetap rata kiri */
    .bagus-card-rating {
        justify-content: flex-start; 
    }
}