/* ==========================================================================
   TSPI Clinic — หน้าเว็บสาธารณะ (โหลดหลัง bootstrap.min.css และ theme.css)
   แนวทาง: พื้นขาวสะอาด สีเขียวสีเดียว ตัวหนังสือ 18px เว้นที่กว้าง ปุ่มหลักไม่เกิน 2 ปุ่มต่อส่วน
   ========================================================================== */

:root {
    --site-sage: #F3F7F2;          /* พื้นส่วนสลับ */
    --site-sage-2: #E6F0E4;
    --site-ink-2: #334155;
    --site-maxw-text: 68ch;
    --bs-body-font-size: 1.125rem;  /* 18px อ่านง่ายสำหรับผู้สูงอายุ */
    --bs-body-bg: #FFFFFF;
}
body { display: flex; flex-direction: column; min-height: 100vh; overflow-x: hidden; background: #fff; }
main { flex: 1 0 auto; }
::selection { background: var(--tspi-green-100); }

/* ---------- คลาสเดิมที่หน้าอื่นยังใช้ ---------- */
.text-primary-clinic { color: var(--tspi-green-700) !important; }
.bg-primary-clinic { background-color: var(--tspi-green-600) !important; }
.badge-subtle-primary { display: inline-block; background: var(--tspi-green-50); color: var(--tspi-green-700); border: 1px solid var(--site-sage-2);
    font-weight: 600; font-size: .95rem; padding: .35rem .9rem; border-radius: 999px; }
.card-hover { transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease; }
.card-hover:hover { transform: translateY(-3px); box-shadow: 0 14px 32px rgba(15, 23, 42, .08); border-color: #BBD7B8; }
.max-w-700 { max-width: 700px; }

/* ---------- ส่วนหัว (Navbar + Offcanvas) ---------- */
/* ห้ามใส่ backdrop-filter: ทำให้ offcanvas (position: fixed) ถูกจำกัดอยู่ในแถบเมนู */
.site-nav { background: #fff; border-bottom: 1px solid var(--tspi-line); }
.site-nav .navbar-brand { font-weight: 700; color: var(--tspi-ink); }
.site-nav .btn { white-space: nowrap; }
.site-logo { width: 42px; height: 42px; border-radius: 12px; background: var(--tspi-green-600); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.site-nav .nav-link { font-weight: 600; color: var(--site-ink-2); font-size: 1.05rem; padding: .55rem .9rem !important; border-radius: 10px; }
.site-nav .nav-link:hover, .site-nav .nav-link:focus { color: var(--tspi-green-700); background: var(--tspi-green-50); }
.site-nav .nav-link.active { color: var(--tspi-green-700); background: var(--tspi-green-50); }
.site-nav .dropdown-menu { border-radius: 16px; border: 1px solid var(--tspi-line); box-shadow: var(--tspi-shadow); padding: .5rem; min-width: 300px; }
.site-nav .dropdown-item { border-radius: 10px; padding: .65rem .8rem; white-space: normal; }
.site-nav .dropdown-item:hover { background: var(--tspi-green-50); }
.site-nav .dropdown-item small { display: block; color: var(--tspi-muted); font-size: .9rem; }

@media (max-width: 991.98px) {
    .site-nav .offcanvas { max-width: 340px; }
    .site-nav .nav-link { font-size: 1.2rem; padding: .9rem 1rem !important; }
    .site-nav .dropdown-menu { box-shadow: none; border: 0; padding: 0 0 0 .75rem; }
}

/* ---------- ส่วนเนื้อหา ---------- */
.site-section { padding: 5rem 0; }
.site-section.alt { background: var(--site-sage); }
.site-eyebrow { color: var(--tspi-green-700); font-weight: 700; letter-spacing: .02em; margin-bottom: .5rem; }
.site-title { font-size: clamp(1.75rem, 3.2vw, 2.4rem); font-weight: 700; margin-bottom: .75rem; }
.site-lead { font-size: 1.2rem; color: var(--tspi-muted); max-width: var(--site-maxw-text); }
@media (max-width: 767.98px) { .site-section { padding: 3.25rem 0; } }

/* Hero */
.site-hero { padding: 4.5rem 0 4rem; background:
    radial-gradient(60% 70% at 100% 0%, #E3F2E1 0%, rgba(227, 242, 225, 0) 70%),
    radial-gradient(50% 60% at 0% 100%, #F1F8EF 0%, rgba(241, 248, 239, 0) 70%), #fff; }
.site-hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
.site-hero .lead { font-size: 1.3rem; color: var(--site-ink-2); max-width: 34rem; }
.btn-xl { min-height: 62px; padding: .85rem 1.9rem; font-size: 1.25rem; border-radius: 999px; }
.btn-primary.btn-xl { box-shadow: 0 12px 28px rgba(46, 125, 50, .28); }
.site-check { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; padding: 0; margin: 0; list-style: none; color: var(--site-ink-2); }
.site-check li { display: flex; align-items: center; gap: .5rem; }
.site-check i { color: var(--tspi-green-600); }
.site-leaf { position: relative; border-radius: 28px; background: radial-gradient(80% 80% at 50% 45%, #E4F3E2 0%, #F5FAF4 55%, #fff 100%);
    border: 1px solid var(--site-sage-2); box-shadow: 0 30px 60px -30px rgba(20, 83, 45, .35); overflow: hidden; }
.site-leaf canvas { display: block; width: 100%; aspect-ratio: 1 / 1; max-height: 460px; cursor: grab; }
.site-leaf-tag { position: absolute; left: 1rem; bottom: 1rem; background: rgba(255, 255, 255, .9); border: 1px solid var(--tspi-line);
    border-radius: 999px; padding: .35rem .9rem; font-size: .95rem; color: var(--site-ink-2); }

/* การ์ดตัวอย่างคำถาม */
.ask-card { border-radius: 20px; padding: 1.5rem; height: 100%; background: #fff; border: 1px solid var(--tspi-line); box-shadow: none; }
.ask-card:hover { border-color: var(--tspi-green-600); box-shadow: 0 12px 28px rgba(15, 23, 42, .07); }
.ask-card .q { font-size: 1.2rem; font-weight: 700; color: var(--tspi-ink); }
.ask-card .go { color: var(--tspi-green-700); font-weight: 600; }
.icon-tile { width: 52px; height: 52px; border-radius: 14px; background: var(--tspi-green-50); color: var(--tspi-green-700);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem; flex-shrink: 0; }

/* ขั้นตอน */
.step-num { width: 48px; height: 48px; border-radius: 50%; background: var(--tspi-green-600); color: #fff; font-weight: 700; font-size: 1.25rem;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Accordion */
.site-accordion .accordion-item { border: 1px solid var(--tspi-line); border-radius: 16px !important; overflow: hidden; margin-bottom: .75rem; background: #fff; }
.site-accordion .accordion-button { font-size: 1.15rem; font-weight: 700; padding: 1.15rem 1.25rem; }
.site-accordion .accordion-button:not(.collapsed) { background: var(--tspi-green-50); color: var(--tspi-green-900); box-shadow: none; }
.site-accordion .accordion-button:focus { box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.site-accordion .accordion-body { color: var(--site-ink-2); }
.phase-pill { font-size: .9rem; font-weight: 700; color: var(--tspi-green-700); background: #fff; border: 1px solid var(--site-sage-2);
    border-radius: 999px; padding: .15rem .7rem; margin-right: .75rem; }

/* บทความ */
.article-card { border-radius: 20px; overflow: hidden; height: 100%; }
.article-card img { aspect-ratio: 16 / 9; object-fit: cover; width: 100%; }
.article-card .card-title { font-size: 1.1rem; line-height: 1.45; }
.line-clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* แถบชวนลงมือ */
.site-cta { border-radius: 28px; padding: 3rem 2rem; background: linear-gradient(135deg, #1E7A3C 0%, #2E7D32 55%, #3E9443 100%); color: #fff; }
.site-cta h2 { color: #fff; }
.site-cta .btn-light { color: var(--tspi-green-900); font-weight: 700; }

/* ---------- ส่วนท้าย ---------- */
.site-footer { background: #0F2A1A; color: #CFE3D2; padding: 4rem 0 2rem; margin-top: 0; }
.site-footer h2 { color: #fff; font-size: 1.1rem; margin-bottom: 1rem; }
.site-footer a { color: #E7F3E9; text-decoration: none; }
.site-footer a:hover { color: #fff; text-decoration: underline; }
.site-footer .small, .site-footer small { color: #A9C7AE; }
.site-footer li { margin-bottom: .55rem; }
.site-footer hr { border-color: rgba(255, 255, 255, .15); opacity: 1; }

/* ==========================================================================
   หน้าคุยกับ AI (แบบ ChatGPT: คอลัมน์กลาง ช่องพิมพ์ติดขอบล่าง)
   ========================================================================== */
.chat-shell { display: flex; flex-direction: column; height: calc(100dvh - 75px); background: #fff; }
.chat-scroll { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
.chat-col { width: 100%; max-width: 820px; margin: 0 auto; padding: 0 1rem; }
.chat-scroll .chat-col { padding-top: 2rem; padding-bottom: 2rem; }

.chat-welcome { text-align: center; padding: 2rem 0 1rem; }
.chat-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--tspi-green-600); color: #fff; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.chat-avatar-lg { width: 76px; height: 76px; font-size: 2rem; box-shadow: 0 14px 30px rgba(46, 125, 50, .3); }
.chat-suggest { width: 100%; min-height: 64px; display: flex; align-items: center; gap: .85rem; text-align: left; padding: .9rem 1.1rem;
    background: #fff; border: 1px solid var(--tspi-line); border-radius: 16px; font-size: 1.1rem; font-weight: 600; color: var(--tspi-ink);
    transition: border-color .15s, background .15s; }
.chat-suggest:hover, .chat-suggest:focus-visible { border-color: var(--tspi-green-600); background: var(--tspi-green-50); }
.chat-suggest i { color: var(--tspi-green-700); font-size: 1.2rem; width: 1.5rem; text-align: center; }
.chat-promise { list-style: none; padding: 0; margin: 2rem auto 0; max-width: 520px; text-align: left; color: var(--tspi-muted); }
.chat-promise li { display: flex; gap: .75rem; align-items: baseline; margin-bottom: .5rem; }
.chat-promise i { color: var(--tspi-green-600); width: 1.25rem; text-align: center; }

.chat-row { display: flex; gap: .85rem; margin-bottom: 1.75rem; }
.chat-row.user { justify-content: flex-end; }
.chat-user { max-width: 80%; background: var(--tspi-green-600); color: #fff; padding: .8rem 1.15rem; border-radius: 22px 22px 6px 22px;
    font-size: 1.125rem; line-height: 1.6; white-space: pre-wrap; word-break: break-word; }
.chat-bot { flex: 1; min-width: 0; font-size: 1.125rem; line-height: 1.85; color: var(--tspi-ink); padding-top: .3rem; }
.chat-block p { margin-bottom: .85rem; }
.chat-block ul { padding-left: 1.3rem; margin-bottom: .85rem; }
.chat-block li { margin-bottom: .35rem; }
.chat-cite { display: inline-flex; align-items: center; justify-content: center; min-width: 1.45rem; height: 1.45rem; padding: 0 .35rem;
    margin: 0 .15rem; vertical-align: .15em; border: 0; border-radius: 6px; background: var(--tspi-green-100); color: var(--tspi-green-900);
    font-size: .8rem; font-weight: 700; line-height: 1; cursor: pointer; }
.chat-cite:hover { background: var(--tspi-green-600); color: #fff; }

.chat-general { margin: .25rem 0 .85rem; padding: 1rem 1.15rem; border-radius: 16px; background: #F8FAFC; border: 1px dashed #CBD5E1; }
.chat-general-label { font-size: .95rem; font-weight: 700; color: #475569; margin-bottom: .5rem; }
.chat-general .chat-block p:last-child, .chat-general .chat-block ul:last-child { margin-bottom: 0; }

.chat-sources { border-top: 1px solid var(--tspi-line); padding-top: .6rem; }
.chat-sources-toggle { border: 0; background: none; padding: .25rem 0; color: var(--tspi-green-700); font-weight: 600; font-size: 1rem;
    display: inline-flex; align-items: center; gap: .5rem; }
.chat-sources-list { margin: .5rem 0 0; padding-left: 1.5rem; font-size: .98rem; color: var(--tspi-muted); }

.chat-dock { border-top: 1px solid var(--tspi-line); background: #fff; padding: .85rem 0 calc(.85rem + env(safe-area-inset-bottom)); }
.chat-input { display: flex; align-items: flex-end; gap: .6rem; padding: .45rem .45rem .45rem 1.1rem; border: 1.5px solid #CBD5E1;
    border-radius: 28px; background: #fff; box-shadow: 0 6px 24px rgba(15, 23, 42, .08); }
.chat-input:focus-within { border-color: var(--tspi-green-600); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.chat-input textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; font-size: 1.15rem; line-height: 1.5;
    padding: .55rem 0; max-height: 180px; }
.chat-input .btn { width: 50px; height: 50px; min-height: 0; padding: 0; border-radius: 50%; font-size: 1.15rem; flex-shrink: 0; }
.chat-foot { font-size: .92rem; color: var(--tspi-muted); }

@media (max-width: 575.98px) {
    .chat-shell { height: calc(100dvh - 67px); }
    .chat-row .chat-avatar { display: none; }
    .chat-user { max-width: 90%; }
    .chat-scroll .chat-col { padding-top: 1.25rem; }
}
.site-footer .btn-light { color: var(--tspi-green-900); }
.site-footer .btn-light:hover { color: var(--tspi-green-900); text-decoration: none; }

/* ---------- หน้าเข้าสู่ระบบ / ลงทะเบียน ---------- */
.auth-wrap { padding: 3.5rem 1rem 4.5rem; background: radial-gradient(60% 60% at 100% 0%, #E3F2E1 0%, rgba(227, 242, 225, 0) 70%), var(--site-sage); }
.auth-card { max-width: 460px; margin: 0 auto; background: #fff; border: 1px solid var(--tspi-line); border-radius: 28px;
    padding: 2.5rem 2rem; box-shadow: 0 30px 60px -30px rgba(15, 23, 42, .25); }
.auth-card-wide { max-width: 620px; }
.auth-logo { width: 64px; height: 64px; border-radius: 18px; font-size: 1.6rem; }
.auth-card .form-floating > .form-control { height: 62px; min-height: 62px; font-size: 1.15rem; border-radius: 14px; }
.auth-card .form-floating > label { font-size: 1.05rem; color: var(--tspi-muted); }
.auth-step { font-weight: 700; color: var(--tspi-green-700); margin-bottom: .75rem; }
.auth-consent { background: var(--site-sage); border-radius: 16px; padding: 1rem 1.15rem; }
.auth-consent .form-check-input { width: 1.4rem; height: 1.4rem; margin-top: .2rem; }
.auth-consent .form-check-label { padding-left: .4rem; }
.auth-alt { margin-top: 1.75rem; padding-top: 1.25rem; border-top: 1px solid var(--tspi-line); text-align: center; }
@media (max-width: 575.98px) { .auth-card { padding: 2rem 1.25rem; border-radius: 22px; } .auth-wrap { padding-top: 1.5rem; } }
