/* ==========================================================================
   ร่มสน คลินิกเวชกรรม — DEMO ระบบจองคิว
   Stylesheet เดียวใช้ทั้ง 5 หน้า
   ยึดตาม design spec: output/showcase/clinic/design-spec.md (ทิศทาง A "Clinical Calm")
   ห้าม hardcode สี — ใช้ custom property ทั้งหมด
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens (spec ข้อ 3 + 4.3)
   -------------------------------------------------------------------------- */
:root {
  /* Brand */
  --c-primary:        #14524A;
  --c-primary-hover:  #0E3F39;
  --c-primary-soft:   #E4EFEB;
  --c-secondary:      #5C8D7F;   /* ห้ามใช้เป็นสีข้อความบนพื้นสว่าง (3.8:1) */
  --c-secondary-soft: #DCE8E3;

  /* พื้นสีเข้มที่ "ต้องเข้มทั้ง light และ dark mode" — footer, CTA band
     ⚠️ ห้ามใช้ --c-primary เป็นพื้นแล้ววางตัวอักษรขาว
        เพราะ dark mode --c-primary จะกลายเป็นเขียวมิ้นต์สว่าง → ตัวอักษรขาวอ่านไม่ออก */
  --c-primary-surface: #14524A;
  --c-on-primary:      #FFFFFF;              /* 9.0:1 บน #14524A ✅ AAA */
  --c-on-primary-dim:  rgba(255,255,255,.82); /* ยังผ่าน AA */
  --c-on-primary-line: rgba(255,255,255,.22);

  /* Accent — CTA จองคิว / LINE */
  --c-accent:         #A85A34;
  --c-accent-hover:   #8C4826;
  --c-accent-soft:    #F5E7DE;
  --c-accent-text:    #FFFFFF;

  /* Semantic */
  --c-success:        #2E7D5B;
  --c-success-soft:   #E1F0E8;
  --c-error:          #A32E2E;
  --c-error-soft:     #F7E6E6;
  --c-warn:           #8A5A12;
  --c-warn-soft:      #FBF0DC;

  /* Background */
  --c-bg:             #FBFAF7;
  --c-bg-alt:         #F2EFE9;
  --c-surface:        #FFFFFF;
  --c-border:         #E3DED4;
  --c-border-strong:  #CFC8BA;

  /* Text */
  --c-text:           #1B2320;
  --c-text-body:      #4A5551;
  --c-text-muted:     #626F6A;
  --c-text-invert:    #FFFFFF;

  /* Fonts */
  --font-head: 'Anuphan', 'IBM Plex Sans Thai Looped', system-ui, -apple-system, sans-serif;
  --font-body: 'IBM Plex Sans Thai Looped', 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  --font-num:  'IBM Plex Sans', 'IBM Plex Sans Thai Looped', system-ui, sans-serif;

  /* Spacing (base 4px) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 128px;

  /* Radius */
  --r-sm: 8px; --r-md: 12px; --r-lg: 20px; --r-xl: 28px; --r-pill: 999px;

  /* Shadow — เขียวอ่อน ไม่ใช่ดำ */
  --sh-1: 0 1px 2px rgba(20,82,74,.06);
  --sh-2: 0 4px 12px rgba(20,82,74,.07);
  --sh-3: 0 12px 32px rgba(20,82,74,.10);

  /* Motion */
  --ease: cubic-bezier(.22,.61,.36,1);

  /* Layout */
  --container: 1200px;
  --header-h: 60px;
  --stickybar-h: 56px;
}

@media (min-width: 1024px) {
  :root { --header-h: 72px; }
}

/* Dark mode (spec 3.2) */
@media (prefers-color-scheme: dark) {
  :root {
    --c-primary:        #7FC4B4;
    --c-primary-hover:  #9AD4C6;
    --c-primary-soft:   #16332D;
    --c-secondary:      #8FB3A8;
    --c-secondary-soft: #1D2F2A;

    /* dark mode: เขียวเข้มที่ "สว่างพอจะแยกออกจากพื้นหลัง แต่เข้มพอให้ตัวอักษรสว่างอ่านออก"
       ตรวจแล้ว: #ECEFEC บน #1D5249 = 7.7:1 (AAA) · dim = 5.6:1 (AA) · แยกจากพื้น #0E1613 = 2.1:1 */
    --c-primary-surface: #1D5249;
    --c-on-primary:      #ECEFEC;
    --c-on-primary-dim:  rgba(236,239,236,.80);
    --c-on-primary-line: rgba(236,239,236,.22);

    --c-accent:         #E08A5C;
    --c-accent-hover:   #EC9F76;
    --c-accent-soft:    #33200F;
    --c-accent-text:    #2A1409;

    --c-success:        #6DBF97;
    --c-success-soft:   #142C21;
    --c-error:          #E88A8A;
    --c-error-soft:     #2E1717;
    --c-warn:           #E0B36A;
    --c-warn-soft:      #2E2413;

    --c-bg:             #0E1613;
    --c-bg-alt:         #131E1A;
    --c-surface:        #16211D;
    --c-border:         #2A3733;
    --c-border-strong:  #3A4B45;

    --c-text:           #ECEFEC;
    --c-text-body:      #AFBAB5;
    --c-text-muted:     #93A19B;
    --c-text-invert:    #0E1613;
  }
}

