/* Graduate Chatbot — Theme (ปรับแต่งได้จากหน้า Settings)
   ทุกคลาสขึ้นต้นด้วย gcb- เพื่อไม่ให้ชนกับ CSS ของธีม WordPress
   ตัวแปรสีทั้งหมดอยู่ใน :root ด้านล่าง — หน้า Settings จะฉีดค่าทับผ่าน <style> แยกต่างหาก */

.gcb-root {
  --gcb-header-from: #16324f;   /* สีไล่เฉดเข้ม (หัวแชท) */
  --gcb-header-to: #2c6e9b;     /* สีหลัก/Accent (หัวแชท, ปุ่ม, บับเบิ้ลผู้ใช้) */
  --gcb-header-text: #ffffff;   /* สีตัวอักษร/ไอคอนในหัวแชท */
  --gcb-accent-dark: #1f5679;   /* สีหลักตอน hover */
  --gcb-bg: #eaf1f7;            /* พื้นหลังบับเบิ้ลบอท/กล่องพิมพ์ */
  --gcb-surface: #ffffff;       /* พื้นหลังการ์ดแชท */
  --gcb-text: #16324f;          /* สีตัวอักษรหลัก */
  --gcb-muted: #5b6b7c;
  --gcb-border: #d7e3ec;
  --gcb-online: #3fae7a;
  --gcb-error: #b3412f;
  --gcb-font-size: 14px;
  font-family: 'Noto Sans Thai', 'Segoe UI', sans-serif;
  font-size: var(--gcb-font-size);
}

.gcb-root * {
  box-sizing: border-box;
}

/* ---------- โหมดลอย (Floating) ---------- */
.gcb-root[data-mode="floating"] {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
}

.gcb-bubble-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--gcb-header-from) 0%, var(--gcb-header-to) 100%);
  color: var(--gcb-header-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px -8px rgba(22, 50, 79, 0.5);
  transition: transform 0.15s ease;
}

.gcb-bubble-btn:hover { transform: scale(1.06); }
.gcb-bubble-btn svg { width: 26px; height: 26px; }

.gcb-panel-floating {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  max-height: 75vh;
  z-index: 999999;
}

@media (max-width: 480px) {
  .gcb-panel-floating {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 88px;
    height: 70vh;
  }
  .gcb-root[data-mode="floating"] { right: 12px; bottom: 12px; }
}

/* ---------- โหมดฝังในหน้า (Inline) ---------- */
.gcb-panel-inline {
  width: 100%;
  max-width: 720px;
  height: 620px;
  margin: 0 auto;
}

/* ---------- ตัวแชทหลัก (ใช้ร่วมกันทั้งสองโหมด) ---------- */
.gcb-chat-app {
  width: 100%;
  height: 100%;
  background: var(--gcb-surface);
  border-radius: 18px;
  box-shadow: 0 24px 60px -20px rgba(22, 50, 79, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--gcb-border);
}

.gcb-header {
  background: linear-gradient(135deg, var(--gcb-header-from) 0%, var(--gcb-header-to) 100%);
  color: var(--gcb-header-text);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.gcb-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #ffffff;
  color: var(--gcb-header-from);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  padding: 4px;
}
.gcb-avatar svg { width: 22px; height: 22px; }
.gcb-avatar-img { width: 100%; height: 100%; object-fit: contain; }

.gcb-header-text { flex: 1; min-width: 0; }
.gcb-header-text h3 { font-size: 1.07em; font-weight: 600; margin: 0; line-height: 1.3; color: inherit; }
.gcb-header-text p {
  font-size: 0.86em;
  margin: 2px 0 0;
  color: inherit;
  opacity: 0.78;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gcb-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gcb-online);
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(128,128,128,0.25);
}

.gcb-close-btn {
  background: none; border: none; color: inherit; opacity: 0.85;
  cursor: pointer; padding: 4px; display: flex; flex-shrink: 0;
}
.gcb-close-btn:hover { opacity: 1; }
.gcb-close-btn svg { width: 18px; height: 18px; }

.gcb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--gcb-surface);
}

.gcb-msg-row { display: flex; max-width: 85%; animation: gcb-rise 0.25s ease-out; }
@keyframes gcb-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.gcb-msg-row.bot { align-self: flex-start; }
.gcb-msg-row.user { align-self: flex-end; }

.gcb-bubble {
  padding: 10px 14px;
  font-size: 1em;
  line-height: 1.6;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.gcb-msg-row.bot .gcb-bubble {
  background: var(--gcb-bg);
  color: var(--gcb-text);
  border-radius: 12px 12px 12px 4px;
  border: 1px solid var(--gcb-border);
}

.gcb-msg-row.user .gcb-bubble {
  background: var(--gcb-header-to);
  color: #fff;
  border-radius: 12px 12px 4px 12px;
}

.gcb-msg-row.error .gcb-bubble {
  background: #fbebe8;
  color: var(--gcb-error);
  border: 1px solid #f0c9c2;
  border-radius: 12px;
}

.gcb-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.gcb-msg-row.bot .gcb-bubble a { color: var(--gcb-header-to); font-weight: 600; }
.gcb-msg-row.user .gcb-bubble a { color: #fff; }

.gcb-typing-dots {
  display: flex; gap: 4px; padding: 12px 15px;
  background: var(--gcb-bg);
  border: 1px solid var(--gcb-border);
  border-radius: 12px 12px 12px 4px;
}
.gcb-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gcb-muted); opacity: 0.5;
  animation: gcb-bounce 1.2s infinite ease-in-out;
}
.gcb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.gcb-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes gcb-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.gcb-input-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 14px;
  flex-shrink: 0;
  border-top: 1px solid var(--gcb-border);
  background: var(--gcb-surface);
}

.gcb-input {
  flex: 1;
  font-family: inherit;
  font-size: 1em;
  padding: 10px 14px;
  border: 1px solid var(--gcb-border);
  border-radius: 999px;
  background: var(--gcb-bg);
  color: var(--gcb-text);
}
.gcb-input:focus { background: var(--gcb-surface); outline: 2px solid var(--gcb-header-to); outline-offset: 1px; }

.gcb-send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--gcb-header-to); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.15s ease, transform 0.1s ease;
}
.gcb-send-btn:hover { background: var(--gcb-accent-dark); }
.gcb-send-btn:active { transform: scale(0.94); }
.gcb-send-btn:disabled { background: var(--gcb-muted); opacity: 0.5; cursor: not-allowed; }
.gcb-send-btn svg { width: 16px; height: 16px; }

@media (prefers-reduced-motion: reduce) {
  .gcb-msg-row, .gcb-typing-dots span { animation: none; }
}
