/* ========================================
   RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f5f5;
    color: rgba(0, 0, 0, 0.87);
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* ========================================
   MAIN CONTENT LAYOUT
   ======================================== */
.main-content {
    padding: 24px 0;
}

/* ========================================
   BESTSELLER SECTION
   ======================================== */
.bestseller-section {
    background: white;
    padding: 24px 0;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: rgba(0, 0, 0, 0.87);
    letter-spacing: 0.5px;
}

.see-all-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #ee4d2d;
    font-size: 14px;
    transition: opacity 0.2s;
}

.see-all-link:hover {
    opacity: 0.8;
}

.see-all-link i {
    font-size: 12px;
}

/* Bestseller Grid */
.bestseller-scroll-container {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
    display: flex;
    justify-content: flex-start;
}

.bestseller-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.bestseller-scroll-container::-webkit-scrollbar-track {
    background: transparent;
}

.bestseller-scroll-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.bestseller-scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.bestseller-grid {
    display: flex;
    gap: 12px;
    min-width: min-content;
    justify-content: center;
}

.bestseller-card {
    width: 200px;
    flex-shrink: 0;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
    transition: all 0.2s;
}

.bestseller-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: rgba(238, 77, 45, 0.4);
}

.bestseller-link {
    display: block;
    height: 100%;
}

