/* ==========================================================================
   Chatbot widget (TOR 4.20.2)
   ปุ่มลอยมุมขวาล่าง + กล่องสนทนา responsive ใช้ได้บนมือถือ (TOR 4.12)
   ========================================================================== */

.cb-launcher {
   position: fixed;
   right: 20px;
   bottom: 20px;
   z-index: 10800;
   width: 60px;
   height: 60px;
   border: 0;
   border-radius: 50%;
   background: #00539f;
   color: #fff;
   box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   transition: transform .2s ease;
}
.cb-launcher:hover { transform: scale(1.06); }
.cb-launcher svg { width: 28px; height: 28px; fill: #fff; }
.cb-launcher.cb-hidden { display: none; }

.cb-panel {
   position: fixed;
   right: 20px;
   bottom: 20px;
   z-index: 10801;
   width: 380px;
   max-width: calc(100vw - 24px);
   height: 560px;
   max-height: calc(100vh - 40px);
   background: #fff;
   border-radius: 12px;
   box-shadow: 0 10px 40px rgba(0, 0, 0, .28);
   display: none;
   flex-direction: column;
   overflow: hidden;
   font-size: 15px;
   line-height: 1.55;
}
.cb-panel.cb-open { display: flex; }

.cb-header {
   background: #00539f;
   color: #fff;
   padding: 14px 16px;
   display: flex;
   align-items: center;
   justify-content: space-between;
   flex: 0 0 auto;
}
.cb-header .cb-title { font-weight: 600; font-size: 16px; }
.cb-header .cb-sub { font-size: 12px; opacity: .8; display: block; font-weight: 400; }
.cb-header-tools { display: flex; align-items: center; gap: 4px; }
.cb-header button {
   background: transparent;
   border: 0;
   color: #fff;
   font-size: 13px;
   cursor: pointer;
   padding: 4px 8px;
   border-radius: 4px;
   line-height: 1;
}
.cb-header button:hover { background: rgba(255, 255, 255, .18); }
.cb-header .cb-close { font-size: 22px; }

.cb-body {
   flex: 1 1 auto;
   overflow-y: auto;
   padding: 14px;
   background: #f4f6f9;
}

.cb-row {
   display: flex;
   margin-bottom: 10px;
   animation: cb-in-up .22s ease-out both;
}
.cb-row.cb-in { justify-content: flex-end; }
.cb-row.cb-out { justify-content: flex-start; }

@keyframes cb-in-up {
   from { opacity: 0; transform: translateY(8px); }
   to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
   .cb-row { animation: none; }
}

.cb-bubble {
   max-width: 82%;
   padding: 10px 13px;
   border-radius: 14px;
   white-space: pre-wrap;
   word-wrap: break-word;
   overflow-wrap: anywhere;
}
.cb-in .cb-bubble { background: #00539f; color: #fff; border-bottom-right-radius: 4px; }
.cb-out .cb-bubble { background: #fff; color: #222; border: 1px solid #e2e6ea; border-bottom-left-radius: 4px; }

.cb-menu { max-width: 92%; }
.cb-menu .cb-menu-title { font-size: 13px; color: #55606b; margin: 2px 0 6px; }
.cb-menu-item {
   display: block;
   width: 100%;
   text-align: left;
   background: #fff;
   border: 1px solid #00539f;
   color: #00539f;
   border-radius: 20px;
   padding: 8px 14px;
   margin-bottom: 6px;
   cursor: pointer;
   font-size: 14px;
   line-height: 1.4;
}
.cb-menu-item:hover { background: #00539f; color: #fff; }
.cb-menu-item .cb-menu-no { font-weight: 600; margin-right: 6px; }

/* เมนูที่ตอบไปแล้ว — กดซ้ำไม่ได้ และต้องดูต่างจากเมนูที่ยังใช้ได้อย่างชัดเจน */
.cb-menu-done .cb-menu-title { color: #7a838c; }
.cb-menu-done .cb-menu-item {
   border-color: #ccd3da;
   color: #78828c;
   background: #f7f9fa;
   cursor: default;
   opacity: .75;
}
.cb-menu-done .cb-menu-item:hover { background: #f7f9fa; color: #78828c; }

.cb-attach { max-width: 82%; }
.cb-attach img { max-width: 100%; border-radius: 10px; display: block; }
.cb-attach .cb-caption { font-size: 12px; color: #55606b; margin-top: 4px; }
.cb-link {
   display: inline-block;
   background: #fff;
   border: 1px solid #e2e6ea;
   border-radius: 10px;
   padding: 9px 13px;
   color: #00539f;
   text-decoration: underline;
   word-break: break-all;
}

/* ตัวบ่งชี้ "กำลังพิมพ์" — จุดสามจุดกระเพื่อม อ่านออกว่าระบบกำลังทำงานอยู่ */
.cb-typing .cb-bubble { display: flex; align-items: center; gap: 4px; padding: 13px; }
.cb-dot {
   width: 7px;
   height: 7px;
   border-radius: 50%;
   background: #98a3ae;
   animation: cb-blink 1.2s infinite ease-in-out both;
}
.cb-dot:nth-child(2) { animation-delay: .18s; }
.cb-dot:nth-child(3) { animation-delay: .36s; }

@keyframes cb-blink {
   0%, 70%, 100% { opacity: .28; transform: translateY(0); }
   35%           { opacity: 1;   transform: translateY(-3px); }
}
@media (prefers-reduced-motion: reduce) {
   .cb-dot { animation: none; opacity: .6; }
}

.cb-footer {
   flex: 0 0 auto;
   border-top: 1px solid #e2e6ea;
   padding: 10px;
   background: #fff;
   display: flex;
   gap: 8px;
}
.cb-footer input {
   flex: 1 1 auto;
   border: 1px solid #d5dbe1;
   border-radius: 20px;
   padding: 9px 14px;
   font-size: 15px;
   outline: none;
   font-family: inherit;
}
.cb-footer input:focus { border-color: #00539f; }
.cb-footer button {
   flex: 0 0 auto;
   border: 0;
   border-radius: 20px;
   background: #00539f;
   color: #fff;
   padding: 0 18px;
   cursor: pointer;
   font-family: inherit;
   font-size: 15px;
}
.cb-footer button:disabled { background: #9aa7b3; cursor: not-allowed; }

.cb-note { font-size: 11px; color: #8a939c; text-align: center; padding: 0 10px 8px; background: #fff; }

@media (max-width: 575.98px) {
   .cb-panel {
      right: 0;
      bottom: 0;
      width: 100%;
      max-width: 100%;
      height: 100%;
      max-height: 100%;
      border-radius: 0;
   }
   .cb-launcher { right: 14px; bottom: 14px; width: 54px; height: 54px; }
}

/* ==========================================================================
   ประเมินความพึงพอใจ (TOR 4.20.6)
   ========================================================================== */
.cb-rate {
   width: 100%;
   background: #fff;
   border: 1px solid #e2e6ea;
   border-radius: 12px;
   padding: 13px 14px;
}
.cb-rate-title { font-size: 14px; color: #46505a; margin-bottom: 8px; }
.cb-stars { display: flex; gap: 4px; margin-bottom: 8px; }
.cb-star {
   background: none;
   border: 0;
   padding: 0 2px;
   font-size: 27px;
   line-height: 1;
   color: #d5dbe1;
   cursor: pointer;
   transition: color .12s ease, transform .12s ease;
}
.cb-star:hover { transform: scale(1.12); }
.cb-star-on { color: #f0ad20; }
.cb-rate-comment {
   width: 100%;
   border: 1px solid #d5dbe1;
   border-radius: 8px;
   padding: 7px 10px;
   font-size: 14px;
   font-family: inherit;
   resize: vertical;
   outline: none;
}
.cb-rate-comment:focus { border-color: #00539f; }

/* ==========================================================================
   การ์ดกลับสู่หัวข้อสอบถามหลัก
   ========================================================================== */
.cb-home {
   width: 100%;
   background: #eef3f8;
   border: 1px dashed #9fb8d0;
   border-radius: 12px;
   padding: 11px 13px;
}
.cb-home-hint { font-size: 12px; color: #66717c; margin-bottom: 7px; }
.cb-home-btn {
   display: flex;
   align-items: center;
   gap: 7px;
   width: 100%;
   text-align: left;
   background: #fff;
   border: 1px solid #00539f;
   color: #00539f;
   border-radius: 20px;
   padding: 8px 14px;
   cursor: pointer;
   font-size: 14px;
   font-family: inherit;
   line-height: 1.4;
}
.cb-home-btn:hover { background: #00539f; color: #fff; }
.cb-home-icon { font-size: 16px; line-height: 1; }
