/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    background: #ffffff;
    color: #333;
    line-height: 1.6;
    padding-bottom: 20px;
}

/* Header (ถูกแทนที่ด้วย tabs-header) */

/* Tabs with Back Button */
.tabs-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.back-btn-inline {
    background: none;
    border: none;
    cursor: pointer;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: background 0.2s;
    flex-shrink: 0;
}

.back-btn-inline:hover {
    background: #f5f5f5;
}

.search-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
    transition: background 0.2s;
    flex-shrink: 0;
}

.search-toggle-btn:hover {
    background: #f5f5f5;
}

/* Tabs */
.tabs {
    display: flex;
    flex: 1;
    background: #ffffff;
}

.tab {
    flex: 1;
    padding: 14px;
    background: none;
    border: none;
    font-size: 16px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    position: relative;
    transition: color 0.2s;
}

.tab.active {
    color: #333;
    font-weight: 600;
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: #333;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Search Box */
.search-box {
    margin: 16px 20px;
    position: relative;
    display: flex;
    align-items: center;
    background: #f8f8f8;
    border-radius: 12px;
    padding: 12px 16px;
}

.search-box svg {
    color: #999;
    margin-right: 12px;
}

.search-box input {
    flex: 1;
    border: none;
    background: none;
    font-size: 15px;
    outline: none;
    color: #333;
}

.search-box input::placeholder {
    color: #999;
}

/* Filters Section */
.filters-section {
    padding: 0 20px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.filters-title {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    padding-left: 2px;
}

.filter-select {
    padding: 9px 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    background: #ffffff;
    color: #333;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    transition: all 0.2s;
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.filter-select:focus {
    outline: none;
    border-color: #333;
}

.filter-select.active {
    background: #f0f0f0;
    border-color: #333;
    font-weight: 500;
}

.filter-select.full-width {
    grid-column: 1 / -1;
}

.clear-filters-btn {
    width: 100%;
    margin-top: 12px;
    padding: 10px;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    transition: all 0.2s;
}

.clear-filters-btn:hover {
    background: #f8f8f8;
    border-color: #333;
    color: #333;
}

/* Active Filters */
.active-filters {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid #f0f0f0;
}

.active-filters-label {
    font-size: 13px;
    color: #666;
    font-weight: 500;
}

.no-filters {
    font-size: 13px;
    color: #999;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f0f0;
    border-radius: 20px;
    font-size: 13px;
    color: #333;
}

.filter-tag-remove {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    font-size: 16px;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.filter-tag-remove:hover {
    color: #333;
}

/* Result Count */
.result-count {
    padding: 12px 20px;
    font-size: 14px;
    color: #666;
    border-bottom: 1px solid #f0f0f0;
}

/* Products Grid */
.products-grid {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.product-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

.product-card-image {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    background: #f8f8f8;
}

.product-card-info {
    padding: 12px;
}

.product-card-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card-price {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* No Results */
.no-results {
    padding: 60px 20px;
    text-align: center;
}

.no-results-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.no-results-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.no-results-text {
    font-size: 14px;
    color: #666;
    margin-bottom: 24px;
}

.no-results-btn {
    padding: 12px 24px;
    background: #333;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    font-family: 'Sarabun', sans-serif;
    transition: background 0.2s;
}

.no-results-btn:hover {
    background: #000;
}

/* Product Page */
.product-container {
    max-width: 600px;
    margin: 0 auto;
}

.product-main-image {
    width: 100%;
    aspect-ratio: 1;
    background: #f8f8f8;
}

.product-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-gallery {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}

.gallery-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.gallery-scroll::-webkit-scrollbar {
    display: none;
}

.gallery-item {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.gallery-item:hover {
    border-color: #333;
}

.gallery-item img, .gallery-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gallery-item-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.product-info {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.product-price {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.product-name-th {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.product-name-en {
    font-size: 16px;
    color: #666;
}

.product-section {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
}

.section-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.section-subtitle {
    font-size: 13px;
    color: #999;
    margin-bottom: 16px;
}

.product-description {
    font-size: 14px;
    color: #666;
    line-height: 1.8;
    white-space: pre-wrap;
}

.related-videos {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.video-thumbnail {
    position: relative;
    aspect-ratio: 9/16;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0,0,0,0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
}

/* Fixed Buttons */
.fixed-buttons {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #f0f0f0;
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    z-index: 100;
}

.shop-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    border-radius: 8px;
    text-decoration: none;
    transition: background 0.2s;
}

.shop-btn:hover {
    background: #f8f8f8;
}

.btn-emoji {
    font-size: 24px;
    line-height: 1;
}

.shop-btn span {
    font-size: 12px;
    font-weight: 500;
}

.btn-line span { color: #06C755; }
.btn-shopee span { color: #EE4D2D; }
.btn-lazada span { color: #0F1487; }
.btn-tiktok span { color: #000000; }

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.95);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
}

.lightbox-content video {
    max-width: 100%;
    max-height: 90vh;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255,255,255,0.2);
    border: none;
    cursor: pointer;
    padding: 16px;
    border-radius: 50%;
    transition: background 0.2s;
    z-index: 1001;
}

.lightbox-nav:hover {
    background: rgba(255,255,255,0.3);
}

.lightbox-prev { left: 20px; }
.lightbox-next { right: 20px; }

/* Feed */
.feed-container {
    width: 100%;
    height: calc(100vh - 110px);
    overflow-y: auto;
    scroll-snap-type: y mandatory;
    background: #000;
}

.feed-video {
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.feed-video iframe,
.feed-video video {
    width: 100%;
    height: 100%;
    max-height: calc(100vh - 110px);
}

.feed-placeholder {
    padding: 60px 20px;
    text-align: center;
    color: #666;
    background: #fff;
}

/* Responsive */
@media (min-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .related-videos {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        max-width: 1200px;
        margin: 0 auto;
    }
}
