/* --- 1. General & Variables --- */
:root {
    --primary-color: #ee4d2d;
    --secondary-color: #f06c4e;
    --text-color: #333;
    --light-gray: #f5f5f5;
    --border-color: #e0e0e0;
    --font-family: 'Noto Sans Thai', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    color: var(--text-color);
    background-color: var(--light-gray);
    font-size: 14px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* --- 2. Header --- */
.main-header {
    background-color: #fff;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 1px 1px rgba(0,0,0,.05);
}

.top-bar {
    background-color: var(--primary-color);
    color: white;
    padding: 5px 0;
    font-size: 13px;
}

.top-bar .container {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.main-nav-bar {
    padding: 20px 0;
}

.main-nav-bar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.search-bar {
    flex-grow: 1;
    margin: 0 40px;
    display: flex;
}

.search-bar input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--primary-color);
    border-radius: 2px 0 0 2px;
    outline: none;
}

.search-bar button {
    background-color: var(--primary-color);
    border: none;
    color: white;
    padding: 0 20px;
    cursor: pointer;
    border-radius: 0 2px 2px 0;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-actions a {
    font-size: 18px;
}

.category-nav {
    padding-bottom: 10px;
}

.category-nav .container {
    display: flex;
    gap: 20px;
    font-size: 13px;
    justify-content: center;
}


/* --- 3. Banner Slider (Corrected) --- */
.banner-slider {
    position: relative;
    max-width: 1200px;
    margin: 20px auto;
    overflow: hidden;
    border-radius: 2px;
}

.slider-container {
    display: flex;
    transition: transform 0.5s ease-in-out;
}

.slide {
    min-width: 100%;
    flex-shrink: 0;
}

.slide img {
    width: 100%;
    display: block;
}

.prev-btn, .next-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(0,0,0,0.3);
    color: white;
    border: none;
    padding: 10px;
    cursor: pointer;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    z-index: 10;
}

.prev-btn { left: 15px; }
.next-btn { right: 15px; }


/* --- 4. General Section Styles --- */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 16px;
    color: var(--primary-color);
}

.section-header h2 {
    font-weight: 500;
}

.view-all {
    font-size: 14px;
    color: var(--primary-color);
}


/* --- 5. Flash Sale Section --- */
.flash-sale-section {
    background-color: #fff;
    margin-bottom: 20px;
    padding: 0 20px 20px 20px;
}

.flash-sale-header h2 {
    color: var(--primary-color);
    font-weight: bold;
}

.countdown-timer {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #333;
}

.time-box {
    background-color: #333;
    color: white;
    padding: 2px 5px;
    border-radius: 2px;
}

.product-carousel {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 10px;
}
.product-carousel::-webkit-scrollbar { display: none; }
.product-carousel { -ms-overflow-style: none; scrollbar-width: none; }

/* Product card specifically for FLASH SALE carousel */
.product-card {
    min-width: 180px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.product-card img {
    width: 100%;
    display: block;
}

.product-card .product-info {
    padding: 10px;
}

.product-card .product-price {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 16px;
    margin-top: 5px;
}

.flash-sale-progress {
    background-color: #fcece8;
    border-radius: 10px;
    height: 20px;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
    text-align: center;
    color: white;
    font-size: 12px;
}

.progress-bar {
    background: linear-gradient(to right, #ffb3a1, var(--primary-color));
    height: 100%;
    width: 50%;
    position: absolute;
    left: 0;
    top: 0;
}

.flash-sale-progress span {
    position: relative;
    z-index: 2;
    line-height: 20px;
}

.discount-badge {
    position: absolute;
    top: 0;
    right: 0;
    background-color: rgba(255, 212, 36, 0.9);
    color: var(--primary-color);
    padding: 5px;
    font-size: 12px;
    font-weight: bold;
}
.discount-badge::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -5px;
    border-width: 0 19px 5px;
    border-style: solid;
    border-color: transparent rgba(255, 212, 36, 0.9) transparent rgba(255, 212, 36, 0.9);
}


/* --- 6. Recommended Products (New Style) --- */
.recommended-products {
    background-color: #fff;
    padding: 20px;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

.product-card-grid {
    background-color: #fff;
    border: 1px solid var(--border-color);
    transition: transform 0.1s ease-out, box-shadow 0.1s ease-out;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 2px;
}

.product-card-grid:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    border-color: var(--primary-color);
}

.product-image-container {
    position: relative;
}

.product-card-grid img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    display: block;
}