/* Top Badge untuk ranking 1-3 */
.top-badge {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    color: white;
    font-weight: 700;
    z-index: 5;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.top-badge.top-1 {
    background: linear-gradient(135deg, #ee4d2d 0%, #ff6b6b 100%);
}

.top-badge.top-2 {
    background: linear-gradient(135deg, #ff8533 0%, #ffa64d 100%);
}

.top-badge.top-3 {
    background: linear-gradient(135deg, #ff9966 0%, #ffb380 100%);
}

.badge-label {
    font-size: 8px;
    line-height: 1;
    margin-bottom: 2px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.badge-number {
    font-size: 16px;
    line-height: 1;
    font-weight: 700;
}

/* Rank Number untuk ranking 4+ - Kotak Sederhana */
.rank-number {
    position: absolute;
    top: 8px;
    left: 8px;
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 3px;
    z-index: 5;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Bestseller Image */
.bestseller-image {
    width: 100%;
    padding-top: 100%;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #fff4e6 0%, #ffe4b5 100%);
}

.bestseller-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Bestseller Info */
.bestseller-info {
    padding: 12px;
}

.bestseller-name {
    font-size: 13px;
    line-height: 1.4;
    color: rgba(0, 0, 0, 0.87);
    min-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
}

.bestseller-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
    color: #ee4d2d;
    margin-bottom: 6px;
}

.bestseller-price .price-label {
    font-size: 11px;
}

.bestseller-price .price-value {
    font-size: 16px;
    font-weight: 600;
}

.bestseller-sold {
    font-size: 11px;
    color: rgba(0, 0, 0, 0.54);
}

.sold-count {
    display: inline-block;
    background: rgba(0, 0, 0, 0.02);
    padding: 2px 6px;
    border-radius: 2px;
}

/* ========================================
   MAIN CONTENT LAYOUT
   ======================================== */

.content-wrapper {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

/* ========================================
   SIDEBAR CATEGORY
   ======================================== */
.sidebar-category {
    width: 220px;
    background: white;
    border-radius: 2px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.category-header {
    padding: 16px;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-header i {
    font-size: 14px;
}

.category-list {
    list-style: none;
}

.category-item {
    border-bottom: 1px solid #f0f0f0;
}

.category-item:last-child {
    border-bottom: none;
}

.category-item a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    font-size: 14px;
    color: rgba(0, 0, 0, 0.8);
    transition: all 0.2s;
}

.category-item a i {
    font-size: 10px;
    color: rgba(0, 0, 0, 0.26);
}

.category-item:hover a,
.category-item.active a {
    color: #ee4d2d;
    background: rgba(238, 77, 45, 0.05);
}

.category-item:hover a i,
.category-item.active a i {
    color: #ee4d2d;
}

/* ========================================
   PRODUCTS SECTION
   ======================================== */
.products-section {
    flex: 1;
    background: white;
    border-radius: 2px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

/* Sort Bar */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    background: rgba(0, 0, 0, 0.02);
}

.sort-label {
    font-size: 14px;
    color: rgba(0, 0, 0, 0.54);
    margin-right: 8px;
}

.sort-options {
    display: flex;
    gap: 8px;
    flex: 1;
}

.sort-btn {
    padding: 8px 16px;
    font-size: 13px;
    color: rgba(0, 0, 0, 0.8);
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.2s;
}

.sort-btn:hover {
    color: #ee4d2d;
    border-color: #ee4d2d;
}

.sort-btn.active {
    color: #ee4d2d;
    background: rgba(238, 77, 45, 0.05);
    border-color: #ee4d2d;
}

/* Price Dropdown */
.price-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dropdown-toggle i {
    font-size: 11px;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 2px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s;
    z-index: 10;
}

.price-dropdown.active .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    color: rgba(0, 0, 0, 0.8);
    transition: all 0.2s;
}

.dropdown-menu a:hover {
    color: #ee4d2d;
    background: rgba(238, 77, 45, 0.05);
}

/* Pagination Info & Controls */
.pagination-info {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.54);
    margin-left: auto;
}

.pagination-controls {
    display: flex;
    gap: 4px;
}

.page-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 2px;
    color: rgba(0, 0, 0, 0.54);
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn:not(.disabled):hover {
    color: #ee4d2d;
    border-color: #ee4d2d;
}

.page-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-btn i {
    font-size: 11px;
}

/* ========================================
   PRODUCTS GRID
   ======================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 20px;
}

.product-card {
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 2px;
    transition: all 0.2s;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: rgba(238, 77, 45, 0.4);
}

.product-link {
    display: block;
    height: 100%;
}

.product-image {
    width: 100%;
    padding-top: 100%;
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-info {
    padding: 8px;
}

.product-name {
    font-size: 13px;
    line-height: 1.4;
    color: rgba(0, 0, 0, 0.87);
    min-height: 36px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    margin-bottom: 8px;
}

.product-price {
    display: flex;
    align-items: baseline;
    gap: 2px;
    color: #ee4d2d;
}

.price-label {
    font-size: 11px;
}

.price-value {
    font-size: 16px;
    font-weight: 500;
}

/* No Products */
.no-products {
    text-align: center;
    padding: 80px 20px;
    color: rgba(0, 0, 0, 0.4);
}

.no-products i {
    font-size: 64px;
    margin-bottom: 16px;
}

.no-products p {
    font-size: 16px;
}

/* ========================================
   BOTTOM PAGINATION
   ======================================== */
.bottom-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
    border-top: 1px solid #f0f0f0;
}

.page-number-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 2px;
    color: rgba(0, 0, 0, 0.8);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-number-btn:not(.active):not(:disabled):hover {
    color: #ee4d2d;
    border-color: #ee4d2d;
}

.page-number-btn.active {
    background: #ee4d2d;
    color: white;
    border-color: #ee4d2d;
}

.page-number-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.page-ellipsis {
    color: rgba(0, 0, 0, 0.4);
    padding: 0 4px;
}

/* ========================================
   FOOTER
   ======================================== */
.main-footer {
    background: white;
    margin-top: 40px;
    border-top: 1px solid rgba(0, 0, 0, 0.09);
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 40px;
    padding: 40px 0;
}

.footer-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: rgba(0, 0, 0, 0.87);
}

.footer-section ul {
    list-style: none;
}

.footer-section li {
    margin-bottom: 8px;
}

.footer-section a {
    font-size: 13px;
    color: rgba(0, 0, 0, 0.65);
    transition: color 0.2s;
}

.footer-section a:hover {
    color: #ee4d2d;
}

.social-links {
    display: flex;
    gap: 12px;
}

.social-links a {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid rgba(0, 0, 0, 0.09);
    border-radius: 4px;
    color: rgba(0, 0, 0, 0.54);
    font-size: 16px;
    transition: all 0.2s;
}

.social-links a:hover {
    color: #f5eeed;
    border-color: #ee4d2d;
}

.footer-bottom {
    text-align: center;
    padding: 24px 0;
    border-top: 1px solid rgba(0, 0, 0, 0.09);
}

.footer-bottom p {
    font-size: 12px;
    color: rgba(0, 0, 0, 0.54);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar-category {
        width: 100%;
    }

    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .sort-bar {
        flex-wrap: wrap;
    }

    .pagination-info,
    .pagination-controls {
        width: 100%;
        justify-content: center;
    }

    /* Bestseller Section Mobile */
    .bestseller-card {
        width: 160px;
    }

    .section-title {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .header-content {
        flex-wrap: wrap;
    }

    .search-container {
        order: 3;
        width: 100%;
    }

    /* Bestseller Section Small Mobile */
    .bestseller-card {
        width: 140px;
    }

    .bestseller-name {
        font-size: 12px;
    }

    .bestseller-price .price-value {
        font-size: 14px;
    }
}

/* ========================================
   AJAX LOADING STATES
   ======================================== */

/* Loading Overlay */
.products-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #ee4d2d;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #333;
    font-size: 14px;
    font-weight: 500;
}

/* Products Section - Relative positioning for overlay */
.products-section {
    position: relative;
}

/* Error Message */
.error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.error-message i {
    font-size: 64px;
    color: #ee4d2d;
    margin-bottom: 20px;
}

.error-message p {
    font-size: 16px;
    margin-bottom: 20px;
}

.retry-btn {
    background: #ee4d2d;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    background: #d73211;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(238, 77, 45, 0.3);
}

/* Smooth transitions for product cards */
.product-card {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading state for buttons */
.sort-btn:disabled,
.page-btn:disabled,
.page-number-btn:disabled {
    cursor: not-allowed;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

/* Mobile responsive loading */
@media (max-width: 768px) {
    .loading-spinner .spinner {
        width: 40px;
        height: 40px;
    }
    
    .loading-spinner p {
        font-size: 12px;
    }
}