/* RunShup base theme */
:root {
  --brand: #F05323; /* ส้ม CI ทางการ (CI Runshup.svg) */
  --brand-dark: #C2410C;
  --ink: #1C1917;
  --muted: #78716C;
  --bg: #FAFAF9;
  --card: #FFFFFF;
  --line: #E7E5E4;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Noto Sans Thai', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 16px; }

/* topbar */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  height: 60px;
}
.logo { font-weight: 800; font-size: 22px; letter-spacing: -0.5px; white-space: nowrap; display: flex; align-items: center; }
.logo .up { color: var(--brand); }
.logo img { height: 48px; width: auto; display: block; }
.searchbox { flex: 1; display: flex; }
.searchbox input {
  flex: 1; height: 40px; padding: 0 14px;
  border: 1.5px solid var(--line); border-right: none;
  border-radius: 8px 0 0 8px; font: inherit; outline: none;
}
.searchbox input:focus { border-color: var(--brand); }
.searchbox button {
  height: 40px; padding: 0 18px; border: none; cursor: pointer;
  background: var(--brand); color: #fff; border-radius: 0 8px 8px 0;
  font: inherit; font-weight: 600;
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font: inherit; font-weight: 600;
  border: 1.5px solid var(--line); background: var(--card); cursor: pointer;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); color: #fff; }

/* hero */
.hero {
  background: linear-gradient(120deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff; padding: 48px 0; margin-bottom: 24px;
}
.hero h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: -0.5px; }
.hero p { margin: 0; opacity: .9; font-size: 17px; }

/* category chips */
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 20px 0; }
.chip {
  padding: 8px 16px; border-radius: 999px; background: var(--card);
  border: 1.5px solid var(--line); cursor: pointer;
  font: inherit; font-weight: 600; font-size: 14px;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip-active { border-color: var(--brand); background: var(--brand); color: #fff; }
.chip-active:hover { color: #fff; }

/* product grid */
.grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  margin-bottom: 48px;
}
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.card .thumb { aspect-ratio: 1; background: var(--bg); width: 100%; object-fit: cover; }
.card .body { padding: 12px; }
.card .title { font-size: 14px; line-height: 1.4; margin: 0 0 6px; min-height: 2.8em; }
.card .price { color: var(--brand); font-weight: 800; font-size: 16px; }
.card .shop { color: var(--muted); font-size: 12px; margin-top: 4px; }

.empty {
  grid-column: 1 / -1; text-align: center; color: var(--muted);
  padding: 64px 0; font-size: 15px;
}

.cart-link { position: relative; }
#cart-badge {
  display: none; position: absolute; top: -6px; right: -8px;
  background: var(--brand); color: #fff; font-size: 11px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 999px;
  align-items: center; justify-content: center; padding: 0 5px;
}

/* topbar บนจอเล็ก: search ตกบรรทัดใหม่, ปุ่มกระชับ, ซ่อนลิงก์เปิดร้าน (มีใน hero/เมนูบัญชีแล้ว) */
@media (max-width: 720px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 0; row-gap: 10px; }
  .searchbox { order: 3; flex-basis: 100%; }
  .logo img { height: 38px; }
  .topbar-actions { margin-left: auto; gap: 6px; }
  .topbar-actions .btn { padding: 7px 10px; font-size: 13px; }
  .topbar-actions a[href="/seller/"] { display: none; }
  .acct-name { max-width: 64px; }
}

/* account menu (auth.js) */
.acct { position: relative; }
.acct-btn { display: inline-flex; align-items: center; gap: 7px; position: relative; }
.acct-dot { position: absolute; top: -6px; right: 18px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 800; min-width: 17px; height: 17px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 4px; }
.acct-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 100;
  min-width: 220px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.10); padding: 6px;
}
.acct.open .acct-menu { display: block; }
.acct-menu a {
  display: flex; align-items: center; gap: 9px; padding: 9px 12px;
  border-radius: 8px; font-size: 14px; font-weight: 600;
}
.acct-menu a:hover { background: var(--bg); color: var(--brand); }
.acct-menu a small { color: var(--muted); font-weight: 400; }
.acct-head { padding: 8px 12px 4px; font-size: 12px; color: var(--muted); word-break: break-all; }
.acct-sec {
  padding: 8px 12px 2px; font-size: 11px; color: var(--muted); font-weight: 700;
  letter-spacing: .4px; border-top: 1px solid var(--line); margin-top: 4px;
}
.acct-sec:empty { padding: 0; }

/* line-minimal icons (js/icons.js) */
.ico-line { vertical-align: -0.18em; flex-shrink: 0; }
[data-icon] { display: inline-flex; align-items: center; }
.btn .ico-line, .btn[data-icon] { vertical-align: -0.22em; }

footer {
  border-top: 1px solid var(--line); background: var(--card);
  padding: 24px 0; color: var(--muted); font-size: 13px;
}

/* ===== mobile hamburger drawer (js/nav.js) ===== */
.nav-burger { display: none; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0; border: 1.5px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink); cursor: pointer; flex-shrink: 0; }
.nav-burger:hover { border-color: var(--brand); color: var(--brand); }
.nav-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); opacity: 0; visibility: hidden; transition: opacity .2s; z-index: 200; }
.nav-overlay.show { opacity: 1; visibility: visible; }
.nav-drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 82%; max-width: 320px; background: var(--card); z-index: 201; transform: translateX(-100%); transition: transform .25s ease; display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0,0,0,.18); }
.nav-drawer.show { transform: translateX(0); }
.nav-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.nav-drawer-close { width: 38px; height: 38px; border: none; background: none; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; }
.nav-drawer-close:hover { background: var(--bg); color: var(--ink); }
.nav-drawer-links { display: flex; flex-direction: column; padding: 8px; gap: 2px; overflow-y: auto; flex: 1; }
.nav-drawer-links a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--ink); }
.nav-drawer-links a:hover, .nav-drawer-links a:active { background: var(--bg); color: var(--brand); }
.nav-drawer-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav-drawer-sell { color: var(--brand) !important; }
.nav-drawer-signin { margin: 8px 16px 20px; justify-content: center; }
body.nav-open { overflow: hidden; }

/* ===== in-app browser helper bar (Facebook / LINE) ===== */
.inapp-bar { display: flex; align-items: center; gap: 10px; background: #FFF7ED; border-bottom: 1px solid #FED7AA; color: #9A3412; padding: 9px 14px; font-size: 13px; line-height: 1.4; }
.inapp-bar .inapp-msg { flex: 1; min-width: 0; }
.inapp-bar .inapp-open { display: inline-flex; align-items: center; gap: 5px; background: var(--brand); color: #fff; border: none; border-radius: 7px; padding: 6px 11px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.inapp-bar .inapp-x { background: none; border: none; color: #9A3412; cursor: pointer; padding: 4px; display: inline-flex; flex-shrink: 0; }

/* ===== small screens: show hamburger, tidy header/hero, scroll wide tables ===== */
@media (max-width: 720px) {
  .nav-burger { display: inline-flex; }
  .hero { padding: 32px 0; }
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }
  /* wide data tables (orders / admin) scroll inside their own box instead of stretching the page */
  table { display: block; width: 100%; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .inapp-bar { font-size: 12px; gap: 8px; padding: 8px 12px; }
}