/* --------------------------------------------------------------------------
   2. Reset + base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-body);
  font-size: 1rem;              /* 16px mobile */
  line-height: 1.8;             /* ไทยต้อง >= 1.6 */
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: none;
  /* กัน sticky CTA bar บังเนื้อหาท้ายหน้า */
  padding-bottom: calc(var(--stickybar-h) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  body { font-size: 1.0625rem; padding-bottom: 0; }
}

img, svg { max-width: 100%; height: auto; display: block; }

h1, h2, h3, h4, h5 {
  font-family: var(--font-head);
  color: var(--c-text);
  margin: 0 0 var(--s-4);
  font-weight: 600;
}

h1 { font-size: 1.75rem; line-height: 1.30; }
h2 { font-size: 1.5rem;  line-height: 1.35; }
h3 { font-size: 1.25rem; line-height: 1.40; }
h4 { font-size: 1.125rem; line-height: 1.45; font-weight: 500; }

@media (min-width: 1024px) {
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.5rem; }
  h4 { font-size: 1.25rem; }
}

p { margin: 0 0 var(--s-4); color: var(--c-text-body); max-width: 68ch; }

a { color: var(--c-primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--c-primary-hover); }

/* Focus ring — ต้องเห็นชัดทุกจุด */
:focus-visible {
  outline: 2px solid var(--c-accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* Utility */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: 20px; }
@media (min-width: 768px)  { .container { padding-inline: 32px; } }
@media (min-width: 1024px) { .container { padding-inline: 40px; } }

.section { padding-block: 56px; }
@media (min-width: 768px)  { .section { padding-block: 72px; } }
@media (min-width: 1024px) { .section { padding-block: 96px; } }
.section--alt { background: var(--c-bg-alt); }
.section--tight { padding-block: 32px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: var(--s-4); top: -100px; z-index: 200;
  background: var(--c-primary); color: var(--c-text-invert);
  padding: var(--s-3) var(--s-5); border-radius: var(--r-md);
  transition: top .2s var(--ease);
}
.skip-link:focus { top: var(--s-3); color: var(--c-text-invert); }

.eyebrow {
  font-family: var(--font-head); font-size: .8125rem; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;   /* อังกฤษเท่านั้น */
  color: var(--c-accent); margin: 0 0 var(--s-2);
}
.lead { font-size: 1.0625rem; line-height: 1.7; color: var(--c-text-body); }
@media (min-width: 1024px) { .lead { font-size: 1.1875rem; } }

.small { font-size: .9375rem; line-height: 1.7; }
.caption { font-size: .8125rem; line-height: 1.6; font-weight: 500; color: var(--c-text-muted); }
.muted { color: var(--c-text-muted); }
.num { font-family: var(--font-num); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: var(--s-4); }

.section-head { margin-bottom: var(--s-6); }
.section-head p { margin-bottom: 0; max-width: 60ch; }
@media (max-width: 767px) { .section-head { text-align: center; }
  .section-head p { margin-inline: auto; } }

/* --------------------------------------------------------------------------
   3. แถบ DEMO (บังคับทุกหน้า)
   -------------------------------------------------------------------------- */
.demo-banner {
  background: var(--c-warn-soft);
  color: var(--c-text);
  border-bottom: 1px solid var(--c-border-strong);
  font-size: .8125rem;
  line-height: 1.6;
  text-align: center;
  padding: var(--s-2) var(--s-4);
}
.demo-banner strong { font-weight: 600; }

/* --------------------------------------------------------------------------
   4. Header
   -------------------------------------------------------------------------- */
.header {
  position: sticky; top: 0; z-index: 100;
  background: color-mix(in srgb, var(--c-surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid transparent;
  transition: box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.header.is-scrolled { box-shadow: var(--sh-1); border-bottom-color: var(--c-border); }

.header__inner {
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-4);
}

.logo {
  display: flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-head); font-weight: 600; font-size: 1.0625rem;
  color: var(--c-primary); text-decoration: none; white-space: nowrap;
}
.logo__mark { width: 32px; height: 32px; flex: none; }
.logo__sub { display: block; font-size: .75rem; font-weight: 400; color: var(--c-text-muted); }

.nav { margin-left: auto; display: none; }
@media (min-width: 1024px) { .nav { display: block; } }
.nav__list { display: flex; gap: var(--s-5); list-style: none; margin: 0; padding: 0; }
.nav__link {
  font-size: .9375rem; color: var(--c-text-body); text-decoration: none;
  padding: var(--s-2) 0; border-bottom: 2px solid transparent;
}
.nav__link:hover { color: var(--c-primary); }
.nav__link[aria-current="page"] { color: var(--c-primary); border-bottom-color: var(--c-accent); font-weight: 500; }

.header__cta { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
@media (min-width: 1024px) { .header__cta { margin-left: var(--s-5); } }

.nav-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 1px solid var(--c-border-strong);
  background: var(--c-surface); border-radius: var(--r-md); cursor: pointer;
  color: var(--c-text);
}
@media (min-width: 1024px) { .nav-toggle { display: none; } }

/* Drawer มือถือ */
.drawer {
  position: fixed; inset: 0; z-index: 150;
  background: var(--c-bg); padding: var(--s-5) 20px;
  display: none; flex-direction: column; gap: var(--s-4);
  overflow-y: auto;
}
.drawer[open], .drawer.is-open { display: flex; }
.drawer__head { display: flex; align-items: center; justify-content: space-between; }
.drawer__close {
  width: 44px; height: 44px; border-radius: var(--r-md);
  border: 1px solid var(--c-border-strong); background: var(--c-surface);
  cursor: pointer; color: var(--c-text); font-size: 1.25rem; line-height: 1;
}
.drawer__list { list-style: none; margin: 0; padding: 0; }
.drawer__list li + li { border-top: 1px solid var(--c-border); }
.drawer__list a {
  display: block; padding: var(--s-4) 0; font-size: 1.0625rem;
  color: var(--c-text); text-decoration: none; min-height: 44px;
}
.drawer__list a[aria-current="page"] { color: var(--c-primary); font-weight: 600; }

/* --------------------------------------------------------------------------
   5. ปุ่ม
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 44px; padding: var(--s-3) var(--s-5);
  font-family: var(--font-head); font-size: 1rem; font-weight: 600; line-height: 1.2;
  border-radius: var(--r-pill); border: 1px solid transparent;
  text-decoration: none; cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.btn--primary { background: var(--c-primary); color: var(--c-text-invert); }
.btn--primary:hover:not(:disabled) { background: var(--c-primary-hover); color: var(--c-text-invert); }
.btn--accent { background: var(--c-accent); color: var(--c-accent-text); }
.btn--accent:hover:not(:disabled) { background: var(--c-accent-hover); color: var(--c-accent-text); }
.btn--outline { background: transparent; border-color: var(--c-border-strong); color: var(--c-text); }
.btn--outline:hover:not(:disabled) { border-color: var(--c-primary); color: var(--c-primary); }
.btn--ghost { background: transparent; color: var(--c-primary); padding-inline: var(--s-3); }
.btn--ghost:hover { background: var(--c-primary-soft); }
.btn--sm { min-height: 38px; padding: var(--s-2) var(--s-4); font-size: .9375rem; }
.btn--lg { min-height: 52px; padding: var(--s-4) var(--s-6); }
.btn--block { width: 100%; }
.btn--danger { background: transparent; border-color: var(--c-error); color: var(--c-error); }
.btn--danger:hover:not(:disabled) { background: var(--c-error-soft); color: var(--c-error); }

/* ปุ่มโทรใน header ซ่อนบนจอเล็กมาก */
@media (max-width: 419px) { .header__cta .btn--outline { display: none; } }

.btn-row { display: flex; flex-direction: column; gap: var(--s-3); }
@media (min-width: 640px) { .btn-row { flex-direction: row; flex-wrap: wrap; } }
.btn-row .btn { width: 100%; }
@media (min-width: 640px) { .btn-row .btn { width: auto; } }

/* --------------------------------------------------------------------------
   6. Card / ตาราง / กล่องข้อมูล
   -------------------------------------------------------------------------- */
.card {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); padding: var(--s-5);
}
.card--flush { padding: 0; overflow: hidden; }

.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: 1fr; }
.grid--3 { grid-template-columns: 1fr; }
@media (min-width: 640px)  { .grid--2, .grid--3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grid--3 { grid-template-columns: repeat(3, 1fr); } }

