/* ร้านบ้านยา — Modern Pharmacy / Clean / Friendly
   ออกแบบให้กดง่ายบนจอสัมผัส: ตัวอักษรใหญ่, ปุ่มสูง >= 56px, พื้นที่ขาวเยอะ */

:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-mute: #94a3b8;
  --line: #e2e8f0;
  --bg: #f6f9fc;
  --card: #ffffff;
  --brand: #0ea5a5;
  --brand-dark: #0b7f80;
  --danger: #e11d48;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --radius: 20px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px rgba(15, 23, 42, .06);
  --shadow-hover: 0 4px 12px rgba(15, 23, 42, .08), 0 16px 40px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, 'Segoe UI', sans-serif;
  font-size: 18px;
  line-height: 1.65;
  color: var(--ink);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, .display {
  font-family: 'Kanit', 'Sarabun', sans-serif;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px; max-width: 1240px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.logo-mark {
  width: 52px; height: 52px; border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), #22c55e);
  color: #fff; display: grid; place-items: center; font-size: 27px;
}
.logo-name { font-family: 'Kanit', sans-serif; font-size: 24px; font-weight: 600; }
.logo-sub { font-size: 14px; color: var(--ink-mute); margin-top: -4px; }

.searchbox { flex: 1; position: relative; min-width: 0; }
.searchbox input {
  width: 100%; height: 58px; padding: 0 20px 0 56px;
  font-size: 20px; font-family: inherit; color: var(--ink);
  border: 2px solid var(--line); border-radius: 999px; background: #fff;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.searchbox input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(14, 165, 165, .12); }
.searchbox .icon {
  position: absolute; left: 20px; top: 50%; transform: translateY(-50%);
  font-size: 22px; color: var(--ink-mute); pointer-events: none;
}
.searchbox .go {
  position: absolute; right: 6px; top: 6px; height: 46px; padding: 0 22px;
  border: 0; border-radius: 999px; background: var(--brand); color: #fff;
  font-family: 'Kanit', sans-serif; font-size: 17px; cursor: pointer;
}

.topbar-actions { display: flex; gap: 10px; flex-shrink: 0; }
.icon-btn {
  height: 52px; min-width: 52px; padding: 0 18px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink-soft);
  font-family: 'Kanit', sans-serif; font-size: 16px;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }

