/* ===========================
   Base & Variables
   =========================== */
:root{
  --brand: #ee4d2d;
  --brand-600: #e64528;
  --brand-700: #d93d21;
  --brand-100: #ffe8e2;
  --text: #222;
  --muted: #666;
  --bg: #f5f5f5;
  --card: #fff;
  --line: #eaeaea;
  --green: #06c167;
}

*{ box-sizing: border-box; }
html, body {
  height: 100%;
  scroll-behavior: smooth;
}
body{
  margin:0;
  font-family: "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* Containers */
.container{
  max-width: 1220px;
  padding: 0 16px;
  margin: 0 auto;
}

/* Topbar */
.topbar{
  background: #fafafa;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}
.topbar .container{
  display:flex; align-items:center; justify-content:space-between; height:36px;
}
.top-link{ color: var(--muted); text-decoration:none; margin-right:12px; }
.top-link:hover{ color: var(--text); }
.topbar .divider{ opacity:.5; margin:0 4px; }

/* Header */
.header{
  position: sticky;
  top:0;
  z-index: 50;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-600) 100%);
  color:#fff;
  box-shadow: 0 2px 0 rgba(0,0,0,.04);
}
.header-inner{
  display:flex; align-items:center; gap:16px;
  height:72px;
}
.logo{
  display:flex; align-items:center; gap:10px; color:#fff; text-decoration:none; font-weight:800; letter-spacing:.2px;
}
.search{
  flex:1; display:flex; height:40px; background:#fff; border-radius:6px; overflow:hidden;
}
.search input{
  flex:1; border:0; padding:0 12px; outline:none; font-size:14px;
}
.search button{
  width:44px; border:0; background:transparent; color:var(--brand); cursor:pointer;
}
.icons{ display:flex; gap:8px; }
.icon-btn{
  width:40px; height:40px; display:grid; place-items:center;
  border-radius:8px; color:#fff; text-decoration:none;
}
.icon-btn:hover{ background: rgba(255,255,255,.12); }

