@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP&display=swap');

/* 기본 설정 */
body {
  font-family: 'Noto Sans JP', sans-serif;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  background-color: #fff;
}

button {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
}

/* 이미지 컨테이너 */
.image-container {
  position: absolute;
  top: 20px;
  left: 20px;
  font-size: 48px;
  font-weight: bold;
  line-height: 1.3;
  color: #000;
  text-align: left;
  white-space: pre-line;
}

/* Chatbot 버튼 (오른쪽 하단 고정) */
.chatbot-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 15px 20px;
  background-color: #4CAF50;
  color: white;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

/* ✅ 전체 래퍼 (좌측 탭 + 우측 메인) — 기본값 px 고정 */
.chat-container-wrapper {
  width: 750px;
  height: 650px;          /* 기본 높이 */
  position: fixed;
  bottom: 80px;
  right: 20px;
  display: none;          /* JS에서 flex/none 토글 */
  background-color: #fff;
  box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  z-index: 999;
  flex-direction: row;    /* 열 방향 */
  overflow: hidden;       /* 둥근 모서리 안쪽만 보이도록 */
  box-sizing: border-box;
}

/* 좌측 세로 탭 */
.chat-mode-toggle {
  display: flex;
  flex-direction: column;
  width: 100px;
  flex: 0 0 100px;
  background: #f1f1f1;
  border-right: 1px solid #ccc;
  justify-content: flex-start;
  align-items: center;
  padding: 10px 5px;
}

.chat-mode-toggle button {
  display: block;
  width: 100%;
  padding: 12px;
  border: 1px solid #ccc;  /* ✅ 외곽선 유지 */
  text-align: center;
  cursor: pointer;
  background-color: #f0f0f0;
  transition: background-color 0.3s, color 0.3s;
  margin: 10px 0;
  border-radius: 6px;
  font-size: 14px;
}

.chat-mode-toggle button:hover {
  background-color: #ddd;
}

.chat-mode-toggle button.active {
  background-color: #4CAF50;
  color: #fff;
  font-weight: bold;
}

/* 우측 메인 */
.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;          /* 🔑 flex 스크롤 버그 방지 */
}

/* 채팅/일지 공통 컨테이너 */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;           /* 부모(wrapper) 높이에 맞춤 */
  min-height: 0;          /* 🔑 */
}

/* 메시지 리스트(유일한 스크롤 영역) */
.chat-box,
.log-box,
.group-box {
  flex: 1 1 auto;
  min-height: 0;          /* 🔑 */
  overflow: auto;
  padding: 12px 12px 88px;  /* 입력창 높이만큼 바닥 여백 */
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  background: #fafafa;
  box-sizing: border-box;
}

.chat-box::-webkit-scrollbar,
.log-box::-webkit-scrollbar,
.group-box::-webkit-scrollbar {
  width: 6px;
}
.chat-box::-webkit-scrollbar-thumb,
.log-box::-webkit-scrollbar-thumb,
.group-box::-webkit-scrollbar-thumb {
  background-color: #bfbfbf;
  border-radius: 5px;
}
.chat-box::-webkit-scrollbar-track,
.log-box::-webkit-scrollbar-track,
.group-box::-webkit-scrollbar-track {
  background-color: #f1f1f1;
}

/* 메시지 */
.message {
  max-width: 85%;
  padding: 10px;
  margin: 5px;
  border-radius: 10px;
  word-wrap: break-word;
  position: relative;
  background-clip: padding-box;
}

.message.received {
  background-color: #e0e0e0;
  align-self: flex-start;
  border-radius: 15px 15px 15px 5px;
}

.message.sent {
  background-color: #4CAF50;
  color: #fff;
  align-self: flex-end;
  border-radius: 15px 15px 5px 15px;
}

.message::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border-style: solid;
}
.message.received::after {
  border-width: 10px;
  border-color: transparent #e0e0e0 transparent transparent;
  left: -10px;
  top: 10px;
}
.message.sent::after {
  border-width: 10px;
  border-color: transparent transparent transparent #4CAF50;
  right: -10px;
  top: 10px;
}

/* 마크다운 말줄임 여백 과다 방지 */
.message > :last-child { margin-bottom: 0; }

