:root {
    /* โทนสีหลัก (Clean Light Theme) */
    --bg-main: #f8fafc;          /* สีพื้นหลังหลัก (ขาวนวล สบายตา) */
    --card-bg: #ffffff;          /* สีพื้นหลังการ์ด/กล่องข้อมูล (ขาวบริสุทธิ์) */
    --card-hover: #ffffff;       /* สีพื้นหลังการ์ดเมื่อชี้ */
    --border-color: #e2e8f0;     /* เส้นขอบนุ่มนวล สบายตา */
    --border-focus: #3b82f6;     /* เส้นขอบเมื่อโฟกัส */
    
    --accent-primary: #2563eb;   /* สีฟ้าโปรพรีเมียม (Primary Accent) */
    --accent-hover: #1d4ed8;     /* สีฟ้าเข้มเมื่อชี้ */
    --text-main: #0f172a;        /* ข้อความหลัก สีเข้มคมชัด อ่านง่าย */
    --text-muted: #64748b;       /* ข้อความรอง สีนุ่มสบายตา */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);

    /* โทนสี Charcoal สำหรับ Navbar & Hero Section */
    --charcoal-black: #121417;   /* สีดำชาร์โคลลึก */
    --charcoal-dark: #1a1d21;    /* สีดำชาร์โคลเข้ม */
    --charcoal-border: #333942;  /* เส้นขอบสีชาร์โคล */
    --accent-orange: #ff6b35;    /* สีส้มตัดกับชาร์โคล */
}

* {
    box-sizing: border-box;
    font-family: 'Sarabun', 'Thonburi', 'Tahoma', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    transition: all 0.2s ease-in-out;
}

/* ป้องกันการล้นขวาในระดับ Global โดยไม่กระทบเลย์เอาต์เดิม */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-main);
    margin: 0;
    padding: 0;
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

img {
    max-width: 100%;
    height: auto;
}

/* Utility Classes */
.cyber-bg {
    background-color: var(--bg-main);
}

.cyber-bg-radial {
    background: radial-gradient(circle at 50% 0%, #ffffff 0%, var(--bg-main) 100%);
}

.neon-border {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.neon-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    border-radius: 16px;
}

.top-glow-bar {
    height: 3px;
    width: 100%;
    background: linear-gradient(90deg, #ff6b35, #f7a072, #e55812);
}

/* Header & Navigation (ปรับเป็นธีมสีดำ Charcoal) */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(26, 29, 33, 0.95);
    backdrop-filter: blur(16px);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--charcoal-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 100%;
}

.brand {
    font-size: 1.4em;
    font-weight: 800;
    color: #ffffff;
    text-decoration: none;
    letter-spacing: 0.5px;
}

.brand span {
    color: var(--accent-orange);
}

.btn-cart {
    background: var(--accent-orange);
    color: #ffffff;
    font-weight: 600;
    padding: 8px 20px;
    border-radius: 10px;
    text-decoration: none;
    font-size: 0.9em;
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.25);
    white-space: nowrap;
}

.btn-cart:hover {
    background: #f7a072;
    transform: translateY(-1px);
}

/* Hero Section (ปรับเป็นธีมสีดำ Charcoal) */
.hero {
    background: linear-gradient(180deg, rgba(18, 20, 23, 0.8) 0%, rgba(18, 20, 23, 0.95) 100%), 
                url('uploads/logo.jpg') center/cover no-repeat;
    color: #ffffff;
    padding: 35px 20px;
    text-align: center;
    border-bottom: 1px solid var(--charcoal-border);
}

.hero h1 {
    font-size: 2em;
    font-weight: 800;
    margin: 0 0 8px 0;
    letter-spacing: 1px;
    color: #ffffff;
}

.hero p {
    font-size: 1em;
    color: #cbd5e1;
    margin: 0;
    font-weight: 400;
}

