/* ==========================================================
   Lai Booking — minimal · premium · personal · warm
   Mobile-first. Không dùng font ngoài (nhanh, không phụ thuộc CDN).
   ========================================================== */
:root {
  --bg: #f6f0e6;
  --surface: #fffcf7;
  --surface-2: #faf4ea;
  --ink: #2b211b;
  --muted: #7a6b5f;
  --line: #e6dacb;
  --line-strong: #d6c6b3;
  --accent: #7b1e34;
  --accent-hover: #661728;
  --accent-soft: #f5e6e6;
  --on-accent: #fffaf5;
  --success: #2f6b4f;
  --success-soft: #e3f0e8;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn-soft: #fbf1dc;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.05), 0 6px 20px rgba(60, 40, 20, 0.06);
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Source Serif Pro", Georgia, "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --t: 200ms ease;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header { border-bottom: 1px solid var(--line); background: rgba(246, 240, 230, 0.92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); }
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.brand { font-family: var(--font-serif); font-size: 26px; font-weight: 600; color: var(--ink); text-decoration: none; letter-spacing: -0.02em; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 4px; }
.nav a { color: var(--muted); text-decoration: none; padding: 8px 14px; border-radius: 999px; font-size: 15px; transition: background var(--t), color var(--t); }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- Page ---------- */
.page { padding: 28px 0 56px; }
.page-intro { margin-bottom: 22px; }
.page-intro h1 { font-size: 30px; }
.page-intro p { color: var(--muted); margin-top: 8px; max-width: 52ch; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 0 20px 36px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; font-size: 16px; text-decoration: none;
  transition: background var(--t), border-color var(--t), transform var(--t), opacity var(--t), box-shadow var(--t);
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 14px rgba(123, 30, 52, 0.22); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn .spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 700ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: 12px; margin-top: 24px; flex-direction: column-reverse; }
.actions .btn { width: 100%; }

/* ---------- Card ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

/* ---------- Stepper ---------- */
.stepper { list-style: none; display: flex; margin: 0 0 22px; padding: 0; gap: 6px; counter-reset: s; }
.stepper li { flex: 1; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--muted); }
.stepper li::before { content: ""; height: 4px; border-radius: 4px; background: var(--line); transition: background var(--t); }
.stepper li.done::before { background: var(--accent); opacity: 0.55; }
.stepper li.current::before { background: var(--accent); }
.stepper li.current { color: var(--ink); font-weight: 600; }
.stepper .step-num { display: none; }
@media (max-width: 539px) { .stepper li:not(.current) .step-label { display: none; } .stepper li.current { flex: 2; } }

/* ---------- Step transitions ---------- */
.step { animation: stepIn 240ms ease both; }
@keyframes stepIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.step-title { font-size: 22px; margin-bottom: 4px; }
.step-sub { color: var(--muted); margin-bottom: 18px; font-size: 15px; }

