/* ==========================================================================
   Reset and Base Styles 
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 50%, #2c3e50 100%);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Color Variables */
:root {
    --orange-gradient: linear-gradient(135deg, #ff7e5f 0%, #feb47b 50%, #ff7e5f 100%);
    --yellow-gradient: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    --dark-gradient: linear-gradient(135deg, #2c3e50 0%, #34495e 50%, #2c3e50 100%);
    --light-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --primary-orange: #ff7e5f;
    --primary-yellow: #ffd89b;
    --dark-bg: #2c3e50;
    --text-light: #ecf0f1;
    --text-dark: #2c3e50;
    --border-color: rgba(255, 255, 255, 0.1);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Sarabun', sans-serif;
}

.btn-primary {
    background: var(--orange-gradient);
    color: white;
    box-shadow: 0 4px 20px rgba(255, 126, 95, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 126, 95, 0.4);
}

.btn-secondary {
    background: transparent;
    color: var(--text-light);
    border: 2px solid var(--primary-orange);
}

.btn-secondary:hover {
    background: var(--orange-gradient);
    color: white;
    transform: translateY(-2px);
}

/* ==========================================================================
   Navigation (ปรับสมส่วนโลโก้ใหญ่และจัดเมนูกึ่งกลางตามบาร์ 100px)
   ========================================================================== */
.nav-container, .nav-brand, .nav-menu {
    display: flex;
    align-items: center;
    height: 100%;
}

.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    z-index: 1000;
    padding: 0;           
    height: 100px;        
    border-bottom: 1px solid var(--border-color);
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center; 
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;       
}

.nav-brand {
    display: flex;
    align-items: center;
    height: 100%;
}

.nav-brand a {
    display: flex;
    align-items: center;
}

.nav-menu {
    display: flex;
    gap: 2rem;
    align-items: center; 
}

.nav-link {
    color: var(--text-light);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    position: relative;
    padding: 10px 0;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-orange);
}

.nav-link:hover::after,
.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0; 
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--orange-gradient);
}

.nav-hamburger {
    display: none;
    flex-direction: column;
    cursor: pointer;
}

/* ==========================================================================
   Hero Section
   ========================================================================== */
.hero {
    background: var(--dark-gradient);
    padding: 120px 0 80px;
    color: var(--text-light);
    overflow: hidden;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="50" cy="50" r="1" fill="%23ff7e5f" opacity="0.05"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
    opacity: 0.3;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-content .container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.hero-text h1 {
    font-size: 4rem;
    font-weight: 700;
    background: var(--orange-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.5rem;
}

.hero-text h2 {
    font-size: 1.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-light);
}

.hero-text p {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    line-height: 1.8;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.hero-image {
    text-align: center;
}

.hero-image i {
    font-size: 15rem;
    color: var(--primary-orange);
    opacity: 0.3;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

/* ==========================================================================
   Features Section
   ========================================================================== */
.features {
    padding: 80px 0;
    background: var(--light-gradient);
}

.section-title {
    text-align: center;
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 3rem;
    position: relative;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: var(--orange-gradient);
    border-radius: 2px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
}

.feature-card {
    background: white;
    padding: 2rem;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 126, 95, 0.1);
}

.feature-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.feature-card i {
    font-size: 3rem;
    color: var(--primary-orange);
    margin-bottom: 1rem;
}

.feature-card h3 {
    font-size: 1.3rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

.feature-card p {
    color: #666;
    line-height: 1.6;
}

/* ==========================================================================
   Products Section & Sidebar
   ========================================================================== */
.products {
    padding: 80px 0;
    background: var(--dark-gradient);
    color: var(--text-light);
}

.products .container {
    display: grid;
    grid-template-columns: 1fr; 
    gap: 2rem;
}

.sidebar {
    background: transparent;
    padding: 0;
    border: none;
    backdrop-filter: none;
}

.sidebar h3 {
    margin-bottom: 1rem;
}

.category-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    list-style: none;
}

.category-link {
    border-radius: 25px; 
}

.category-link:hover,
.category-link.active {
    background: var(--orange-gradient);
    color: white;
    opacity: 1;
    transform: translateX(5px);
}

.category-link i {
    font-size: 1.1rem;
}

.main-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 2rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

.products-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.products-header .section-title {
    margin: 0;
    color: var(--text-light);
    font-size: 2rem;
}

.search-box {
    position: relative;
}

.search-box input {
    padding: 12px 45px 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    width: 300px;
    font-family: 'Sarabun', sans-serif;
}

.search-box input::placeholder {
    color: rgba(236, 240, 241, 0.6);
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--primary-orange);
}

/* ==========================================================================
   🔥 Products Grid & Card (แก้ไขบั๊กการ์ดเบี้ยว รูปภาพล้น และซ้อนทับกัน)
   ========================================================================== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* คุมคอมพิวเตอร์หน้าจอใหญ่ แถวละ 5 ชิ้น */
    gap: 1rem; 
    width: 100%;
}

.product-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 15px;
    padding: 12px; /* บีบพื้นที่ขอบลดลง เพื่อไม่ให้การ์ดเบียดดันกันล้น */
    text-align: center;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    height: 100%; /* ล็อกความสูงของการ์ดทุกใบให้เท่ากันแบบกล่องตาราง */
    justify-content: space-between;
    box-sizing: border-box;
}