.chip {
  display: inline-flex; align-items: center; gap: var(--s-1);
  background: var(--c-primary-soft); color: var(--c-primary);
  font-size: .8125rem; font-weight: 600; line-height: 1.4;
  padding: var(--s-1) var(--s-3); border-radius: var(--r-pill);
}
.chip--accent  { background: var(--c-accent-soft);  color: var(--c-accent); }
.chip--success { background: var(--c-success-soft); color: var(--c-success); }
.chip--warn    { background: var(--c-warn-soft);    color: var(--c-warn); }
.chip--error   { background: var(--c-error-soft);   color: var(--c-error); }
.chip--muted   { background: var(--c-bg-alt);       color: var(--c-text-muted); }

/* Disclaimer band (spec 6.10) */
.disclaimer {
  background: var(--c-bg-alt); border-left: 3px solid var(--c-secondary);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  padding: var(--s-4) var(--s-5);
  font-size: .9375rem; line-height: 1.7; color: var(--c-text-muted);
  display: flex; gap: var(--s-3);
}
.disclaimer svg { flex: none; margin-top: 4px; color: var(--c-secondary); }
.disclaimer p { color: inherit; margin: 0; }

/* กล่องเตือน */
.note {
  border-radius: var(--r-md); padding: var(--s-4);
  font-size: .9375rem; line-height: 1.7; display: flex; gap: var(--s-3);
}
.note p:last-child { margin-bottom: 0; }
.note--info    { background: var(--c-primary-soft); color: var(--c-text); }
.note--warn    { background: var(--c-warn-soft);    color: var(--c-text); }
.note--success { background: var(--c-success-soft); color: var(--c-text); }
.note--error   { background: var(--c-error-soft);   color: var(--c-text); }
.note svg { flex: none; margin-top: 4px; }

