/* ============================================================
   ธีมสีส้ม สำหรับ n8n Chat Trigger
   สีหลัก #FFA503 — วางทั้งไฟล์ในช่อง Custom CSS ของโหนด Chatbot
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@400;500;600;700&display=swap');

:root {
  /* ---------- จานสี ---------- */
  --brand:            #FFA503;   /* สีหลักของบริษัท */
  --brand-600:        #F09600;   /* hover */
  --brand-700:        #D98500;   /* กดค้าง */
  --brand-050:        #FFF4DE;   /* พื้นอ่อน ใช้เน้นแบบบาง ๆ */
  --ink:              #241A06;   /* ตัวอักษรบนพื้นสีส้ม */
  --header-bg:        #17130D;   /* หัวแชท น้ำตาลเข้มเกือบดำ */

  --chat--color--primary: var(--brand);
  --chat--color--primary-shade-50: var(--brand-600);
  --chat--color--primary--shade-100: var(--brand-700);
  --chat--color--secondary: var(--brand);
  --chat--color-secondary-shade-50: var(--brand-600);

  --chat--color-white: #fff;
  --chat--color-light: #FAF6F0;              /* พื้นหลังโทนอุ่น เข้ากับสีส้ม */
  --chat--color-light-shade-50: #F0E8DB;
  --chat--color-light-shade-100: #DCD2C2;
  --chat--color-medium: #C9BFB0;
  --chat--color-dark: #2B2318;
  --chat--color-disabled: #D8D0C4;
  --chat--color-typing: var(--brand-700);

  /* ---------- ตัวอักษร ---------- */
  /* Noto Sans Thai อ่านง่ายกว่าฟอนต์ระบบมากเมื่อผสมไทย-อังกฤษ */
  --chat--font-family: 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* ---------- โครงหน้าต่าง ---------- */
  --chat--spacing: 1rem;
  --chat--border-radius: 14px;
  --chat--transition-duration: 0.2s;
  --chat--window--width: 420px;
  --chat--window--height: 640px;
  --chat--window--border: 1px solid var(--chat--color-light-shade-50);
  --chat--window--border-radius: 18px;
  --chat--window--z-index: 9999;

  /* ---------- หัวแชท ---------- */
  --chat--header--background: var(--header-bg);
  --chat--header--color: #FFF7E8;
  --chat--header--padding: 1.35rem var(--chat--spacing);
  --chat--header--border-bottom: 3px solid var(--brand);
  --chat--heading--font-size: 1.45rem;
  --chat--subtitle--font-size: 0.9rem;
  --chat--subtitle--line-height: 1.65;

  /* ---------- ข้อความ ---------- */
  --chat--message--font-size: 1rem;
  --chat--message--padding: 0.85rem 1.05rem;
  --chat--message--border-radius: var(--chat--border-radius);
  --chat--message-line-height: 1.75;         /* ไทยมีสระบน-ล่าง ต้องการบรรทัดสูงกว่าอังกฤษ */
  --chat--message--margin-bottom: 0.7rem;

  --chat--message--bot--background: #FFFFFF;
  --chat--message--bot--color: #2B2318;
  --chat--message--bot--border: 1px solid #EFE6D8;

  /* พื้นส้มสว่างมาก ตัวอักษรต้องเป็นสีเข้ม ไม่ใช่สีขาว */
  --chat--message--user--background: var(--brand);
  --chat--message--user--color: var(--ink);
  --chat--message--user--border: none;
  --chat--message--pre--background: rgba(0, 0, 0, 0.05);
  --chat--messages-list--padding: 1.25rem var(--chat--spacing);

  /* ---------- ปุ่มลอย (โหมดฝังในเว็บ) ---------- */
  --chat--toggle--size: 60px;
  --chat--toggle--width: var(--chat--toggle--size);
  --chat--toggle--height: var(--chat--toggle--size);
  --chat--toggle--border-radius: 50%;
  --chat--toggle--background: var(--brand);
  --chat--toggle--hover--background: var(--brand-600);
  --chat--toggle--active--background: var(--brand-700);
  --chat--toggle--color: var(--ink);

  /* ---------- ช่องพิมพ์ ---------- */
  --chat--textarea--height: 54px;
  --chat--textarea--max-height: 12rem;
  --chat--input--padding: 0.9rem 1rem;
  --chat--input--background: #FFFFFF;
  --chat--input--text-color: #2B2318;
  --chat--input--line-height: 1.6;
  --chat--input--border: 0;
  --chat--input--border-active: 0;

  /* ---------- ปุ่ม ---------- */
  --chat--button--padding: 0.65rem 1.15rem;
  --chat--button--border-radius: 10px;
  --chat--button--font-size: 0.95rem;
  --chat--button--color--primary: var(--ink);
  --chat--button--background--primary: var(--brand);
  --chat--button--color--primary--hover: var(--ink);
  --chat--button--background--primary--hover: var(--brand-600);
  --chat--button--color--primary--disabled: #8A7C66;
  --chat--button--background--primary--disabled: #F2E4C6;
  --chat--close--button--color-hover: var(--brand);

  --chat--input--send--button--background: transparent;
  --chat--input--send--button--color: var(--brand-700);
  --chat--input--send--button--background-hover: transparent;
  --chat--input--send--button--color-hover: var(--brand);
  --chat--input--file--button--background: transparent;
  --chat--input--file--button--color: #9A8B73;
  --chat--input--file--button--color-hover: var(--brand-700);

  /* ---------- พื้นหลัง / ท้ายหน้า ---------- */
  --chat--body--background: var(--chat--color-light);
  --chat--footer--background: #FFFFFF;
  --chat--footer--color: #6B5D45;
}