/* ------------------------------------------------------------- sections */
.section { padding: 34px 0 8px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.section-head h2 { font-size: 28px; }
.section-head .hint { color: var(--ink-mute); font-size: 17px; }

.hero {
  background: linear-gradient(135deg, #ecfeff, #f0fdf4);
  border-bottom: 1px solid var(--line);
  padding: 30px 0 32px;
}
.hero h1 { font-size: 34px; }
.hero p { font-size: 19px; color: var(--ink-soft); margin: 8px 0 0; }

/* --------------------------------------------------------- category grid */
.cat-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.cat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; min-height: 170px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
  border-top: 6px solid var(--c, var(--brand));
  transition: transform .12s ease, box-shadow .12s ease;
}
.cat-card:active { transform: scale(.98); }
.cat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.cat-icon {
  width: 62px; height: 62px; border-radius: 18px; display: grid; place-items: center;
  font-size: 32px; background: color-mix(in srgb, var(--c) 12%, #fff);
  margin-bottom: 6px;
}
.cat-name { font-family: 'Kanit', sans-serif; font-size: 21px; font-weight: 600; }
.cat-desc { font-size: 16px; color: var(--ink-soft); flex: 1; }
.cat-count { font-size: 15px; color: var(--c); font-weight: 600; }

/* ---------------------------------------------------------- product grid */
.prod-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
}
.prod-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .12s ease, box-shadow .12s ease;
}
.prod-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.prod-card:active { transform: scale(.99); }
.prod-thumb {
  aspect-ratio: 1 / 1; background: #f8fafc; display: grid; place-items: center;
  position: relative; overflow: hidden;
}
.prod-thumb img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.thumb-ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: 64px; background: color-mix(in srgb, var(--c, #0ea5a5) 8%, #fff);
}
.prod-body { padding: 16px 16px 18px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.prod-name { font-family: 'Kanit', sans-serif; font-size: 19px; font-weight: 500; line-height: 1.4; }
.prod-size { font-size: 15px; color: var(--ink-mute); }
.prod-desc { font-size: 16px; color: var(--ink-soft); flex: 1; }
.prod-price { font-family: 'Kanit', sans-serif; font-size: 24px; font-weight: 600; color: var(--brand-dark); }
.prod-price small { font-size: 15px; font-weight: 400; color: var(--ink-mute); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 56px; padding: 0 24px; border-radius: 14px; border: 0; cursor: pointer;
  font-family: 'Kanit', sans-serif; font-size: 18px; font-weight: 500;
  background: var(--brand); color: #fff; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.98); }
.btn-ghost { background: #fff; color: var(--ink); border: 2px solid var(--line); }
.btn-ghost:hover { background: #f8fafc; border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { min-height: 42px; padding: 0 14px; font-size: 15px; border-radius: 10px; }

/* -------------------------------------------------------------- badges */
.badges { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 6px; }
.badge {
  font-family: 'Kanit', sans-serif; font-size: 13px; font-weight: 500;
  padding: 4px 12px; border-radius: 999px; background: #f1f5f9; color: var(--ink-soft);
}
.badge-hot { background: #fef2f2; color: #dc2626; }
.badge-rec { background: #eff6ff; color: #2563eb; }
.badge-out { background: #f1f5f9; color: #64748b; }
.badge-cat { background: color-mix(in srgb, var(--c, #0ea5a5) 12%, #fff); color: var(--c, var(--brand-dark)); }

.pharm-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--warn-bg); border: 1px solid #fde68a; color: var(--warn);
  border-radius: 14px; padding: 12px 16px; font-size: 16px;
}
.pharm-note strong { font-family: 'Kanit', sans-serif; font-weight: 500; }

/* ------------------------------------------------------------ breadcrumb */
.crumb { display: flex; align-items: center; gap: 10px; padding: 20px 0 4px; font-size: 16px; color: var(--ink-mute); flex-wrap: wrap; }
.crumb a:hover { color: var(--brand); }

.chips { display: flex; gap: 10px; overflow-x: auto; padding: 6px 0 14px; -webkit-overflow-scrolling: touch; }
.chip {
  flex-shrink: 0; padding: 10px 18px; border-radius: 999px; background: #fff;
  border: 2px solid var(--line); font-size: 16px; white-space: nowrap;
}
.chip.active { background: var(--c, var(--brand)); border-color: var(--c, var(--brand)); color: #fff; }

/* --------------------------------------------------------- product page */
.detail { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 32px; align-items: start; padding: 12px 0 30px; }
.detail-img {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  aspect-ratio: 1 / 1; display: grid; place-items: center; overflow: hidden; box-shadow: var(--shadow);
}
.detail-img img { width: 100%; height: 100%; object-fit: contain; padding: 18px; }
.detail h1 { font-size: 32px; }
.detail .price { font-family: 'Kanit', sans-serif; font-size: 40px; font-weight: 600; color: var(--brand-dark); }
.spec { border-top: 1px solid var(--line); padding: 16px 0; display: grid; grid-template-columns: 150px 1fr; gap: 10px 16px; }
.spec dt { color: var(--ink-mute); font-size: 16px; }
.spec dd { margin: 0; }
.block { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin-top: 14px; }
.block h3 { font-size: 19px; margin-bottom: 6px; }
.block p { margin: 0; color: var(--ink-soft); white-space: pre-line; }

/* --------------------------------------------------------------- footer */
.footer { margin-top: 46px; padding: 26px 0 34px; border-top: 1px solid var(--line); color: var(--ink-mute); font-size: 15px; background: #fff; }
.footer a { color: var(--ink-soft); }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-mute); }
.empty .big { font-size: 60px; margin-bottom: 10px; }

/* --------------------------------------------------------------- admin */
.admin-bar { background: #0f172a; color: #e2e8f0; }
.admin-bar .topbar-in { padding: 12px 20px; }
.admin-bar a { color: #cbd5e1; }
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-nav a { padding: 10px 16px; border-radius: 10px; font-family: 'Kanit', sans-serif; font-size: 16px; }
.admin-nav a:hover, .admin-nav a.active { background: rgba(255, 255, 255, .12); color: #fff; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 22px; margin-bottom: 18px; box-shadow: var(--shadow); }
.panel h2 { font-size: 22px; margin-bottom: 12px; }

.stat-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat .n { font-family: 'Kanit', sans-serif; font-size: 28px; font-weight: 600; }
.stat .l { font-size: 15px; color: var(--ink-mute); }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 16px; color: var(--ink-soft); margin-bottom: 6px; font-weight: 500; }
.field input[type=text], .field input[type=number], .field input[type=password],
.field select, .field textarea {
  width: 100%; padding: 12px 14px; font-size: 17px; font-family: inherit; color: var(--ink);
  border: 2px solid var(--line); border-radius: 12px; background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { min-height: 96px; resize: vertical; }
.field .help { font-size: 14px; color: var(--ink-mute); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.check {
  display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px;
  border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-size: 16px; background: #fff;
}
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.check:has(input:checked) { border-color: var(--brand); background: #f0fdfa; color: var(--brand-dark); }

table.list { width: 100%; border-collapse: collapse; font-size: 16px; }
table.list th { text-align: left; font-family: 'Kanit', sans-serif; font-weight: 500; color: var(--ink-mute); font-size: 15px; padding: 10px; border-bottom: 2px solid var(--line); }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:hover td { background: #f8fafc; }
.tiny-thumb { width: 54px; height: 54px; border-radius: 10px; object-fit: cover; background: #f1f5f9; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

.flash { padding: 14px 18px; border-radius: 12px; margin-bottom: 16px; font-size: 17px; }
.flash.ok { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.flash.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

.login-box { max-width: 420px; margin: 12vh auto; }

/* --------------------------------------------------------------- mobile */
@media (max-width: 820px) {
  body { font-size: 17px; }
  .detail { grid-template-columns: 1fr; gap: 18px; }
  .detail h1 { font-size: 26px; }
  .detail .price { font-size: 32px; }
  .hero h1 { font-size: 26px; }
  .topbar-in { flex-wrap: wrap; gap: 10px; }
  .searchbox { order: 3; width: 100%; flex-basis: 100%; }
  .logo-sub { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .cat-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .cat-card { min-height: 150px; padding: 16px; }
  .cat-icon { width: 50px; height: 50px; font-size: 26px; }
  .cat-name { font-size: 18px; }
  .cat-desc { font-size: 14px; }
  .prod-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .prod-name { font-size: 17px; }
  .spec { grid-template-columns: 110px 1fr; }
  .hide-sm { display: none; }
}

@media print {
  .topbar, .footer, .btn, .crumb { display: none; }
}
