﻿/* ==========================================================
   TarardProp - COMPONENTS - buttons, forms, cards, tables, sidebar
   Reusable UI building blocks
   ========================================================== */

/* ---------- กล่องข้อมูลติดต่อ (ซ่อน/แสดงเบอร์) ---------- */
.contact-box { display: flex; flex-direction: column; gap: .45rem; }
.contact-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .45rem .55rem; border: 1px solid var(--line); border-radius: .6rem;
  background: var(--surface-2); }
.contact-ico { width: 1.15rem; text-align: center; flex-shrink: 0; }
.contact-label { font-size: .8rem; color: var(--muted); flex-shrink: 0; }
.contact-value { font-weight: 600; font-size: .9rem; letter-spacing: .02em; word-break: break-all; }
.contact-value a { color: var(--brand-text); }
.contact-value a:hover { text-decoration: underline; }
.contact-reveal { margin-left: auto; display: inline-flex; align-items: center; gap: .25rem;
  padding: .2rem .55rem; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: .72rem; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: .15s; white-space: nowrap; }
.contact-reveal:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-text); background: var(--brand-light); }
.contact-reveal:disabled { opacity: .6; cursor: wait; }

/* ---------- เมนูเลือกแพ็กเกจ (หน้าแดชบอร์ด) ---------- */
.pkg-menu { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.pkg-menu-item { display: flex; align-items: center; gap: .7rem; padding: .8rem .9rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: .8rem; transition: .15s; }
.pkg-menu-item:hover { border-color: var(--brand); box-shadow: 0 6px 16px rgba(15,23,42,.07); transform: translateY(-1px); }
.pkg-menu-ico { width: 2.3rem; height: 2.3rem; border-radius: .6rem; flex-shrink: 0;
  display: grid; place-items: center; background: var(--brand-light); color: var(--brand); }
.pkg-menu-ico.vip { background: #fef3c7; color: #b45309; }
.pkg-menu-txt { display: flex; flex-direction: column; min-width: 0; }
.pkg-menu-txt b { font-size: .92rem; }
.pkg-menu-txt small { font-size: .76rem; color: var(--muted); }
.pkg-menu-arrow { margin-left: auto; color: var(--muted); font-size: .72rem; flex-shrink: 0; }

/* ---------- การ์ดแพ็กเกจ (โฆษณา / VIP) ---------- */
.pkg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.pkg-card { position: relative; display: flex; flex-direction: column; gap: .6rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: .9rem;
  padding: 1.1rem; transition: .15s; }
.pkg-card:hover { border-color: var(--brand); box-shadow: 0 8px 20px rgba(15,23,42,.08); transform: translateY(-2px); }
.pkg-card.best { border-color: var(--brand); box-shadow: 0 6px 18px rgba(5,150,105,.18); }
.pkg-flag { position: absolute; top: -.6rem; left: 1rem; padding: .1rem .55rem; border-radius: 999px;
  background: var(--brand); color: var(--on-brand); font-size: .68rem; font-weight: 700; }
.pkg-name { font-weight: 600; font-size: .95rem; }
.pkg-price { font-size: 1.7rem; font-weight: 700; color: var(--brand-text); line-height: 1.1; }
.pkg-price small { font-size: .85rem; font-weight: 500; color: var(--muted); }
.pkg-feats { list-style: none; margin: 0; padding: 0; flex: 1;
  font-size: .84rem; color: var(--muted); display: flex; flex-direction: column; gap: .3rem; }
.pkg-feats i { color: var(--brand); margin-right: .35rem; }
.pkg-status { display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; }
.pkg-status.st-pending   { background: #fef3c7; color: #b45309; }
.pkg-status.st-paid      { background: #d1fae5; color: #047857; }
.pkg-status.st-cancelled { background: var(--surface-2); color: var(--muted); }

/* ---------- ปุ่มแชทลอย (FAB) ---------- */
.ai-fab {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 90;
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand); color: #fff; font-size: 1.45rem;
  display: grid; place-items: center;
  box-shadow: 0 10px 24px rgba(5,150,105,.38), 0 0 0 6px rgba(5,150,105,.14);
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.ai-fab:hover  { transform: scale(1.07); box-shadow: 0 14px 30px rgba(5,150,105,.46), 0 0 0 8px rgba(5,150,105,.18); }
.ai-fab:active { transform: scale(.96); }
.ai-fab:focus-visible { outline: 3px solid var(--brand-dark); outline-offset: 3px; }
.ai-fab.is-hidden { opacity: 0; visibility: hidden; transform: scale(.7); pointer-events: none; }

/* ---------- หน้าต่างแชทลอย ---------- */
.ai-panel {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 95;
  width: min(370px, calc(100vw - 2.2rem));
  height: min(560px, calc(100vh - 5.5rem));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 1rem; box-shadow: 0 18px 50px rgba(15,23,42,.22);
  opacity: 0; transform: translateY(14px) scale(.97);
  transition: opacity .2s, transform .2s;
}
.ai-panel.is-open { opacity: 1; transform: translateY(0) scale(1); }
.ai-panel[hidden] { display: none; }

.ai-panel-head { display: flex; align-items: center; gap: .55rem; padding: .7rem .85rem;
  background: var(--brand); color: #fff; flex-shrink: 0; }
.ai-panel-ico { width: 2.1rem; height: 2.1rem; border-radius: 50%; background: rgba(255,255,255,.2);
  display: grid; place-items: center; font-size: .95rem; flex-shrink: 0; }
.ai-panel-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ai-panel-txt b    { font-size: .9rem; line-height: 1.3; }
.ai-panel-txt small { font-size: .7rem; opacity: .88; }
.ai-panel-close, .ai-panel-clear {
  width: 30px; height: 30px; border-radius: 8px; border: 0; cursor: pointer; flex-shrink: 0;
  background: rgba(255,255,255,.16); color: #fff; font-size: .78rem; transition: .15s;
}
.ai-panel-clear { margin-right: .2rem; }
.ai-panel-close:hover, .ai-panel-clear:hover { background: rgba(255,255,255,.32); }
.ai-panel-close:focus-visible, .ai-panel-clear:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.ai-panel .ai-log { padding: .9rem; gap: .65rem; }
.ai-panel .ai-bubble  { font-size: .86rem; padding: .6rem .8rem; }
.ai-panel .ai-msg    { max-width: 92%; }
.ai-panel .ai-time   { font-size: .62rem; }
.ai-panel .ai-sample { font-size: .74rem; }
.ai-panel .ai-form   { padding: 0 .9rem; }
.ai-panel .ai-hint   { display: none; }

/* ---------- ผู้ช่วย AI: หน้าแชท ---------- */
.ai-page { padding: 1.2rem 1rem 2.5rem; }
.ai-page .page-head { margin-bottom: 1rem; }

.ai-chat { display: flex; flex-direction: column; height: min(72vh, 720px); overflow: hidden; }
.ai-log { flex: 1; overflow-y: auto; padding: 1.1rem; display: flex; flex-direction: column; gap: .8rem; }

.ai-msg { max-width: min(88%, 640px); display: flex; flex-direction: column; gap: .2rem; }
.ai-msg.bot  { align-self: flex-start; }
.ai-msg.user { align-self: flex-end; align-items: flex-end; }

.ai-bubble { padding: .7rem .95rem; border-radius: 1rem; line-height: 1.65; font-size: .92rem; word-break: break-word; }
.ai-msg.bot  .ai-bubble { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: .3rem; }
.ai-msg.user .ai-bubble { background: var(--brand); color: var(--on-brand); border-bottom-right-radius: .3rem; }
.ai-time { font-size: .66rem; color: var(--muted); padding: 0 .2rem; }

.ai-note { display: flex; align-items: center; gap: .4rem; font-size: .78rem; color: #b45309;
  background: #fef3c7; border-radius: .5rem; padding: .35rem .6rem; margin-bottom: .45rem; }

.ai-typing { display: flex; gap: .25rem; align-items: center; padding: .85rem 1rem; }
.ai-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: aiBlink 1.2s infinite; }
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%,60%,100% { opacity:.3; transform:translateY(0) } 30% { opacity:1; transform:translateY(-3px) } }

/* การ์ดประกาศที่ค้นเจอ */
.ai-results { display: grid; gap: .4rem; margin-top: .55rem; }
.ai-result { display: flex; flex-direction: column; gap: .12rem; padding: .55rem .7rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: .65rem; text-decoration: none; color: inherit; transition: .15s; }
.ai-result:hover { border-color: var(--brand); transform: translateX(2px); }
.ai-result b { font-size: .86rem; color: var(--brand-text); }
.ai-result span { font-size: .74rem; color: var(--muted); }
.ai-result strong { font-size: .92rem; color: var(--brand); }
.ai-result small { font-size: .72rem; color: var(--muted); }
.ai-result em { font-size: .72rem; color: var(--brand); font-style: normal; margin-top: .15rem; }

/* ช่องพิมพ์ */
.ai-samples { display: flex; gap: .4rem; padding: 0 1.1rem .7rem; overflow-x: auto; flex-shrink: 0; }
.ai-sample { white-space: nowrap; font-size: .78rem; padding: .32rem .7rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  cursor: pointer; font-family: inherit; transition: .15s; }
.ai-sample:hover { border-color: var(--brand); color: var(--brand-text); }

.ai-form { display: flex; gap: .5rem; align-items: flex-end; padding: 0 1.1rem; flex-shrink: 0; }
.ai-form textarea { flex: 1; resize: none; max-height: 140px; min-height: 46px; padding: .7rem .9rem;
  border: 1px solid var(--line); border-radius: 1.1rem; font-family: inherit; font-size: .92rem;
  background: var(--surface-2); color: inherit; outline: none; transition: .15s; line-height: 1.5; }
.ai-form textarea:focus { border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px rgba(5,150,105,.12); }
.ai-form button { width: 46px; height: 46px; border-radius: 50%; border: 0; flex-shrink: 0;
  background: var(--brand); color: var(--on-brand); font-size: 1rem; cursor: pointer; transition: .15s; }
.ai-form button:hover:not(:disabled) { background: var(--brand-dark); transform: scale(1.05); }
.ai-form button:disabled { opacity: .5; cursor: not-allowed; }
.ai-hint { text-align: center; font-size: .7rem; color: var(--muted); padding: .5rem 1.1rem .9rem; flex-shrink: 0; }

/* ---------- กล่องคำอธิบาย ---------- */
.ai-hint-box { display: flex; gap: .5rem; align-items: flex-start; margin-top: .8rem; padding: .6rem .8rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: .6rem;
  font-size: .78rem; color: var(--muted); line-height: 1.7; }
.ai-hint-box i { color: var(--brand); margin-top: .15rem; flex-shrink: 0; }
.ai-hint-box b { color: var(--ink); }
.ai-hint-box a { color: var(--brand-text); }

/* ---------- สวิตช์เปิด/ปิดระบบ AI ---------- */
.ai-switch-grid { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .9rem; }
.ai-switch { display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: .7rem; transition: .15s; }
.ai-switch:hover { border-color: var(--brand); }
.ai-switch input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); flex-shrink: 0; cursor: pointer; }
.ai-switch-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ai-switch-txt b    { font-size: .88rem; }
.ai-switch-txt small { font-size: .76rem; color: var(--muted); }
.ai-pill { flex-shrink: 0; font-size: .7rem; font-weight: 600; padding: .12rem .6rem; border-radius: 999px; }
.ai-pill.on  { background: #d1fae5; color: #047857; }
.ai-pill.off { background: #fee2e2; color: #b91c1c; }

/* ---------- หน้าวิเคราะห์และพัฒนา AI ---------- */
.ai-toggle-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .6rem; margin-bottom: .9rem; }
.ai-toggle { display: flex; align-items: flex-start; gap: .6rem; padding: .7rem .8rem; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: .7rem; transition: .15s; }
.ai-toggle:hover { border-color: var(--brand); }
.ai-toggle input { margin-top: .2rem; accent-color: var(--brand); flex-shrink: 0; }
.ai-toggle-txt { display: flex; flex-direction: column; }
.ai-toggle-txt b { font-size: .88rem; }
.ai-toggle-txt small { font-size: .76rem; color: var(--muted); }

.ai-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; margin-bottom: .9rem; }

.ai-test-out { margin-top: .9rem; }
.ai-test-ok   { color: #047857; font-size: .85rem; margin-bottom: .5rem; }
.ai-test-err  { color: #b91c1c; font-size: .85rem; background: #fee2e2; padding: .7rem .9rem; border-radius: .6rem; }
.ai-test-text { background: var(--surface-2); border: 1px solid var(--line); border-radius: .7rem;
  padding: .8rem 1rem; font-size: .88rem; line-height: 1.7; white-space: pre-wrap; }

.ai-quickadd { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.ai-quickadd .input { flex: 1; min-width: 220px; }
.ai-run-btns { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.ai-muted-note { color: var(--muted); font-size: .83rem; }

.ai-count-pill { font-size: .74rem; color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 999px; padding: .1rem .6rem; }

.ai-addsyn { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .9rem; }
.ai-addsyn .input { flex: 1; min-width: 160px; }
.ai-arrow { color: var(--muted); font-size: .8rem; }

.ai-syn-list { display: flex; flex-direction: column; gap: .4rem; }
.ai-syn { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; padding: .5rem .65rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: .6rem; font-size: .85rem; }
.ai-syn.off { opacity: .5; }
.ai-syn-from { font-weight: 600; }
.ai-syn-to   { color: var(--brand-text); font-weight: 600; }
.ai-syn-meta { color: var(--muted); font-size: .75rem; margin-left: auto; }
.ai-syn-off  { color: var(--muted); font-size: .75rem; margin-left: auto; }

.ai-inline-form { display: inline; }
.ai-chip-btn { border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: .12rem .55rem; font-size: .72rem; cursor: pointer; transition: .15s; }
.ai-chip-btn:hover { color: #b91c1c; border-color: #b91c1c; }
.ai-chip-btn.ok:hover { color: #047857; border-color: #047857; }

.ai-topq { display: flex; flex-direction: column; gap: .4rem; }
.ai-topq-row { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap;
  padding: .45rem .6rem; background: var(--surface-2); border-radius: .6rem; font-size: .85rem; }
.ai-topq-meta { color: var(--muted); font-size: .74rem; margin-left: auto; }

.ai-gap-list { display: flex; flex-direction: column; gap: .45rem; }
.ai-gap { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .55rem .7rem;
  background: var(--surface-2); border-left: 3px solid #b45309; border-radius: .5rem; font-size: .85rem; }
.ai-gap-kw   { font-weight: 600; }
.ai-gap-area { color: var(--muted); font-size: .78rem; }
.ai-gap-meta { color: var(--muted); font-size: .74rem; }
.ai-gap-actions { margin-left: auto; display: flex; gap: .35rem; }

.ai-run-list { display: flex; flex-direction: column; gap: .6rem; }
.ai-run { padding: .6rem .75rem; background: var(--surface-2); border-radius: .6rem; }
.ai-run-top { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.ai-run-mode { font-weight: 600; font-size: .84rem; }
.ai-run-meta { color: var(--muted); font-size: .74rem; margin-left: auto; }
.ai-run-msg { font-size: .82rem; color: var(--muted); margin-top: .35rem; line-height: 1.6; }

/* ปุ่ม/ช่องกรอกเป็น form control ที่เบราว์เซอร์ไม่สืบทศัพท์จาก body
   ถ้าไม่กำหนด font-family: inherit ข้อความจะเป็นฟอนต์เริ่มต้นของเบราว์เซอร์
   ทำให้หน้าตากับทั่วไปของเว็บไม่เหมือนกัน */
button, select, textarea, .chip, .nav-link, .ai-sample, .ai-fab, .theme-toggle, .side-link {
  font-family: inherit;
}

/* ---------- ปุ่ม ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
       padding: .6rem 1rem; border-radius: .5rem; border: 1px solid transparent;
       /* ปุ่มเป็น form control ที่เบราว์เซอร์ไม่สืบทศัพท์จาก body ให้
          ต้องกำหนดเอง ไม่งั้นข้อความในปุ่ม (เช่น "สมัครสมาชิก") จะเป็นฟอนต์เริ่มต้น
          ของเบราว์เซอร์ ไม่ตรงกับหัวข้อและเนื้อความส่วนอื่นของระบบ */
       font-family: inherit;
       font-size: .9rem; font-weight: 500; cursor: pointer; transition: .15s; white-space: nowrap; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-gold { background: #f59e0b; color: var(--on-brand); }
.btn-gold:hover { background: #d97706; }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- หน้าเข้าสู่ระบบ / สมัครสมาชิก ---------- */
.auth-wrap { max-width: 460px; margin: 2.5rem auto; padding: 0 1rem; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 1rem; padding: 2rem; }
.auth-card h1 { font-size: 1.4rem; margin: 0 0 .3rem; }
.auth-alt { text-align: center; font-size: .88rem; color: var(--muted); margin-top: 1.2rem; }
.auth-alt a { color: var(--brand); font-weight: 500; }
.auth-err { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: .6rem .8rem; border-radius: .5rem; font-size: .85rem; margin-bottom: 1rem; }

/* ---------- ช่องอัปโหลดรูป ---------- */
.upload-zone { border: 2px dashed var(--line); border-radius: .8rem; padding: 1.5rem;
  text-align: center; cursor: pointer; transition: .15s; background: var(--bg); }
.upload-zone:hover, .upload-zone.drag { border-color: var(--brand); background: var(--brand-light); }
.upload-zone i { font-size: 1.8rem; color: var(--brand); margin-bottom: .4rem; }
.preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .6rem; margin-top: .8rem; }
.preview-grid figure { position: relative; aspect-ratio: 1; border-radius: .5rem; overflow: hidden; }
.preview-grid img { width: 100%; height: 100%; object-fit: cover; }
.preview-grid button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px;
  border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; border: 0; cursor: pointer;
  font-size: .7rem; display: grid; place-items: center; }


/* ---------- การ์ด / ฟอร์ม ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: .75rem; padding: 1.25rem; }
.label { display: block; font-size: .82rem; font-weight: 500; color: var(--muted); margin-bottom: .3rem; }
.input, select.input, textarea.input { width: 100%; padding: .55rem .7rem; border: 1px solid var(--line);
  border-radius: .55rem; font-size: .9rem; font-family: inherit; background: var(--surface); transition: .15s; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(13,148,136,.12); }
textarea.input { resize: vertical; min-height: 90px; }
.form-row { margin-bottom: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 .9rem; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
/* 3 คอลัมน์ (ช่องกรอก 2 + ปุ่ม) — ใช้กับแบบประเมินราคา */
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr auto; gap: 0 .9rem; align-items: end; }
@media (max-width: 640px) { .form-grid-3 { grid-template-columns: 1fr; } }
/* ย่อ/ซ่อนองค์ประกอบด้วย JS */
.hidden { display: none; }

/* ---------- สีช่วยเหลือ ---------- */
.bg-slate-50 { background: var(--bg); } .bg-slate-100 { background: var(--surface-2); }
.bg-slate-200 { background: var(--surface-2); }
.bg-brand-50, .bg-land-50 { background: var(--brand-light); }
.bg-emerald-100 { background: #d1fae5; } .text-emerald-700 { color: #047857; }
.bg-amber-100 { background: #fef3c7; }   .text-amber-700 { color: #b45309; }
.bg-sky-100 { background: #e0f2fe; }     .text-sky-700 { color: #0369a1; }
.bg-rose-100 { background: #ffe4e6; }    .text-rose-700 { color: #be123c; }



/* ---------- stats ---------- */
/* ---------- สถิติ ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: .8rem; padding: 1rem; text-align: center; }
.stat b { display: block; font-size: 1.6rem; color: var(--brand-dark); }
.stat span { font-size: .8rem; color: var(--muted); }

/* ---------- ตาราง ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.table th, .table td { padding: .6rem .7rem; border-bottom: 1px solid var(--line); text-align: left; }
.table th { background: var(--bg); color: var(--muted); font-weight: 500; font-size: .82rem; }
.table tr:hover td { background: var(--bg); }
.table-scroll { overflow-x: auto; }

/* ---------- เบรดครัมบ์ / แจ้งเตือน ---------- */
.breadcrumb { font-size: .82rem; color: var(--muted); padding: .9rem 0; }
.breadcrumb a:hover { text-decoration: underline; }
.alert { padding: .8rem 1rem; border-radius: .6rem; font-size: .88rem; margin-bottom: 1rem; border: 1px solid; }
.alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.alert-error   { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.5rem; margin-bottom: .75rem; opacity: .35; }

/* ---------- เมนูด้านข้าง ---------- */
.side-card { background: var(--surface); border: 1px solid var(--line); border-radius: .9rem; padding: .75rem; }
.side-link { display: flex; align-items: center; gap: .6rem; padding: .55rem .75rem;
  border-radius: .6rem; font-size: .88rem; color: var(--muted); transition: .15s; }
.side-link:hover { background: var(--surface-2); }
.side-link.on { background: var(--brand); color: #fff; font-weight: 500; }

/* ---------- หน้ารายละเอียด ---------- */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.gallery-main { aspect-ratio: 16/10; background: var(--surface-2); border-radius: .9rem; overflow: hidden; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: .5rem; margin-top: .6rem; overflow-x: auto; padding-bottom: .25rem; }
.gallery-thumbs img { width: 84px; height: 64px; object-fit: cover; border-radius: .5rem;
  border: 2px solid transparent; cursor: pointer; flex-shrink: 0; }
.gallery-thumbs img.on { border-color: var(--brand); }
.spec-table td { padding: .45rem 0; border-bottom: 1px dashed var(--line); }
.spec-table td:first-child { color: var(--muted); width: 40%; }

.prop-specs span { display: inline-flex; align-items: center; gap: .25rem; }
.prop-foot { margin-top: auto; padding-top: .5rem; font-size: .72rem; color: var(--muted); border-top: 1px solid var(--line); }

/* ---------- ตัวกรอง ---------- */
.filter-bar { background: var(--surface); border: 1px solid var(--line); border-radius: .9rem; padding: 1rem; }
.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip { padding: .35rem .8rem; border-radius: 999px; border: 1px solid var(--line);
  font-size: .82rem; background: var(--surface); color: var(--muted); transition: .15s; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 500; }

/* ============================================================
   หลังบ้าน (admin) — เลย์เอาต์ เมนูด้านซ้าย + การ์ดสรุป + กราฟ
   ============================================================ */
.ap-layout { display: grid; grid-template-columns: 260px 1fr; gap: 1.5rem; align-items: start; }
@media (max-width: 900px) { .ap-layout { grid-template-columns: 1fr; } }

.admin-sidebar { width: 100%; }
@media (min-width: 901px) { .admin-sidebar { position: sticky; top: 84px; } }
.admin-sidebar-box { background: var(--surface); border: 1px solid var(--line); border-radius: .9rem; padding: .6rem; }
.admin-sidebar nav { list-style: none; margin: 0; padding: 0; }

/* หัวข้อกลุ่มที่ย่อ/ขยายได้ */
.adm-grp { display: flex; align-items: center; gap: .5rem; width: 100%;
  padding: .5rem .75rem; border: 0; background: none; cursor: pointer; border-radius: .6rem; }
.adm-grp:hover { background: var(--bg); }
.adm-grp-label { flex: 1; text-align: left; font-size: .7rem; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.adm-grp-dots { color: #cbd5e1; font-weight: 700; letter-spacing: 1px; line-height: 1; }

/* รายการเมนู (ใช้ร่วมกับ .side-link เดิม) */
.side-txt { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.side-lbl  { font-size: .9rem; }
.side-desc { font-size: .7rem; color: var(--muted); }
.side-link.on .side-desc { color: rgba(255,255,255,.75); }
.side-badge { flex-shrink: 0; min-width: 1.4rem; text-align: center; padding: .05rem .4rem;
  border-radius: 999px; font-size: .7rem; font-weight: 700; background: #fef3c7; color: #b45309; }
.side-link.on .side-badge { background: rgba(255,255,255,.25); color: var(--on-brand); }
.side-foot { border-top: 1px solid var(--line); margin-top: .5rem; padding-top: .5rem; }

/* การ์ดสรุปตัวเลขแบบคลิกได้ */
.kpi { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: .8rem;
  padding: .9rem 1rem; transition: .15s; }
.kpi:hover { border-color: var(--brand); box-shadow: 0 6px 16px rgba(15,23,42,.08); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.kpi-label { font-size: .8rem; color: var(--muted); }
.kpi-icon { width: 2.1rem; height: 2.1rem; border-radius: .6rem; display: grid; place-items: center;
  font-size: .9rem; background: var(--brand-light); color: var(--brand); flex-shrink: 0; }
.kpi-val { font-size: 1.7rem; font-weight: 700; margin-top: .35rem; line-height: 1.1; }
.kpi-val.sm { font-size: 1.15rem; }
.kpi-foot { font-size: .72rem; color: var(--muted); margin-top: .2rem; }

/* แถบกราฟแท่งแนวนอน */
.bar-row { display: grid; grid-template-columns: 110px 1fr 54px; align-items: center; gap: .6rem; margin-bottom: .5rem; }
.bar-track { background: var(--surface-2); border-radius: 999px; height: .6rem; overflow: hidden; }
.bar-fill  { background: var(--brand); height: 100%; border-radius: 999px; }
.bar-fill.alt { background: #6366f1; }
.bar-val { font-size: .78rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ตารางที่มีรูปตัวอย่าง */
.thumb-xs { width: 54px; height: 40px; border-radius: .4rem; object-fit: cover; background: var(--surface-2); flex-shrink: 0; }
.row-acts { display: flex; gap: .25rem; justify-content: flex-end; flex-wrap: wrap; }

/* ป้ายสถานะคำขอรับซื้อ */
.st-new       { background: #fef3c7; color: #b45309; }
.st-contacted { background: #dbeafe; color: #1d4ed8; }
.st-closed    { background: var(--surface-2); color: var(--muted); }

/* หัวข้อหน้า (ชื่อ + คำอธิบาย + ปุ่มด้านขวา) */
.page-head { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.4rem; font-weight: 700; margin: 0 0 .2rem; }
.page-head p  { color: var(--muted); font-size: .9rem; margin: 0; }

/* ช่องว่างในตาราง */
.table td, .table th { white-space: nowrap; }
.table td.wrap-cell { white-space: normal; }


/* theme-aware form fields */
/* ช่องกรอกข้อมูลให้เข้ากับธีม */
.input, select.input, textarea.input { background: var(--field); color: var(--ink); }
select.input option { background: var(--field); color: var(--ink); }