/* Trust bar */
.trustbar { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-5); }
@media (min-width: 768px) { .trustbar { grid-template-columns: repeat(4, 1fr); } }
.trustbar__num { font-family: var(--font-num); font-size: 1.75rem; font-weight: 600; color: var(--c-primary); line-height: 1.2; }
@media (min-width: 768px) { .trustbar__num { font-size: 2rem; } }
.trustbar__label { font-size: .9375rem; color: var(--c-text-muted); }

/* --------------------------------------------------------------------------
   7. รูป placeholder (inline SVG — ไม่มีการโหลดรูปจากอินเทอร์เน็ต)
   -------------------------------------------------------------------------- */
.img-slot {
  position: relative; display: block; width: 100%;
  background: var(--c-primary-soft);
  border: 1px dashed var(--c-secondary);
  border-radius: var(--r-lg); overflow: hidden;
  color: var(--c-primary);
}
.img-slot svg { width: 100%; height: 100%; display: block; }
.img-slot__tag {
  position: absolute; left: var(--s-3); bottom: var(--s-3);
  background: color-mix(in srgb, var(--c-surface) 88%, transparent);
  color: var(--c-text-muted); font-size: .75rem; line-height: 1.5;
  padding: 2px var(--s-2); border-radius: var(--r-sm);
  border: 1px solid var(--c-border);
}
.ratio-16x9 { aspect-ratio: 16 / 9; }
.ratio-4x5  { aspect-ratio: 4 / 5; }
.ratio-4x3  { aspect-ratio: 4 / 3; }
.ratio-1x1  { aspect-ratio: 1 / 1; }

/* --------------------------------------------------------------------------
   8. Hero
   -------------------------------------------------------------------------- */
.hero { padding-block: 40px 48px; background: var(--c-bg); }
@media (min-width: 1024px) { .hero { padding-block: 72px 96px; } }
.hero__grid { display: grid; gap: var(--s-6); align-items: center; }
@media (min-width: 1024px) { .hero__grid { grid-template-columns: 55fr 45fr; gap: var(--s-8); } }
.hero__media { position: relative; }
.hero__media .img-slot { border-radius: var(--r-xl) var(--r-md) var(--r-xl) var(--r-md); }
.hero h1 { margin-bottom: var(--s-4); }
.hero .btn-row { margin-top: var(--s-6); }

.hero--sub { padding-block: 28px 24px; background: var(--c-bg-alt); }
.hero--sub h1 { margin-bottom: var(--s-2); }
.hero--sub p { margin-bottom: 0; }

.breadcrumb { font-size: .8125rem; color: var(--c-text-muted); margin-bottom: var(--s-3); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; padding: 0; }
.breadcrumb li + li::before { content: "›"; margin-right: var(--s-2); color: var(--c-border-strong); }