/* 입력창 (패널 내부 하단 고정) */
.input-box {
  position: sticky;   /* 패널 내부 하단에 고정 */
  bottom: 0;
  z-index: 1;
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid #ccc;
  background: #fff;
  flex: 0 0 auto;
  box-sizing: border-box;
}

.input-box input {
  flex: 1 1 auto;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 5px;
  margin-right: 5px;
}

.mic-button {
  padding: 10px;
  border: none;
  background-color: #d3d3d3 !important;
  color: black;
  cursor: pointer;
  border-radius: 5px;
  margin-right: 5px;
}
.mic-button:hover { filter: brightness(70%); }

.send-button {
  padding: 10px;
  border: none;
  background-color: #4CAF50;
  color: white;
  cursor: pointer;
  border-radius: 5px;
}
.send-button:hover { filter: brightness(70%); }

/* 로딩 애니메이션 */
.dot {
  animation: blink 1.4s infinite;
  font-size: 20px;
  font-weight: bold;
  margin: 0 2px;
}
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* ------------------- 너비 (Width) — wrapper 전용 ------------------- */

/* 작은 휴대폰 (아이폰 SE 등) */
@media (max-width: 360px) {
  .chat-container-wrapper { width: 330px; }
}

/* 보통 휴대폰 (361px ~ 480px) */
@media (min-width: 361px) and (max-width: 480px) {
  .chat-container-wrapper { width: 340px; }
}

/* 큰 휴대폰 (481px ~ 600px) */
@media (min-width: 481px) and (max-width: 600px) {
  .chat-container-wrapper { width: 450px; }
}

/* 작은 태블릿 (601px ~ 768px) */
@media (min-width: 601px) and (max-width: 768px) {
  .chat-container-wrapper { width: 550px; }
}

/* ------------------- 높이 (Height) — wrapper 전용 ------------------- */

/* 작은 휴대폰 (아이폰 SE 등) */
@media (max-height: 640px) {
  .chat-container-wrapper { height: 400px; }
}

/* 보통 휴대폰 */
@media (min-height: 641px) and (max-height: 800px) {
  .chat-container-wrapper { height: 500px; }
}

/* 큰 휴대폰 */
@media (min-height: 801px) and (max-height: 900px) {
  .chat-container-wrapper { height: 600px; }
}

/* 작은 태블릿 */
@media (min-height: 901px) and (max-height: 1100px) {
  .chat-container-wrapper { height: 700px; }
}


/* 🔧 마크다운 기본 여백 리셋 */
.message p { margin: 0; }
.message ul, .message ol { margin: 0; padding-left: 1.2em; }
.message h1, .message h2, .message h3, .message h4 { margin: 0.2em 0; }

/* 🔧 풍선 기본 줄간 간격 약간만 */
.message { line-height: 1.7; }

/* 🔧 진짜 한 줄(단일 p 요소만 있을 때)은 더 컴팩트하게 */
.message:has(p:only-child) { padding-block: 6px; }
/* (Chrome/Edge/Safari 최신에서 :has 지원. 오래된 브라우저 고려 X면 OK) */

.chat-main,
.chat-container,
.chat-box,
.log-box,
.group-box {
  min-width: 0;
}

/* 3) 말풍선 안의 길~은 토큰도 강제 줄바꿈 (보너스 안정화) */
.message {
  overflow-wrap: anywhere;
  word-break: break-word;
}
.message pre,
.message code {
  white-space: pre-wrap;
  word-break: break-word;
}

.inline-actions { display:flex; margin:6px 0 8px; }
.inline-btn {
  padding:6px 10px; border-radius:8px;
  border:1px solid #cfe0ff; background:#eef6ff;
  font-size:12px; cursor:pointer;
}
.inline-btn:active { transform: translateY(1px); }

.user-tabs {
  display: flex;
  border-bottom: 1px solid #e0e0e0; /* A light line to separate tabs from content */
  background-color: #fff;
}

.tab-button {
  padding: 10px 20px;
  border: none;
  background-color: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #555;
  border-bottom: 3px solid transparent; /* Placeholder for active indicator */
  margin-bottom: -1px; /* Aligns with the bottom border */
}

.tab-button.active {
  color: #000;
  font-weight: 600;
  border-bottom: 3px solid #333; /* Or your preferred highlight color */
}