.product-card-discount {
    position: absolute;
    top: 0;
    right: 0;
    background-color: var(--primary-color);
    color: white;
    font-size: 12px;
    font-weight: 500;
    padding: 2px 5px;
    z-index: 5;
    border-bottom-left-radius: 2px;
}

.product-card-grid .product-info {
    padding: 8px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-info .product-name {
    font-size: 13px;
    line-height: 1.4;
    height: 36px;
    margin-bottom: 8px;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.product-price {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 16px;
}

.price-currency {
    font-size: 12px;
    margin-right: 2px;
    font-weight: normal;
}

.product-sales {
    font-size: 12px;
    color: #888;
}

.tag-mall {
    background-color: #d0011b;
    color: #fff;
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 2px;
    margin-right: 4px;
    vertical-align: middle;
}

.view-more-btn-container {
    text-align: center;
    margin-top: 20px;
}

.view-more-btn {
    padding: 10px 40px;
    border: 1px solid var(--border-color);
    background-color: #fff;
    color: #555;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    min-width: 200px;
}

.view-more-btn:hover {
    background-color: #f0f0f0;
    border-color: #bbb;
}


/* --- 7. Footer --- */
.main-footer {
    background-color: #fbfbfb;
    color: #555;
    padding: 40px 0 0;
    border-top: 4px solid var(--primary-color);
}

.main-footer .container {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-column {
    flex: 1;
    min-width: 200px;
}

.footer-column h4 {
    margin-bottom: 15px;
    font-size: 14px;
    font-weight: bold;
    text-transform: uppercase;
}

.footer-column ul {
    list-style: none;
}

.footer-column ul li a {
    display: block;
    margin-bottom: 10px;
    font-size: 13px;
    transition: color 0.2s;
}

.footer-column ul li a:hover {
    color: var(--primary-color);
}

.footer-column .fab {
    margin-right: 8px;
}

.qr-code {
    width: 100px;
    height: 100px;
}

.footer-bottom {
    text-align: center;
    padding: 20px 0;
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    font-size: 13px;
}


/* --- 8. Category Page --- */
.category-page {
    padding: 20px 0;
}

.breadcrumb {
    padding: 15px;
    background-color: #fff;
    margin-bottom: 20px;
    border-radius: 2px;
    font-size: 14px;
}

.category-content {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.filters {
    flex-basis: 220px;
    flex-shrink: 0;
    background-color: transparent; /* Changed */
}

.filters h4 {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 15px;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-group h5 {
    margin-bottom: 10px;
    font-weight: 500;
}

.filter-group ul {
    list-style: none;
}

.filter-group ul li {
    margin-bottom: 8px;
}

.price-range {
    display: flex;
    align-items: center;
    gap: 5px;
}

.price-range input {
    width: 80px;
    padding: 5px;
    border: 1px solid var(--border-color);
}

.apply-filter-btn {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px;
    margin-top: 10px;
    cursor: pointer;
    text-transform: uppercase;
}

.product-listing {
    flex-grow: 1;
}

.sort-bar {
    background-color: #ededed;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.sort-btn {
    padding: 8px 15px;
    border: none;
    background-color: #fff;
    cursor: pointer;
    border-radius: 2px;
}

.sort-btn.active {
    background-color: var(--primary-color);
    color: white;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 8px;
}

.page-num, .prev-page, .next-page {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background-color: #fff;
}

.page-num.active, .page-num:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}


/* --- 9. Responsive --- */
@media (max-width: 1024px) {
    .search-bar { margin: 0 20px; }
    .category-nav .container {
        overflow-x: auto;
        justify-content: flex-start;
        padding-bottom: 5px;
    }
}

@media (max-width: 768px) {
    .main-nav-bar .container {
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }
    .logo { width: 100%; text-align: center; }
    .search-bar { order: 2; margin: 0; }
    .user-actions { order: 3; }
    .category-content { flex-direction: column; }
    .filters { flex-basis: auto; width: 100%; }
}

@media (max-width: 576px) {
    body { font-size: 13px; }
    .top-bar, .category-nav { font-size: 12px; }
    .logo { font-size: 20px; }
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
    }
    .main-footer .container {
        flex-direction: column;
        text-align: center;
    }
    .qr-code { margin: 0 auto; }
}