/* Layout Container */
.container, .container-narrow, .container-checkout {
    max-width: 1200px;
    margin: 36px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
    box-sizing: border-box;
}

.container-narrow { max-width: 850px; }
.container-checkout { max-width: 1000px; }

/* Category Bar */
.categories-bar {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 12px;
    margin-bottom: 28px;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

.cat-btn {
    padding: 8px 20px;
    border-radius: 8px;
    background: #ffffff;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 500;
    border: 1px solid var(--border-color);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

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

/* Responsive Table Wrapper */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Product Grid & Cards */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 24px;
    border: 1px solid var(--border-color);
}

.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0;
    box-shadow: var(--shadow-sm);
}

.product-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
}

.img-wrapper {
    width: 100%;
    height: 210px;
    background: #f1f5f9;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.img-wrapper img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.badge-count {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.75em;
    padding: 2px 8px;
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
}

.card-body {
    padding: 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 1.1em;
    font-weight: 700;
    margin: 0 0 6px 0;
    color: var(--text-main);
}

.product-desc {
    font-size: 0.88em;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.5;
}

.price {
    font-size: 1.3em;
    font-weight: 800;
    color: var(--accent-primary);
}

.btn-add {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85em;
}

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

.card-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #f1f5f9;
    padding-top: 14px;
}

.link-detail {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 10px;
    display: inline-block;
}

.link-detail:hover {
    text-decoration: underline;
}

/* Cart Page & Components */
.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    margin-bottom: 16px;
    font-weight: 600;
    font-size: 0.9em;
}

.btn-back:hover { color: var(--text-main); }

.cart-card {
    background: var(--card-bg);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    padding: 28px;
    box-shadow: var(--shadow-md);
}

.cart-title {
    font-size: 1.5em;
    font-weight: 700;
    color: var(--text-main);
    margin: 0 0 20px 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.cart-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 0;
    border-bottom: 1px solid #f1f5f9;
}

.cart-item:last-child { border-bottom: none; }

.img-box {
    width: 70px;
    height: 70px;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.img-box img { max-width: 100%; max-height: 100%; object-fit: cover; }

.item-info { flex: 1; }
.item-name { font-weight: 600; color: var(--text-main); margin-bottom: 2px; font-size: 1em; }
.item-price { font-size: 0.9em; color: var(--text-muted); }

.qty-control {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: 8px;
}

.btn-qty {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: #ffffff;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-main);
}

.btn-qty:hover { background: var(--accent-primary); color: white; border-color: var(--accent-primary); }

.qty-num { font-weight: 600; min-width: 20px; text-align: center; color: var(--text-main); }

.item-subtotal {
    font-weight: 700;
    color: var(--text-main);
    width: 100px;
    text-align: right;
}

.btn-remove {
    color: #ef4444;
    text-decoration: none;
    font-size: 0.85em;
    margin-left: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.btn-remove:hover { background: #ef4444; color: white; }

.cart-summary {
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.total-price {
    font-size: 1.8em;
    font-weight: 800;
    color: var(--accent-primary);
}

.btn-checkout, .btn-submit {
    background: var(--accent-primary);
    color: #ffffff;
    padding: 12px 28px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    display: inline-block;
    border: none;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.btn-checkout:hover, .btn-submit:hover {
    background: var(--accent-hover);
}

/* Forms & Inputs */
.form-label {
    display: block;
    font-weight: 600;
    font-size: 0.88em;
    color: var(--text-main);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 0.95em;
    outline: none;
    background: #ffffff;
    color: var(--text-main);
}

.form-control:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Section Title */
.section-title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 12px;
}

/* Footer */
.footer {
    background: #ffffff;
    color: var(--text-muted);
    text-align: center;
    padding: 24px 20px;
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    font-size: 0.88em;
}

.footer span { color: var(--text-main); font-weight: 600; }

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: #ffffff;
    padding: 12px 24px;
    border-radius: 10px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.toast-notification.show { opacity: 1; transform: translateY(0); }