:root {
    --primary: #0d47a1;
    --primary-light: #1976d2;
    --primary-dark: #002171;
    --secondary: #00838f;
    --bg-default: #f4f6f8;
    --bg-paper: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0px 4px 20px rgba(0, 0, 0, 0.05);
    --hover-shadow: 0px 8px 25px rgba(13, 71, 161, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --primary: #90caf9;
    --primary-light: #e3f2fd;
    --primary-dark: #42a5f5;
    --secondary: #4dd0e1;
    --bg-default: #0a192f;
    --bg-paper: #112240;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: #233554;
    --card-shadow: 0px 4px 20px rgba(0, 0, 0, 0.3);
    --hover-shadow: 0px 8px 25px rgba(144, 202, 249, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Prompt', 'Roboto', sans-serif;
    background-color: var(--bg-default);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

.navbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-paper);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

.logo img {
    height: 40px;
    width: auto;
    object-fit: contain;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.8rem;
    cursor: pointer;
}

.slider-container {
    position: relative;
    width: 100%;
    height: 680px;
    overflow: hidden;
    background-color: #000;
}

.slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.8s ease-in-out;
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slide.active {
    opacity: 1;
    z-index: 1;
}

.slide-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.7) 100%);
}

.slide-content {
    position: relative;
    z-index: 2;
    color: #ffffff;
    text-align: center;
    max-width: 800px;
    padding: 0 1.5rem;
}

.slide-content h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.slide-content p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    opacity: 0.95;
}

.slider-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    transition: var(--transition);
}

.slider-btn:hover {
    background: rgba(255, 255, 255, 0.5);
    color: #000;
}

.slider-btn.prev {
    left: 20px;
}

.slider-btn.next {
    right: 20px;
}

.slider-dots {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 10px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: var(--transition);
}

.dot.active {
    background: var(--primary-light);
    width: 28px;
    border-radius: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0.75rem 1.75rem;
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: 8px;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}

.btn-primary {
    background-color: var(--secondary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #006064;
}

.btn-outlined {
    background: transparent;
    border: 1.5px solid #ffffff;
    color: #ffffff;
}

.btn-outlined:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 4rem 1.5rem;
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title h2 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.section-title p {
    color: var(--text-secondary);
}

.product-controls {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.search-box {
    position: relative;
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
}

.search-box input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 3rem;
    font-family: inherit;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 30px;
    background-color: var(--bg-paper);
    color: var(--text-primary);
    outline: none;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(25, 118, 210, 0.2);
}

.search-box .material-icons-outlined {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.category-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.category-btn {
    padding: 0.6rem 1.25rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-paper);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.category-btn:hover,
.category-btn.active {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.card {
    background-color: var(--bg-paper);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: var(--hover-shadow);
}

.product-card {
    overflow: hidden;
    padding: 0;
}

.product-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: #eee;
}

.product-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-category {
    font-size: 0.8rem;
    color: var(--secondary);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.25rem;
}

.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.product-price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    margin-top: auto;
    margin-bottom: 1rem;
}

.btn-detail {
    width: 100%;
    padding: 0.6rem;
    background-color: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    border-radius: 6px;
    font-family: inherit;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-detail:hover {
    background-color: var(--primary);
    color: #ffffff;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-paper);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.modal-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    padding: 2rem;
}

.modal-img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    border-radius: 8px;
    cursor: zoom-in;
    transition: box-shadow 0.2s;
}

.modal-img:focus {
    outline: 2px solid #1976d2;
    box-shadow: 0 0 0 2px #1976d2;
}

.modal-info .price {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0.5rem 0;
}

.modal-info .desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* --- ปรับแต่ง News Grid & News Card --- */
.news-grid {
    display: grid;
    /* กำหนดให้กล่องเล็กพอดี (กว้าง 300px - 360px) และไม่ยืดเต็มหน้าเมื่อมีเพียง 1 รายการ */
    grid-template-columns: repeat(auto-fill, minmax(300px, 360px));
    gap: 1.5rem;
}

.news-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.news-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.news-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    /* จำกัดหัวข้อแสดงไม่เกิน 2 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.news-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    /* ตัดคำเนื้อหาแสดงตัวอย่างไม่เกิน 3 บรรทัด */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1.25rem;
}

.news-card .btn-read {
    margin-top: auto;
    width: 100%;
    justify-content: center;
}

footer {
    background-color: var(--bg-paper);
    border-top: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.footer-login-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    transition: var(--transition);
    opacity: 0.75;
}

.footer-login-link:hover {
    color: var(--primary);
    opacity: 1;
    text-decoration: underline;
}

.footer-login-link .material-icons-outlined {
    font-size: 1.05rem;
}

/* --- สไตล์สำหรับ modal รูปขยาย --- */
.img-zoom-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    justify-content: center;
    align-items: center;
    transition: opacity 0.2s;
}

.img-zoom-modal.active {
    display: flex;
}

.img-zoom-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.img-zoom-modal-img {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    background: #fff;
    object-fit: contain;
}

.img-zoom-modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    color: #fff;
    border-radius: 50%;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
    font-size: 1.6rem;
    transition: background 0.2s;
}

.img-zoom-modal-close:focus {
    outline: 2px solid #fff;
}

.img-zoom-modal-caption {
    margin-top: 1rem;
    color: #fff;
    font-size: 1rem;
    text-align: center;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    max-width: 90vw;
    word-break: break-word;
}

@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--bg-paper);
        flex-direction: column;
        padding: 1.5rem;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        border-top: 1px solid var(--border-color);
    }

    .nav-links.active {
        display: flex;
    }

    .mobile-menu-btn {
        display: block;
    }

    .slider-container {
        height: 380px;
    }

    .slide-content h1 {
        font-size: 1.75rem;
    }

    .modal-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .img-zoom-modal-img {
        max-width: 98vw;
        max-height: 60vh;
    }
}