/* --------------------------------------------------------------------------
   9. การ์ดบริการ + ฟิลเตอร์ (spec 6.3 / 6.5)
   -------------------------------------------------------------------------- */
.filter-bar {
  position: sticky; top: var(--header-h); z-index: 60;
  background: color-mix(in srgb, var(--c-bg) 95%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-border);
  padding-block: var(--s-3);
}
.filter-scroll {
  display: flex; gap: var(--s-2); overflow-x: auto;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
  padding-bottom: var(--s-2);
  scrollbar-width: none;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-wrap { position: relative; }
.filter-wrap::after {
  content: ""; position: absolute; right: 0; top: 0; bottom: var(--s-2); width: 32px;
  background: linear-gradient(to right, transparent, var(--c-bg));
  pointer-events: none;
}
@media (min-width: 900px) { .filter-wrap::after { display: none; } .filter-scroll { flex-wrap: wrap; overflow: visible; } }

.filter-chip {
  scroll-snap-align: start; white-space: nowrap; flex: none;
  min-height: 40px; padding: var(--s-2) var(--s-4);
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-pill); color: var(--c-text-body);
  font-family: var(--font-body); font-size: .9375rem; cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease);
}
.filter-chip:hover { border-color: var(--c-secondary); }
.filter-chip[aria-pressed="true"] {
  background: var(--c-primary); color: var(--c-text-invert); border-color: var(--c-primary); font-weight: 600;
}
.filter-meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); margin-top: var(--s-3); font-size: .875rem; color: var(--c-text-muted); }

.card-service {
  display: flex; flex-direction: column;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); box-shadow: var(--sh-1); overflow: hidden;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.card-service:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--c-secondary); }
.card-service__media { border: 0; border-radius: 0; border-bottom: 1px solid var(--c-border); }
.card-service__body { padding: var(--s-4) var(--s-5) var(--s-5); display: flex; flex-direction: column; flex: 1; }
.card-service__body h3 { font-size: 1.125rem; margin: var(--s-3) 0 var(--s-2); }
.card-service__desc {
  font-size: .9375rem; color: var(--c-text-body); margin-bottom: var(--s-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card-service__meta {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  font-size: .8125rem; color: var(--c-text-muted); margin-bottom: var(--s-4);
}
.card-service__meta span { display: inline-flex; align-items: center; gap: 4px; }
.card-service__foot {
  margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--c-border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
}
.price { font-family: var(--font-num); font-size: 1.5rem; font-weight: 600; color: var(--c-text); line-height: 1.3; }
.price small { display: block; font-family: var(--font-body); font-size: .75rem; font-weight: 400; color: var(--c-text-muted); }

.empty-state { text-align: center; padding: var(--s-8) var(--s-4); }

/* --------------------------------------------------------------------------
   10. ฟอร์ม (spec 6.6)
   -------------------------------------------------------------------------- */
.field { margin-bottom: var(--s-5); }
.field > label, .field .label {
  display: block; font-size: .9375rem; font-weight: 500;
  color: var(--c-text); margin-bottom: var(--s-2);
}
.field .req { color: var(--c-error); }
.field .hint { font-size: .8125rem; color: var(--c-text-muted); margin: var(--s-1) 0 var(--s-2); }

input[type="text"], input[type="tel"], input[type="email"], input[type="date"], select, textarea {
  width: 100%; min-height: 48px; padding: var(--s-3) var(--s-4);
  font-family: var(--font-body); font-size: 1rem; line-height: 1.6;
  color: var(--c-text); background: var(--c-surface);
  border: 1px solid var(--c-border-strong); border-radius: var(--r-md);
  transition: border-color .2s var(--ease);
}
textarea { min-height: 96px; resize: vertical; line-height: 1.7; }
select {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23626F6A' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 44px;
}
input:focus, select:focus, textarea:focus { border-color: var(--c-primary); }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--c-error); }

.field__error {
  display: none; align-items: center; gap: var(--s-1);
  margin-top: var(--s-2); font-size: .875rem; color: var(--c-error);
}
.field__error.is-visible { display: flex; }

.checkbox {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4); background: var(--c-bg-alt);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
}
.checkbox input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; flex: none; margin-top: 2px; accent-color: var(--c-primary); }
.checkbox label { font-size: .9375rem; line-height: 1.7; color: var(--c-text-body); margin: 0; }

.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

/* --------------------------------------------------------------------------
   11. Stepper (หน้าจองคิว)
   -------------------------------------------------------------------------- */