/* ---------- Service cards ---------- */
.service-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.service-card {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  padding: 16px; min-height: 76px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
}
.service-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); }
.service-card .ico { flex: none; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; transition: background var(--t); }
.service-card .ico svg { width: 22px; height: 22px; }
.service-card .name { font-weight: 600; font-size: 16.5px; display: block; }
.service-card .desc { color: var(--muted); font-size: 13.5px; display: block; margin-top: 2px; line-height: 1.4; }
.service-card .tick { margin-left: auto; flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1.5px solid var(--line-strong); display: grid; place-items: center; color: transparent; transition: all var(--t); }
.service-card .tick svg { width: 14px; height: 14px; }
.service-card[aria-checked="true"] { border-color: var(--accent); background: #fdf5f4; box-shadow: 0 0 0 3px rgba(123, 30, 52, 0.08); }
.service-card[aria-checked="true"] .ico { background: var(--accent-soft); }
.service-card[aria-checked="true"] .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ---------- Calendar ---------- */
.time-layout { display: grid; gap: 16px; grid-template-columns: 1fr; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head h3 { font-size: 18px; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; transition: background var(--t); }
.icon-btn:hover:not(:disabled) { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.icon-btn svg { width: 18px; height: 18px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 6px 0; font-weight: 600; }
.cal-day {
  aspect-ratio: 1 / 1; min-height: 40px; border: 1.5px solid transparent; border-radius: 12px; background: transparent;
  font-size: 15px; display: grid; place-items: center; position: relative; transition: background var(--t), border-color var(--t), color var(--t);
}
.cal-day.empty { visibility: hidden; }
.cal-day:disabled { color: #b9ab9c; cursor: not-allowed; text-decoration: none; }
.cal-day.avail { font-weight: 600; background: var(--surface-2); }
.cal-day.avail:hover { border-color: var(--line-strong); }
.cal-day.today::after { content: ""; position: absolute; bottom: 5px; width: 4px; height: 4px; border-radius: 50%; background: var(--accent); }
.cal-day[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.cal-day[aria-pressed="true"].today::after { background: var(--on-accent); }
.cal-loading { color: var(--muted); font-size: 14px; padding: 8px 0; min-height: 28px; }
.slots-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.slots-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 12px; }
.slot-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.slot {
  min-height: 46px; border-radius: 12px; border: 1.5px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 15px;
  transition: background var(--t), border-color var(--t), color var(--t);
}
.slot:hover { border-color: var(--accent); }
.slot[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.empty-state { color: var(--muted); font-size: 14.5px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); padding: 18px; text-align: center; }

/* ---------- Form ---------- */
.field { margin-bottom: 18px; }
.field > label, .field > .label { display: block; font-weight: 600; font-size: 14.5px; margin-bottom: 6px; }
.field .opt { color: var(--muted); font-weight: 400; font-size: 13px; }
.input, .textarea {
  width: 100%; min-height: 50px; padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 12px;
  font-size: 16px; /* >=16px để iOS không zoom */ transition: border-color var(--t), box-shadow var(--t);
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.input:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(123, 30, 52, 0.12); }
.field.invalid .input, .field.invalid .textarea { border-color: var(--danger); }
.help { color: var(--muted); font-size: 13px; margin-top: 6px; }
.error { color: var(--danger); font-size: 13.5px; margin-top: 6px; display: none; }
.field.invalid .error { display: block; }
.counter { text-align: right; color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface); transition: all var(--t); font-size: 15px; }
.chip:hover { border-color: var(--accent); }
.chip[aria-checked="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Confirm ---------- */
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.summary-head { background: var(--accent-soft); padding: 12px 18px; font-size: 12.5px; letter-spacing: 0.08em; font-weight: 700; color: var(--accent); }
.summary-row { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; padding: 14px 18px; border-top: 1px solid var(--line); }
.summary-row:first-of-type { border-top: 0; }
.summary-row .k { color: var(--muted); font-size: 13px; margin-bottom: 2px; }
.summary-row .v { font-weight: 600; word-break: break-word; }
.summary-row .v.plain { font-weight: 400; white-space: pre-wrap; }
.link-btn { background: none; border: 0; color: var(--accent); font-size: 14px; padding: 4px 0; text-decoration: underline; text-underline-offset: 3px; flex: none; }
.banner { border-radius: var(--radius-sm); padding: 12px 14px; font-size: 14.5px; margin-bottom: 16px; border: 1px solid; }
.banner.error-b { background: var(--danger-soft); color: #7a1a13; border-color: #f0c4be; }
.banner.info-b { background: var(--warn-soft); color: #6b4c10; border-color: #ecd9a8; }

/* ---------- Success ---------- */
.success-card { text-align: center; padding: 32px 20px; }
.success-check { width: 72px; height: 72px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: grid; place-items: center; margin: 0 auto 18px; animation: pop 320ms ease both; }
.success-check svg { width: 34px; height: 34px; }
@keyframes pop { from { transform: scale(0.7); opacity: 0; } to { transform: none; opacity: 1; } }
.success-card h1 { font-size: 28px; }
.success-card .lead { color: var(--muted); margin-top: 6px; }
.bk-box { margin: 24px auto 8px; max-width: 420px; background: var(--accent-soft); border: 1px solid #ebcfcf; border-radius: var(--radius); padding: 18px 12px; }
.bk-label { font-size: 12.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.bk-id { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: clamp(22px, 7vw, 32px); font-weight: 700; letter-spacing: 0.04em; color: var(--accent); margin: 6px 0 14px; word-break: break-all; user-select: all; }
.success-meta { margin: 22px auto 0; max-width: 420px; text-align: left; border-top: 1px solid var(--line); }
.success-notes { margin-top: 22px; color: var(--muted); font-size: 14.5px; display: grid; gap: 6px; }
.success-notes .ok { color: var(--success); font-weight: 600; }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: all var(--t); z-index: 50; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Modal (cảnh báo khi rời chat) ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(43, 33, 27, 0.45); display: grid; place-items: center; padding: 20px; z-index: 60; animation: fade 160ms ease both; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 22px; max-width: 420px; width: 100%; box-shadow: 0 20px 50px rgba(43, 33, 27, 0.25); }
.modal h3 { font-size: 20px; margin-bottom: 8px; }
.modal p { color: var(--muted); font-size: 15px; }
.modal .actions { margin-top: 18px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================
   CHAT
   ========================================================== */
body.chat-page { height: var(--app-h, 100dvh); display: flex; flex-direction: column; overflow: hidden; }
.chat-shell { flex: 1; min-height: 0; display: flex; flex-direction: column; width: 100%; max-width: 760px; margin: 0 auto; background: var(--surface); }
.chat-status { display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-size: 13.5px; background: var(--warn-soft); color: #6b4c10; border-bottom: 1px solid #ecd9a8; }
.chat-status.permanent { background: var(--success-soft); color: var(--success); border-color: #c5e0d0; font-weight: 600; }
.chat-status.expired { background: var(--danger-soft); color: #7a1a13; border-color: #f0c4be; }
.chat-status .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; opacity: 0.8; }
.presence { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); font-weight: 400; white-space: nowrap; }
.presence i { width: 8px; height: 8px; border-radius: 50%; background: #b9ab9c; display: inline-block; }
.presence.online i { background: #3a9d6b; }
.messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--surface); overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.msg { display: flex; flex-direction: column; max-width: 82%; animation: msgIn 200ms ease both; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-meta { font-size: 12px; color: var(--muted); margin: 0 6px 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg-meta .auto { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.bubble { padding: 10px 14px; border-radius: 18px; background: var(--surface-2); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere; font-size: 15.5px; line-height: 1.45; }
.msg--mine { align-self: flex-end; align-items: flex-end; }
.msg--mine .bubble { background: var(--accent); color: var(--on-accent); border-color: var(--accent); border-bottom-right-radius: 6px; }
.msg--other { align-self: flex-start; align-items: flex-start; }
.msg--other .bubble { border-bottom-left-radius: 6px; }
.msg--bot .bubble { background: transparent; border-style: dashed; color: var(--muted); }
.msg--system { align-self: center; align-items: center; max-width: 92%; }
.msg--system .bubble { background: var(--surface-2); border: 0; color: var(--muted); font-size: 13.5px; text-align: center; border-radius: 999px; padding: 6px 14px; }
.msg-state { font-size: 11.5px; color: var(--muted); margin: 3px 6px 0; }
.msg-state.failed { color: var(--danger); }
.msg-state button { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 0; font-size: inherit; }
.typing { padding: 0 20px 6px; font-size: 12.5px; color: var(--muted); min-height: 22px; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { flex: 1; min-height: 46px; max-height: 140px; resize: none; padding: 11px 14px; border-radius: 22px; border: 1.5px solid var(--line-strong); background: var(--bg); font-size: 16px; line-height: 1.4; }
.composer textarea:focus { outline: none; border-color: var(--accent); }
.composer .send { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; transition: background var(--t), opacity var(--t); }
.composer .send:hover:not(:disabled) { background: var(--accent-hover); }
.composer .send:disabled { opacity: 0.45; cursor: not-allowed; }
.composer .send svg { width: 20px; height: 20px; }
.chat-start { padding: 24px 20px; max-width: 460px; margin: 0 auto; width: 100%; }
.chat-start h1 { font-size: 26px; margin-bottom: 6px; }
.chat-start p.lead { color: var(--muted); margin-bottom: 20px; }
.chat-note { color: var(--muted); font-size: 13px; margin-top: 14px; }

/* ==========================================================
   Responsive
   ========================================================== */
@media (min-width: 540px) {
  .slot-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 720px) {
  .wrap { padding: 0 28px; }
  .page { padding: 44px 0 72px; }
  .page-intro h1 { font-size: 38px; }
  .card { padding: 28px; }
  .service-grid { grid-template-columns: 1fr 1fr; }
  .time-layout { grid-template-columns: 1.15fr 1fr; gap: 28px; align-items: start; }
  .slot-grid { grid-template-columns: repeat(2, 1fr); }
  .actions { flex-direction: row; justify-content: flex-end; }
  .actions .btn { width: auto; min-width: 150px; }
  .actions .btn-ghost { margin-right: auto; }
  .chat-shell { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .messages { padding: 20px 24px; }
  .msg { max-width: 72%; }
}
@media (min-width: 1000px) { .wrap { max-width: 920px; } .slot-grid { grid-template-columns: repeat(3, 1fr); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

/* ---------- bổ sung ---------- */
.chat-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.step-title:focus, .page h1:focus { outline: none; }