.product-card:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--primary-orange);
}

/* 📦 บล็อกกล่องครอบรูปภาพใหม่ ไม่ฟิกความกว้าง 80px และเปลี่ยนพื้นหลังให้เข้าโทนเว็บ */
.product-image {
    width: 100% !important;
    height: 130px !important; /* ล็อกความสูงพอดีคำสำหรับแสดงภาพบน Desktop */
    margin: 0 0 1rem 0 !important;
    border-radius: 10px !important;
    background: rgba(0, 0, 0, 0.2) !important; 
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: hidden !important;
    position: relative !important;
}

/* 🖼️ ล็อกสเกลรูปภาพข้างในการ์ดตัดปัญหารูปลอยทะลุข้อความ */
.product-card img,
.product-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important; /* ครอปรูปภาพสัดส่วนแปลกๆ ให้เข้ากรอบพอดี ไม่ยืดหรือบี้แบน */
    border-radius: 10px !important;
}

.product-info {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-info h3 {
    color: var(--text-light);
    font-size: 0.95rem; 
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.6em; /* จำกัดความสูงของชื่อสินค้าไว้ที่ 2 บรรทัด ปุ่มสั่งซื้อจะได้อยู่ระดับเดียวกัน */
    line-height: 1.3em;
}

.product-info p,
.product-info p.stock {
    color: rgba(236, 240, 241, 0.5);
    font-size: 0.8rem;
    margin-bottom: 1rem;
}

.product-price {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* ดันปุ่มสั่งซื้อและราคาให้เกาะขอบล่างสุดของการ์ดเสมอ */
    margin-bottom: 0.8rem;
}

.price {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-orange);
}

.original-price {
    text-decoration: line-through;
    color: rgba(236, 240, 241, 0.6);
    font-size: 0.9rem;
}

.btn-buy {
    width: 100%;
    padding: 10px;
    font-size: 0.9rem;
    border-radius: 8px;
    margin-top: auto;
}

/* ==========================================================================
   Other Utilities & Components
   ========================================================================== */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-light);
}

.loading i {
    font-size: 2rem;
    color: var(--primary-orange);
    margin-bottom: 1rem;
}

.footer {
    background: #1a252f;
    color: var(--text-light);
    padding: 3rem 0 1rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3,
.footer-section h4 {
    color: var(--primary-orange);
    margin-bottom: 1rem;
}

.footer-section p,
.footer-section li {
    color: rgba(236, 240, 241, 0.8);
    margin-bottom: 0.5rem;
}

.footer-section ul {
    list-style: none;
}

.footer-section a {
    color: rgba(236, 240, 241, 0.8);
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-section a:hover {
    color: var(--primary-orange);
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--orange-gradient);
    border-radius: 50%;
    color: white;
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.social-links a:hover {
    transform: translateY(-3px);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    color: rgba(236, 240, 241, 0.6);
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    position: absolute;
    right: 1rem;
    top: 1rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    transition: color 0.3s ease;
}

.close:hover {
    color: var(--primary-orange);
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e8ed;
    border-radius: 10px;
    font-size: 16px;
    font-family: 'Sarabun', sans-serif;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-orange);
}

/* ==========================================================================
   Responsive Design & Media Queries
   ========================================================================== */
@media (max-width: 1024px) {
    .products .container {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .sidebar {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 15px;
    }

    .category-menu {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .category-menu li {
        margin: 0;
    }

    .category-link {
        padding: 0.6rem 1rem;
        border-radius: 25px;
        white-space: nowrap;
    }
}

@media (max-width: 768px) {
    .nav-menu {
        display: none;
    }

    .nav-hamburger {
        display: flex;
    }

    .hero-content .container {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 2rem;
    }

    .hero-text h1 {
        font-size: 3rem;
    }

    .hero-text h2 {
        font-size: 1.5rem;
    }

    .hero-buttons {
        justify-content: center;
    }

    .hero-image i {
        font-size: 8rem;
    }

    .products-header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box input {
        width: 100%;
    }

    /* 📱 บังคับสลับการ์ดเรียงตัวเป็น 2 คอลัมน์บนมือถือแบบพอดีขอบจอ */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important; 
        gap: 8px !important; 
    }

    .product-image {
        height: 100px !important; /* ย่อความสูงกล่องรูปภาพบนมือถือเพื่อให้กระชับสายตา */
    }

    .product-info h3 {
        font-size: 0.85rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .modal-content {
        margin: 10% auto;
        width: 95%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }

    .hero {
        padding: 100px 0 60px;
    }

    .hero-text h1 {
        font-size: 2.5rem;
    }

    .hero-text h2 {
        font-size: 1.3rem;
    }

    .section-title {
        font-size: 2rem;
    }

    .products,
    .features {
        padding: 60px 0;
    }

    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
    }

    /* 📱 บังคับมือถือหน้าจอเล็กจิ๋วให้เกาะกลุ่มเป็น 2 คอลัมน์เช่นกัน ป้องกันสไตล์ตีกลับ */
    .products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}