.hamburger{ display:none; background:none; border:0; width:40px; height:40px; }
.hamburger span{ display:block; height:2px; background:#fff; margin:6px 0; border-radius:2px; }

/* Catbar */
.catbar{
  border-top: 1px solid rgba(255,255,255,.2);
  background: linear-gradient(180deg, var(--brand-600) 0%, var(--brand-700) 100%);
}
.catbar-inner{
  display:flex; align-items:center; gap:8px; height:44px;
}
.catbar-list{
  display:flex; overflow-x:auto; scrollbar-width:none; gap:12px; flex:1;
}
.catbar-list::-webkit-scrollbar{ display:none; }
.catbar a{
  color:#fff; text-decoration:none; white-space:nowrap; font-size:14px; padding:6px 10px; border-radius:6px;
}
.catbar a:hover{ background: rgba(255,255,255,.12); }
.catbar-prev,.catbar-next{
  background: rgba(255,255,255,.16); border:0; color:#fff; width:32px; height:32px; border-radius:50%; cursor:pointer;
}

/* Layout */
.layout{ display:grid; grid-template-columns: 240px 1fr; gap:16px; margin:16px auto; }

.left-menu{
  display:none;
  background: var(--card);
  border-radius:10px;
  padding:12px 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.left-menu h3{ font-size:14px; margin:6px 12px 8px; color:#111; }
.left-menu ul{ list-style:none; padding:0; margin:0; }
.left-menu li a{
  display:block; padding:10px 12px; color:#333; text-decoration:none; border-radius:8px; font-size:14px;
}
.left-menu li a:hover{ background:#f7f7f7; color:#000; }

/* Hero slider */
.hero{ grid-column: 2 / -1; }
.slider{ position:relative; border-radius:12px; overflow:hidden; box-shadow: 0 4px 16px rgba(0,0,0,.06); }
.slides{ display:flex; transition: transform .5s ease; }
.slide{ min-width:100%; height:360px; position:relative; }
.slide img{ width:100%; height:100%; object-fit:cover; display:block; }
.slider .nav{
  position:absolute; top:50%; transform:translateY(-50%); z-index:2;
  width:42px; height:42px; border:0; border-radius:50%; background: rgba(0,0,0,.35); color:#fff; cursor:pointer;
}
.slider .nav:hover{ background: rgba(0,0,0,.5); }
.slider .prev{ left:10px; } .slider .next{ right:10px; }
.dots{ position:absolute; bottom:10px; left:0; right:0; display:flex; gap:6px; justify-content:center; }
.dots button{
  width:8px; height:8px; border-radius:50%; border:0; background: rgba(255,255,255,.6);
}
.dots button.is-active{ background:#fff; transform: scale(1.2); }

/* Flash Sale */
.flash-sale{ background:#fff; margin-top:20px; padding:16px 0 24px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.fs-head{ display:flex; align-items:center; gap:16px; }
.fs-head h2{ color: var(--brand); margin:0; }
.fs-tabs{ display:flex; gap:8px; }
.fs-tab{ border:1px solid var(--brand); background:#fff; color: var(--brand); border-radius:20px; padding:6px 10px; cursor:pointer; }
.fs-tab.is-active, .fs-tab:hover{ background: var(--brand); color:#fff; }
.fs-countdown{ margin-left:auto; background: var(--brand); color:#fff; padding:8px 12px; border-radius:8px; font-weight:700; display:flex; align-items:center; gap:8px; }
.fs-countdown .cd-label{ background: rgba(255,255,255,.18); padding:4px 6px; border-radius:4px; font-weight:600; }

.fs-track{ position:relative; margin-top:12px; }
.fs-list{ display:flex; gap:12px; overflow-x:auto; scroll-snap-type:x mandatory; padding:6px 2px; }
.fs-list::-webkit-scrollbar{ height:10px; }
.fs-list::-webkit-scrollbar-thumb{ background:#ddd; border-radius:6px; }
.fs-scroll{ position:absolute; top:50%; transform:translateY(-50%); border:0; width:36px; height:36px; border-radius:50%; background:#fff; box-shadow:0 2px 8px rgba(0,0,0,.15); cursor:pointer; }
.fs-scroll.prev{ left:-10px; } .fs-scroll.next{ right:-10px; }

/* Product cards */
.product-card{
  background: var(--card);
  border-radius:10px;
  min-width: 180px;
  text-decoration:none; color:inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .15s ease;
  scroll-snap-align:start;
}
.product-card:hover{ transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.08); }
.product-card .img-wrap{ position:relative; aspect-ratio: 1/1; overflow:hidden; border-radius:10px 10px 0 0; }
.product-card img{ width:100%; height:100%; object-fit:cover; display:block; }
.badge{
  position:absolute; left:8px; top:8px; background: var(--brand); color:#fff;
  padding:4px 8px; border-radius:999px; font-size:12px; font-weight:700;
}
.badge-small{ font-size:11px; padding:2px 8px; }
.p-info{ padding:10px 12px 12px; }
.p-title{ font-size:14px; margin:0 0 8px; color:#111; line-height:1.45; height:40px; overflow:hidden; }
.p-price{ display:flex; align-items:center; gap:8px; }
.p-price .current{ color: var(--brand); font-weight:800; }
.p-price .old{ color:#999; }

.p-progress{
  background:#f1f1f1; height:8px; border-radius:999px; margin-top:8px; position:relative;
}
.p-progress span{
  display:block; height:100%; background: linear-gradient(90deg, var(--brand) 0%, #ff8a65 100%);
  border-radius:inherit;
}
.p-progress em{
  position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); font-style:normal; font-size:11px; color:#fff; text-shadow:0 1px 2px rgba(0,0,0,.2);
}

/* Recommended grid */
.recommended{ padding:24px 0 32px; }
.recommended h2{ margin:6px 0 12px; }
.grid{
  display:grid; gap:12px; grid-template-columns: repeat(6, 1fr);
}
.grid-card{ min-width:0; }

/* Footer */
.footer{ background:#1f1f1f; color:#ddd; margin-top:24px; }
.footer-grid{
  display:grid; grid-template-columns: repeat(4, 1fr); gap:24px; padding:32px 0;
}
.footer a{ color:#ddd; text-decoration:none; }
.footer a:hover{ color:#fff; text-decoration:underline; }
.footer h4{ color:#fff; margin-top:0; }
.app-badges{ display:flex; gap:12px; align-items:center; }
.app-badges .badges{ display:flex; flex-direction:column; gap:8px; }
.copyright{ border-top:1px solid #333; }
.copyright .container{ padding:12px 0; color:#999; font-size:13px; }

/* Category page */
.category-layout{
  display:grid; grid-template-columns: 260px 1fr; gap:16px; margin:16px 0 28px;
}
.filters{
  background:#fff; border-radius:10px; padding:12px; box-shadow:0 1px 2px rgba(0,0,0,.06);
}
.filters h3{ margin:6px 6px 12px; }
.filter-block{ border-top:1px solid var(--line); padding:12px 6px; }
.filter-block:first-of-type{ border-top:0; }
.filter-block h4{ margin:0 0 8px; font-size:14px; }
.filter-block label{ display:block; margin:6px 0; font-size:14px; }
.price-range{ display:flex; align-items:center; gap:8px; }
.price-range input{ width:100%; padding:8px 10px; border:1px solid var(--line); border-radius:8px; }
.price-range button{ padding:8px 12px; border-radius:8px; border:1px solid var(--brand); background:#fff; color:var(--brand); cursor:pointer; }
.price-range button:hover{ background:var(--brand); color:#fff; }

.sortbar{
  display:flex; align-items:center; justify-content:space-between;
  background:#fff; border-radius:10px; padding:10px 12px; box-shadow:0 1px 2px rgba(0,0,0,.06);
}
.sort-controls{ display:flex; align-items:center; gap:12px; }
.sort-controls select{ padding:8px 10px; border-radius:8px; border:1px solid var(--line); background:#fff; }
.view-toggle button{
  padding:6px 10px; border-radius:8px; border:1px solid var(--line); background:#fff; cursor:pointer;
}
.view-toggle .is-active{ border-color: var(--brand); color: var(--brand); }

.cat-grid{ margin-top:12px; }

.breadcrumb{ font-size:13px; color:#777; padding-top:8px; }
.breadcrumb a{ color:#666; text-decoration:none; }
.breadcrumb a:hover{ color:#111; }
.breadcrumb .current{ color:#111; }

.pagination{ display:flex; justify-content:center; gap:6px; margin-top:18px; }
.page{ display:inline-block; min-width:36px; height:36px; border-radius:8px; background:#fff; box-shadow:0 1px 2px rgba(0,0,0,.06); text-align:center; line-height:36px; color:#333; text-decoration:none; }
.page.is-active, .page:hover{ background:var(--brand); color:#fff; }
.page.dots{ background:transparent; box-shadow:none; color:#888; }

.rating{ font-size:12px; color:#ff9900; }
.sold{ color:#777; margin-left:6px; }

/* Responsive */
@media (min-width: 1024px){
  .left-menu{ display:block; }
  .hero{ grid-column: 2 / -1; }
}
@media (max-width: 1279px){
  .grid{ grid-template-columns: repeat(5, 1fr); }
}
@media (max-width: 1023px){
  .layout{ grid-template-columns: 1fr; }
  .hero{ grid-column: 1 / -1; }
  .category-layout{ grid-template-columns: 1fr; }
  .filters{ order:2; }
}
@media (max-width: 767px){
  .header-inner{ height:64px; }
  .catbar-inner{ height:40px; }
  .grid{ grid-template-columns: repeat(2, 1fr); }
  .footer-grid{ grid-template-columns: 1fr 1fr; }
  .search{ height:36px; }
  .hamburger{ display:block; }
  .icons{ display:none; }
}
@media (max-width: 575px){
  .grid{ grid-template-columns: repeat(2, 1fr); gap:10px; }
  .slide{ height:200px; }
  .fs-countdown{ display:none; }
}