.stepper { margin-bottom: var(--s-6); }
.stepper__list {
  display: flex; list-style: none; margin: 0; padding: 0; gap: var(--s-1);
  overflow-x: auto; scrollbar-width: none;
}
.stepper__list::-webkit-scrollbar { display: none; }
.stepper__item {
  flex: 1; min-width: 84px; text-align: center;
  font-size: .75rem; color: var(--c-text-muted); line-height: 1.5;
  padding-top: var(--s-6); position: relative;
}
.stepper__item::before {
  content: attr(data-step);
  position: absolute; top: 0; left: 50%; transform: translateX(-50%);
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-bg-alt); border: 1px solid var(--c-border-strong);
  color: var(--c-text-muted); font-family: var(--font-num); font-size: .8125rem; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.stepper__item::after {
  content: ""; position: absolute; top: 14px; left: calc(50% + 18px); right: calc(-50% + 18px);
  height: 1px; background: var(--c-border-strong);
}
.stepper__item:last-child::after { display: none; }
.stepper__item.is-done::before { background: var(--c-primary-soft); border-color: var(--c-primary); color: var(--c-primary); content: "✓"; }
.stepper__item.is-current::before { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-text-invert); }
.stepper__item.is-current { color: var(--c-text); font-weight: 600; }

.step-panel { display: none; }
.step-panel.is-active { display: block; }

.step-actions {
  display: flex; gap: var(--s-3); margin-top: var(--s-6);
  padding-top: var(--s-5); border-top: 1px solid var(--c-border);
}
.step-actions .btn { flex: 1; }
@media (min-width: 640px) { .step-actions .btn { flex: 0 0 auto; } .step-actions .btn--next { margin-left: auto; } }

/* ตัวเลือกแบบ radio card */
.option-list { display: grid; gap: var(--s-3); }
@media (min-width: 768px) { .option-list--2 { grid-template-columns: repeat(2, 1fr); } }
.option {
  position: relative; display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-4); background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--r-md);
  cursor: pointer; transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.option:hover { border-color: var(--c-secondary); }
.option input { position: absolute; opacity: 0; width: 0; height: 0; }
.option__dot {
  flex: none; width: 22px; height: 22px; margin-top: 2px; border-radius: 50%;
  border: 2px solid var(--c-border-strong); background: var(--c-surface);
  display: flex; align-items: center; justify-content: center;
}
.option__dot::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: transparent; }
.option:has(input:checked) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.option:has(input:checked) .option__dot { border-color: var(--c-primary); }
.option:has(input:checked) .option__dot::after { background: var(--c-primary); }
.option:has(input:focus-visible) { outline: 2px solid var(--c-accent); outline-offset: 2px; }
.option__body { flex: 1; min-width: 0; }
.option__title { font-family: var(--font-head); font-weight: 600; font-size: 1rem; color: var(--c-text); }
.option__meta { font-size: .8125rem; color: var(--c-text-muted); line-height: 1.6; }
.option__price { font-family: var(--font-num); font-weight: 600; color: var(--c-text); white-space: nowrap; }
.option.is-disabled { opacity: .5; cursor: not-allowed; background: var(--c-bg-alt); }

/* --------------------------------------------------------------------------
   12. ปฏิทิน + ช่องเวลา (หัวใจของงาน)
   -------------------------------------------------------------------------- */
/* โครงหน้าจองคิว: เนื้อหา + กล่องสรุปด้านข้าง */
.booking-layout { display: grid; gap: var(--s-6); }
@media (min-width: 1024px) {
  .booking-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-7); align-items: start; }
}

.booking-cols { display: grid; gap: var(--s-6); }
@media (min-width: 640px) and (max-width: 1023px) { .booking-cols { grid-template-columns: 320px 1fr; align-items: start; } }
@media (min-width: 1200px) { .booking-cols { grid-template-columns: 320px 1fr; align-items: start; } }

/* แถวของปฏิทินต้องไม่กิน grid — ให้ cell ไหลลงตาราง 7 คอลัมน์โดยตรง */
.calendar__grid [role="row"] { display: contents; }

.calendar {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-lg); padding: var(--s-4); box-shadow: var(--sh-1);
}
.calendar__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); margin-bottom: var(--s-4); }
.calendar__title { font-family: var(--font-head); font-weight: 600; font-size: 1.0625rem; color: var(--c-text); }
.calendar__nav {
  width: 44px; height: 44px; flex: none; border-radius: var(--r-md);
  border: 1px solid var(--c-border-strong); background: var(--c-surface);
  color: var(--c-text); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.calendar__nav:hover:not(:disabled) { border-color: var(--c-primary); color: var(--c-primary); }
.calendar__nav:disabled { opacity: .35; cursor: not-allowed; }

.calendar__dow {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
  font-size: .75rem; font-weight: 600; color: var(--c-text-muted);
  text-align: center; margin-bottom: var(--s-2);
}
.calendar__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }

