/* Import Google font - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", "sans-serif";
}
body {
  background: #E3F2FD;
}
.chatbot-toggler {
  position: fixed;
  bottom: 60px;
  right: 60px;
  outline: none;
  border: none;
  height: 50px;
  width: 50px;
  display: flex;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #724ae8;
  transition: all 0.2s ease;
  z-index: 5;
}
body.show-chatbot .chatbot-toggler {
  transform: rotate(90deg);
}
.chatbot-toggler span {
  color: #fff;
  position: absolute;
}
.chatbot-toggler span:last-child,
body.show-chatbot .chatbot-toggler span:first-child  {
  opacity: 0;
}
body.show-chatbot .chatbot-toggler span:last-child {
  opacity: 1;
}
.chatbot {
  position: fixed;
  right: 60px;
  bottom: 120px;
  width: 420px;
  background: #fff;
  border-radius: 15px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.5);
  transform-origin: bottom right;
  box-shadow: 0 0 128px 0 rgba(0,0,0,0.1),
              0 32px 64px -48px rgba(0,0,0,0.5);
  transition: all 0.1s ease;
  z-index: 5;
}
body.show-chatbot .chatbot {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}
.chatbot header {
  padding: 10px 0;
  position: relative;
  text-align: center;
  color: #fff;
  background: #724ae8;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.chatbot header span {
  position: absolute;
  right: 15px;
  top: 50%;
  display: none;
  cursor: pointer;
  transform: translateY(-50%);
}
header h2 {
  font-size: 1.4rem;
}
.chatbot .chatbox {
  overflow-y: auto;
  height: 510px;
  padding: 30px 20px 100px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar {
  width: 6px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-track {
  background: #fff;
  border-radius: 25px;
}
.chatbot :where(.chatbox, textarea)::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 25px;
}
.chatbox .chat {
  display: flex;
  list-style: none;
}
.chatbox .outgoing {
  margin: 20px 0;
  justify-content: flex-end;
}
.chatbox .incoming span {
  width: 32px;
  height: 32px;
  color: #fff;
  cursor: default;
  text-align: center;
  line-height: 32px;
  align-self: flex-end;
  background: #724ae8;
  border-radius: 4px;
  margin: 0 10px 7px 0;
}

.chatbox .chat div.error {
  color: #721c24;
  background: #f8d7da;
}

.chatbot .chat-input {
  display: flex;
  gap: 5px;
  position: absolute;
  bottom: 0;
  width: 100%;
  background: #fff;
  padding: 3px 20px;
  border-top: 1px solid #ddd;
}
.chat-input textarea {
  height: 55px;
  width: 100%;
  border: none;
  outline: none;
  resize: none;
  max-height: 180px;
  padding: 15px 15px 15px 0;
  font-size: 0.95rem;
}
.chat-input span {
  align-self: flex-end;
  color: #724ae8;
  cursor: pointer;
  height: 55px;
  display: flex;
  align-items: center;
  visibility: hidden;
  font-size: 1.35rem;
}
.chat-input textarea:valid ~ span {
  visibility: visible;
}

@media (max-width: 420px) {
  .chatbot-toggler {
    left: 20px;
    bottom: 30px;
    height: 45px;
    width: 45px;
  }
  .chatbot {
    left: 20px;
    bottom: 80px;
    height: 55%;
    border-radius: 15px;
    transform-origin: bottom left;
    width: 80%;
  }
  .chatbot .chatbox {
    height: 90%;
    padding: 25px 15px 100px;
  }
  .chatbot :where(.chatbox, textarea)::-webkit-scrollbar-track {
  background: #fff;
  border-radius: 25px;
  }
  .chatbot :where(.chatbox, textarea)::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 25px;
  }
  .chatbot .chat-input {
    padding: 5px 15px;
  }
  .chatbot header span {
    display: block;
  }
}

/* 1. 메시지 공통 텍스트 색상 설정 (p 대신 div 등을 쓸 때 대응) */
.chatbox .chat :where(div, li, span, h1, h2, h3) {
    color: inherit; /* 부모인 .incoming이나 .outgoing의 색상을 따라가게 함 */
}

/* 2. 보낸 메시지 (나) - 배경 보라색, 글자 흰색 */
.chatbox .outgoing div,
.chatbox .outgoing span {
    color: #000;
    background: #a5e3fc;
    padding: 12px 16px;
    border-radius: 10px 10px 0 10px;
    display: inline-block; /* 내용만큼만 배경색이 차도록 */
}

/* 3. 받은 메시지 (챗봇) - 배경 회색, 글자 검은색 */
.chatbox .incoming div {
    width: 100%;
    color: #000; /* 글자색을 명시적으로 검은색으로 설정 */
    background: #bfaef3; /* 배경색 설정 */
    padding: 12px 16px;
    border-radius: 10px 10px 10px 0;
    display: inline-block; /* 내용만큼만 배경색이 차도록 */
}

/* 표(Table) 내부 글자색도 검은색으로 명시 */
.chatbox .incoming table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 0.85rem;
    color: #000;
    background: #fff; /* 표 배경을 흰색으로 하면 더 잘 보입니다 */
}

.chatbox .incoming th, .chatbox .incoming td {
    border: 1px solid #ddd;
    padding: 4px 8px;
    text-align: left;
    color: #000;
}

.chatbox .incoming ul, .chatbox .incoming ol {
    padding-left: 20px;
    margin: 10px 0;
}

/* 말풍선 내부의 p 태그 여백을 제거하거나 최소화 */
.chatbox .chat :where(div, p, span) p {
  margin: 0;
  padding: 0;
}

/* p 태그 간의 간격을 조절하고 싶다면 아래처럼 약간의 마진만 줍니다 */
.chatbox .chat :where(div, p, span) p:not(:last-child) {
  margin-bottom: 2px; /* 줄바꿈 간격을 5px로 고정 (원하는 만큼 조절 가능) */
}