/* ============================================================
   ปรับแต่งระดับคลาส
   ============================================================ */

/* ฟองข้อความ: กว้างขึ้นเพราะคำตอบภาษาไทยมักยาว 2-4 บรรทัด */
.chat-message {
  max-width: 78%;
  box-shadow: 0 1px 2px rgba(36, 26, 6, 0.06);
  animation: chat-pop var(--chat--transition-duration) ease-out;
}

/* มุมด้านที่ติดกับผู้พูด ให้แหลมกว่าอีกสามมุม เหมือนหางฟองคำพูด */
.chat-message.chat-message-from-bot  { border-bottom-left-radius: 4px; }
.chat-message.chat-message-from-user {
  border-bottom-right-radius: 4px;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(255, 165, 3, 0.28);
}

@keyframes chat-pop {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* หัวแชท: ไล่เฉดส้มบาง ๆ ตัดกับพื้นเข้ม */
.chat-header {
  background-image: linear-gradient(135deg, #17130D 0%, #241C10 60%, #33260F 100%);
}
.chat-header h1 { letter-spacing: -0.01em; }
.chat-header p  { color: #D9CDB8; margin-top: 0.35rem; }

/* แถบพิมพ์: เส้นขอบเรืองแสงสีส้มเมื่อโฟกัส */
.chat-input {
  border-top: 1px solid #EFE6D8;
  transition: box-shadow var(--chat--transition-duration) ease;
}
.chat-input:focus-within {
  box-shadow: inset 0 2px 0 0 var(--brand);
}
.chat-input textarea::placeholder { color: #A2937C; }

/* ปุ่มส่ง: วงกลมสีส้ม ไอคอนสีเข้ม */
.chat-input-send-button {
  background: var(--brand) !important;
  color: var(--ink) !important;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--chat--transition-duration) ease,
              background var(--chat--transition-duration) ease;
}
.chat-input-send-button:hover  { background: var(--brand-600) !important; transform: scale(1.06); }
.chat-input-send-button:active { background: var(--brand-700) !important; transform: scale(0.96); }

/* จุดกำลังพิมพ์ */
.chat-message-typing .chat-message-typing-circle { background: var(--brand); }

/* แถบเลื่อนแบบบาง */
.chat-messages-list::-webkit-scrollbar { width: 8px; }
.chat-messages-list::-webkit-scrollbar-thumb {
  background: #E2D6C2;
  border-radius: 4px;
}
.chat-messages-list::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ลิงก์ในคำตอบของบอท */
.chat-message-from-bot a {
  color: var(--brand-700);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* รายการหัวข้อในคำตอบ ให้เว้นระยะอ่านสบายขึ้น */
.chat-message-from-bot ul,
.chat-message-from-bot ol { padding-left: 1.2rem; margin: 0.4rem 0; }
.chat-message-from-bot li { margin-bottom: 0.3rem; }

/* บนจอมือถือ ฟองข้อความควรกว้างเกือบเต็ม */
@media (max-width: 640px) {
  .chat-message { max-width: 92%; }
  :root {
    --chat--heading--font-size: 1.25rem;
    --chat--messages-list--padding: 1rem 0.75rem;
  }
}