.day {
  position: relative; aspect-ratio: 1 / 1; min-height: 42px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--c-text);
  font-family: var(--font-num); font-size: .9375rem; cursor: pointer;
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.day:hover:not(.is-disabled) { background: var(--c-primary-soft); }
.day.is-outside { visibility: hidden; }
.day.is-disabled { color: var(--c-text-muted); opacity: .38; cursor: not-allowed; text-decoration: line-through; }
.day.is-today { border-color: var(--c-accent); font-weight: 600; }
.day.is-selected { background: var(--c-primary); color: var(--c-text-invert); font-weight: 600; }
.day.is-selected:hover { background: var(--c-primary-hover); }
.day__dot {
  position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%;
  background: var(--c-secondary);
}
.day.is-selected .day__dot { background: var(--c-text-invert); }
.day.is-disabled .day__dot { display: none; }

.calendar__legend {
  display: flex; flex-wrap: wrap; gap: var(--s-3);
  margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px solid var(--c-border);
  font-size: .75rem; color: var(--c-text-muted);
}
.calendar__legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }

/* ช่องเวลา */
.slots__group + .slots__group { margin-top: var(--s-5); }
.slots__label {
  font-family: var(--font-head); font-size: .9375rem; font-weight: 600;
  color: var(--c-text); margin-bottom: var(--s-3);
}
.slots__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--s-2); }
.slot {
  min-height: 46px; padding: var(--s-2) var(--s-2);
  background: var(--c-surface); border: 1px solid var(--c-border-strong);
  border-radius: var(--r-md); color: var(--c-text);
  font-family: var(--font-num); font-size: .9375rem; font-weight: 500; cursor: pointer;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.slot:hover:not(:disabled) { border-color: var(--c-primary); background: var(--c-primary-soft); }
.slot[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-text-invert); }
.slot:disabled { opacity: .35; cursor: not-allowed; text-decoration: line-through; background: var(--c-bg-alt); }

/* สรุปการจอง (sticky บน desktop) */
.summary { background: var(--c-bg-alt); border: 1px solid var(--c-border); border-radius: var(--r-lg); padding: var(--s-5); }
@media (min-width: 900px) { .summary--sticky { position: sticky; top: calc(var(--header-h) + 16px); } }
.summary dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-4); }
.summary dt { font-size: .875rem; color: var(--c-text-muted); }
.summary dd { margin: 0; font-size: .9375rem; color: var(--c-text); font-weight: 500; text-align: right; }
.summary__total {
  margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--c-border-strong);
  display: flex; align-items: baseline; justify-content: space-between;
}

/* --------------------------------------------------------------------------
   13. หน้ายืนยัน
   -------------------------------------------------------------------------- */
.confirm-hero { text-align: center; padding-block: var(--s-7) var(--s-5); }
.confirm-icon {
  width: 72px; height: 72px; margin: 0 auto var(--s-5);
  border-radius: 50%; background: var(--c-success-soft); color: var(--c-success);
  display: flex; align-items: center; justify-content: center;
}
.code-box {
  text-align: center; background: var(--c-primary-soft);
  border: 1px dashed var(--c-primary); border-radius: var(--r-lg);
  padding: var(--s-5); margin-block: var(--s-5);
}
.code-box__label { font-size: .875rem; color: var(--c-text-muted); margin-bottom: var(--s-1); }
.code-box__value {
  font-family: var(--font-num); font-size: 2rem; font-weight: 600;
  letter-spacing: .06em; color: var(--c-primary); line-height: 1.3;
}
.copy-area {
  width: 100%; font-family: var(--font-body); font-size: .9375rem; line-height: 1.8;
  background: var(--c-bg-alt); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: var(--s-4); min-height: 190px; color: var(--c-text-body);
}
.toast {
  position: fixed; left: 50%; bottom: calc(var(--stickybar-h) + 16px); transform: translateX(-50%);
  background: var(--c-primary); color: var(--c-text-invert);
  padding: var(--s-3) var(--s-5); border-radius: var(--r-pill); box-shadow: var(--sh-3);
  font-size: .9375rem; z-index: 300; opacity: 0; pointer-events: none;
  transition: opacity .3s var(--ease);
}
.toast.is-visible { opacity: 1; }

/* --------------------------------------------------------------------------
   14. ตารางแอดมิน
   -------------------------------------------------------------------------- */
.toolbar { display: grid; gap: var(--s-3); margin-bottom: var(--s-5); }
@media (min-width: 768px) { .toolbar { grid-template-columns: repeat(4, 1fr); align-items: end; } }
.toolbar .field { margin-bottom: 0; }

.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s-3); margin-bottom: var(--s-5); }
@media (min-width: 768px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--r-md); padding: var(--s-4);
}
.stat__num { font-family: var(--font-num); font-size: 1.5rem; font-weight: 600; color: var(--c-primary); line-height: 1.2; }
.stat__label { font-size: .8125rem; color: var(--c-text-muted); }

.table-wrap {
  overflow-x: auto; border: 1px solid var(--c-border);
  border-radius: var(--r-lg); background: var(--c-surface);
}
table.data { width: 100%; border-collapse: collapse; font-size: .9375rem; min-width: 860px; }
table.data caption { text-align: left; padding: var(--s-4); font-size: .875rem; color: var(--c-text-muted); }
table.data th, table.data td { padding: var(--s-3) var(--s-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--c-border); }
table.data thead th {
  background: var(--c-bg-alt); font-family: var(--font-head); font-weight: 600;
  font-size: .875rem; color: var(--c-text); white-space: nowrap; position: sticky; top: 0;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--c-bg); }
table.data td.num { font-family: var(--font-num); white-space: nowrap; }
table.data select { min-height: 38px; padding: var(--s-1) var(--s-4) var(--s-1) var(--s-3); font-size: .875rem; }
.row-cancelled td { opacity: .55; }
.row-cancelled .cell-main { text-decoration: line-through; }

/* --------------------------------------------------------------------------
   15. Sticky CTA bar มือถือ + Footer
   -------------------------------------------------------------------------- */
.sticky-cta {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  display: flex; border-top: 1px solid var(--c-border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--c-surface);
}
@media (min-width: 768px) { .sticky-cta { display: none; } }
.sticky-cta a {
  flex: 1; min-height: var(--stickybar-h);
  display: flex; align-items: center; justify-content: center; gap: var(--s-2);
  font-family: var(--font-head); font-weight: 600; font-size: .9375rem;
  text-decoration: none; color: var(--c-text-invert);
}
.sticky-cta .cta-line { background: #06C755; color: #0A2E17; }  /* สีแบรนด์ LINE */
.sticky-cta .cta-call { background: var(--c-primary-surface); color: var(--c-on-primary); }
.sticky-cta .cta-book { background: var(--c-accent); color: var(--c-accent-text); }

.footer { background: var(--c-primary-surface); color: var(--c-on-primary); padding-block: var(--s-7) var(--s-5); }
.footer a { color: var(--c-on-primary); text-decoration: none; }
.footer a:hover { color: var(--c-on-primary); text-decoration: underline; }
.footer h3 { color: var(--c-on-primary); font-size: 1rem; margin-bottom: var(--s-3); }
.footer p, .footer li { color: var(--c-on-primary-dim); font-size: .9375rem; }
.footer__grid { display: grid; gap: var(--s-6); }
@media (min-width: 768px) { .footer__grid { grid-template-columns: 1.4fr 1fr 1.2fr; } }
.footer__list { list-style: none; margin: 0; padding: 0; }
.footer__list li { padding-block: var(--s-1); }
.footer__legal {
  margin-top: var(--s-6); padding-top: var(--s-5);
  border-top: 1px solid var(--c-on-primary-line);
  font-size: .8125rem; line-height: 1.8; color: var(--c-on-primary-dim);
}
.footer__legal strong { color: var(--c-on-primary); }

/* CTA band ท้ายหน้า — พื้นเข้มเสมอ (ห้ามใช้ --c-primary ดูคำเตือนที่ token) */
.cta-band {
  background: var(--c-primary-surface);
  border: 1px solid var(--c-primary-surface);
  border-radius: var(--r-lg);
  padding: var(--s-6);
}
.cta-band h2, .cta-band h3 { color: var(--c-on-primary); }
.cta-band p, .cta-band li { color: var(--c-on-primary-dim); }
.cta-band .btn--outline { border-color: var(--c-on-primary-line); color: var(--c-on-primary); }
.cta-band .btn--outline:hover { border-color: var(--c-on-primary); color: var(--c-on-primary); }

/* --------------------------------------------------------------------------
   16. prefers-reduced-motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important; animation-iteration-count: 1 !important;
    transition-duration: .001ms !important; scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------------------
   17. Print — ให้ลูกค้าพิมพ์ใบยืนยันได้
   -------------------------------------------------------------------------- */
@media print {
  .header, .sticky-cta, .footer, .demo-banner, .no-print { display: none !important; }
  body { padding-bottom: 0; background: #fff; }
  .card, .code-box { box-shadow: none; border-color: #999; }
}
