/* -----------------------------------------------------------
   기본 테마 변수
----------------------------------------------------------- */
:root {
  --background-color: #1c1c1c;
  --sidebar-bg-color: #0d0d0d;
  --chat-background-color: #1c1c1c;
  --user-message-bg: #3a3a3a;
  --bot-message-bg: transparent;
  --input-background-color: #333333;
  --text-color: #e0e0e0;
  --text-secondary-color: #a0a0a0;
  --border-color: #333;
  --button-color: #5a5a5a;
  --button-hover-color: #6a6a6a;
  
  --sidebar-width: 260px;
  --sidebar-width-collapsed: 80px;
  
  /* 스크롤바 */
  --scrollbar-color:rgba(255, 255, 255, 0.25) transparent;

  /* 좌측 히스토리 메뉴 구성 */
  --history-active-text-color-accent: #9c9c9c;

  /* + 버튼 */
  --chat-btn-color: #fff;
  --chat-btn-bg-color: #3a3a3a;
  --chat-btn-bg-hover-color: #4a4a4a;

  /* 팝업(파일첨부) */
  --chat-btn-pop-bg-color: #2a2a2a;
  --chat-btn-pop-color: #ddd;
  --chat-btn-pop-hover-color: #3a3a3a;

  /* 메시지 */
  --message-color: #ffffff;
  --message-hover-color: #ffffff;
  --message-box-bg-hover-color:#222;
}

/* -----------------------------------------------------------
   [NEW] 화이트 모드 (Override)
   .app-layout에 data-theme="light"가 붙으면 이 변수들이 적용됨
----------------------------------------------------------- */
[data-theme="light"] {
  --background-color: #ffffff;          /* 배경: 흰색 */
  --sidebar-bg-color: #f7f7f8;          /* 사이드바: 밝은 회색 */
  --chat-background-color: #ffffff;     /* 채팅창: 흰색 */
  --user-message-bg: #e0e0e0;           /* 사용자 말풍선 */
  --bot-message-bg: transparent;
  --input-background-color: #ffffff;    /* 입력창 */
  --text-color: #333333;                /* 글자: 검정 */
  --text-secondary-color: #666666;      /* 보조 글자 */
  --border-color: #e5e5e5;              /* 테두리 */
  --button-color: #e0e0e0;
  --button-color: #1b1b1b;
  --button-hover-color: #d0d0d0;
  --button-hover-color: #6a6a6a;

  /* 프롬프트 카드용 변수 (라이트 모드) */
  --card-bg-normal: #f9f9f9;
  --card-border-color: #e0e0e0;

  /* + 버튼 */
  --chat-btn-color: #1a1a1a;
  --chat-btn-bg-color: #f5f5f5;
  --chat-btn-bg-hover-color: rgb(226, 226, 226);

  /* 팝업(파일첨부) */
  --chat-btn-pop-bg-color: #ffffff;
  --chat-btn-pop-border-color: #bdbdbd;
  --chat-btn-pop-color: #0f0f0f;
  --chat-btn-pop-hover-color: #f0f0f0;

  /* 메시지 */
  --message-color: #333;
  --message-hover-color: #161616;
  --message-box-bg-hover-color:#eeeeee;
}

/* -----------------------------------------------------------
   기본 레이아웃
----------------------------------------------------------- */
body {
  font-family: sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

.app-layout {
  display: flex;
  height: 100%;
  transition: padding-left 0.3s ease;
}

.sidebar-menu a:nth-child(n+2){
  opacity: .7;
  pointer-events: none;
}

/* -----------------------------------------------------------
   사이드바
----------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--sidebar-bg-color);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
  box-sizing: border-box;
  transition: width 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.app-layout.sidebar-collapsed .sidebar {
  width: var(--sidebar-width-collapsed);
}

.app-layout.sidebar-collapsed .sidebar-header {
  justify-content: center;
}

.app-layout.sidebar-collapsed .gpt-icon {
  display: none;
}

.app-layout.sidebar-collapsed .menu-item {
  justify-content: center;
}

.app-layout.sidebar-collapsed .menu-item span {
  display: none;
}

.app-layout.sidebar-collapsed .chat-history {
  display: none;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-shrink: 0;
}

.gpt-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: bold;
  color: var(--text-color);
  text-decoration: none;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary-color);
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background-color 0.2s, color 0.2s;
}

.icon-btn:hover {
  background-color: var(--input-background-color);
  color: var(--text-color);
}

/* -----------------------------------------------------------
   사이드바 메뉴 & 히스토리
----------------------------------------------------------- */
.sidebar-menu {
  margin-bottom: 1.5rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 8px;
  color: var(--text-secondary-color);
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color 0.2s, color 0.2s;
}

.menu-item:hover {
  background-color: var(--input-background-color);
  color: var(--text-color);
}

.menu-item svg {
  width: 20px;
  height: 20px;
}

.chat-history {
  flex-grow: 1;
  overflow-y: auto;
}

.chat-history::-webkit-scrollbar {
  width: 6px;
}

.chat-history::-webkit-scrollbar-track {
  background: var(--sidebar-bg-color);
}

.chat-history::-webkit-scrollbar-thumb {
  background-color: var(--border-color);
  border-radius: 3px;
}

.chat-history h3 {
  position: sticky;
  top: 0;
  background: var(--sidebar-bg-color);
  z-index: 1;
  padding: 1rem 0.75rem 0.5rem 0.75rem;
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.chat-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.history-item a {
  display: block;
  padding: 0.75rem;
  border-radius: 8px;
  color: var(--text-color);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.2s;
}

.history-item.active{
  background-color: var(--history-active-text-color-accent);
}

.history-item:not(.active) a:hover {
  background-color: var(--input-background-color);
}

/* -----------------------------------------------------------
   채팅 영역
----------------------------------------------------------- */
.chat-container {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  background-color: var(--background-color);
}

.main-content {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  box-sizing: border-box;
  overflow: auto;
}

.chat-container.is-empty .main-content {
  justify-content: center;
  align-items: center;
}

.empty-state-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 1rem;
  color: var(--text-color);
}

.empty-state-container h2 {
  font-size: 1.5rem;
  margin: 0;
}

.chat-container.is-empty .chat-messages {
  display: none;
}

.chat-container:not(.is-empty) .empty-state-container {
  display: none;
}

.chat-header {
  padding: 1rem 0;
  flex-shrink: 0;
  color: var(--text-color);
}

.chat-header h1 {
  margin: 0;
  font-size: 1.2rem;
  text-align: left;
}

.chat-messages {
  flex-grow: 1;
  overflow-y: auto;
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chat-messages::-webkit-scrollbar {
  width: 12px;
}

.chat-messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.25);
  background: var(--scrollbar-color);
  border-radius: 8px;
}

#chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

.message {
  display: flex;
  gap: 0.5rem;
  line-height: 1.6;
  max-width: 90%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  margin-right: 1rem;
}

.message-content {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}

.message.user .message-content {
  background-color: var(--user-message-bg);
}

.message.bot .message-content {
  background-color: var(--bot-message-bg);
    color: var(--bot-message-bg);
    color: var(--message-color);
}

/* -----------------------------------------------------------
   [NEW] 파일 첨부 카드 & 이미지 스타일 (채팅 내)
----------------------------------------------------------- */
.file-attachment-card {
    display: flex;
    align-items: center;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 10px;
    padding: 10px;
    margin-bottom: 8px;
    text-decoration: none;
    color: #e0e0e0;
    max-width: 300px;
    transition: background-color 0.2s;
}
.file-attachment-card:hover {
    background: #3a3a3a;
}

/* PDF 스타일 */
.file-attachment-card.pdf .file-icon {
    font-size: 24px;
    margin-right: 10px;
}
.file-attachment-card.pdf .file-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.file-attachment-card.pdf .file-name {
    font-size: 14px;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-attachment-card.pdf .file-label {
    font-size: 11px;
    color: #aaa;
}

/* 이미지 스타일 (프리뷰) */
.file-attachment-card.image {
    padding: 0;
    overflow: hidden;
    border: none;
    background: transparent;
}
.file-attachment-card.image .attachment-preview {
    width: 200px;
    height: auto;
    border-radius: 10px;
    border: 1px solid #444;
    display: block;
}

/* 봇 생성/수정 이미지 */
.chat-image-content {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 8px;
    border: 1px solid #444;
    transition: transform 0.2s;
}
.chat-image-content:hover {
    transform: scale(1.02);
    cursor: pointer;
}

/* 사용자 메시지 내부 텍스트와의 간격 */
.text-content {
    margin-top: 6px;
    color: var(--bot-message-bg);
    color: var(--message-color);
}

/* -----------------------------------------------------------
   입력 영역
----------------------------------------------------------- */
.chat-input-form {
  padding: 1.5rem 0;
  flex-shrink: 0;
  width: 100%;
  max-width: 1000px;
  box-sizing: border-box;
}

.chat-container.is-empty .chat-input-form {
  padding-top: 0;
  margin-top: 2rem;
  max-width: 700px;
  width: calc(100% - 2rem);
}

.input-wrapper {
  display: flex;
  background-color: var(--input-background-color);
  border-radius: 26px;
  border: 1px solid var(--border-color);
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  overflow-y: auto;
  resize: none;
  background: transparent;
  border: none;
  color: var(--text-color);
  line-height: 24px;
  padding: 6px 0;
  scrollbar-width: none;
  font-size: 1rem;
  font-family: sans-serif;
}

.chat-input::-webkit-scrollbar {
  display: none;
}

.chat-input:focus {
  outline: none;
}

/* -----------------------------------------------------------
   첨부 배지 영역
----------------------------------------------------------- */
.attachment-area {
  width: 100%;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  /* + 버튼 위치와 얼추 맞게 왼쪽 여백 추가 */
  padding: 0 0.5rem 0.5rem 0.5rem; 
  box-sizing: border-box;
  min-height: 0; /* 내용이 없으면 높이 0 */
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: #2c2c2c;
  border-radius: 999px;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  color: #eee;
}

/* PDF chip */
.attachment-chip.pdf {
  background: #402020;
}

/* Image chip */
.attachment-chip.image {
  background: #203040;
}

/* 이미지 썸네일 */
.attachment-thumb {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: cover;
}

.attachment-remove {
  border: none;
  background: transparent;
  color: #bbb;
  cursor: pointer;
  font-size: 1rem;
  padding: 0;
}

/* 드래그 영역 */
.chat-drop-active {
  border: 2px dashed #4a90e2 !important;
  background: #e8f3ff !important;
}

/* -----------------------------------------------------------
   + 버튼 / 첨부 팝업
----------------------------------------------------------- */
.plus-btn {
  width: 36px;
  height: 36px;
  margin-right: 8px;
  font-size: 20px;
  border-radius: 50%;
  background-color: var(--chat-btn-bg-color);
  color: var(--chat-btn-color);
  border: none;
  cursor: pointer;
  transition: 0.2s;
}

.plus-btn:hover {
  background-color: var(--chat-btn-bg-hover-color);
}

.plus-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.attach-menu-wrapper {
  position: relative;
}

.attach-popup {
  position: absolute;
  bottom: 45px;
  left: 0;
  background-color: var(--chat-btn-pop-bg-color);
  border: 1px solid var(--chat-btn-pop-border-color);
  
  border-radius: 8px;
  padding: 8px 0;
  display: none;
  flex-direction: column;
  width: 150px;
  z-index: 50;
}
/* --chat-btn-color: #1a1a1a;
--chat-btn-bg-color: #cecece;
--chat-btn-bg-hover-color: rgb(175, 175, 175); */

.attach-popup.show {
  display: flex;
}

.attach-item {
  padding: 10px 12px;
  cursor: pointer;
  color: var(--chat-btn-pop-color);
  background-color: var(--chat-btn-pop-bg-color);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.attach-item:hover {
  background-color: var(--chat-btn-pop-hover-color);
}

/* -----------------------------------------------------------
   마이크 버튼 & 전송 버튼
----------------------------------------------------------- */
.mic-btn {
  width: 40px;
  height: 40px;
  margin-right: 10px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  transition: background-color 0.2s;
}

.mic-btn:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.mic-btn svg {
  width: 18px;
  height: 18px;
  stroke: #ccc;
}

.send-button {
  width: 36px;
  height: 36px;
  border: none;
  background-color: var(--button-color);
  color: var(--text-color);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.send-button:hover:not(:disabled) {
  background-color: var(--button-hover-color);
}

.send-button:disabled {
  cursor: default;
}

.send-button svg {
  width: 20px;
  height: 20px;
}

/* -----------------------------------------------------------
   로딩 표시
----------------------------------------------------------- */
.loading-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.loading-label {
  font-size: 0.85rem;
  color: var(--text-secondary-color);
}

.loading-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.loading-dots span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-secondary-color);
  animation: blink 1.4s infinite both;
}

.loading-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.loading-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0% {
    opacity: 0.2;
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0.2;
  }
}

/* -----------------------------------------------------------
   드래그 & 드롭 오버레이
----------------------------------------------------------- */
.drop-overlay {
  position: fixed;
  inset: 0;
  background: var(--chat-background-color);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.drop-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.drop-overlay-inner {
  text-align: center;
  padding: 2.5rem 3rem;
  border-radius: 1.5rem;
  background: #111;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.drop-icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.drop-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.drop-subtitle {
  font-size: 0.9rem;
  color: #aaa;
}

/* -----------------------------------------------------------
   하단 안내 / 푸터
----------------------------------------------------------- */
.disclaimer-text {
  font-size: 0.8rem;
  color: var(--text-secondary-color);
  padding: 1rem;
  background: #fafafa;
  border-radius: 8px;
  line-height: 1.4;
  text-align: center;

  margin: 0 auto;       /* 가운데 정렬 */
  text-align: left;     /* 내부 div는 기본 left 유지 */
  width: fit-content;   /* 내용만큼만 너비 */
  max-width: 90%;       /* 너무 확장 방지 */
}

/* 입력창이 커짐 */
.chat-container .disclaimer-text {
}
/* 입력창이 작음 */
.chat-container.is-empty .disclaimer-text {
}

/* guide와 첫 문장을 한 줄에 유지 */
.disclaimer-text > div {
  margin: 6px 0;
}

/* 라벨 */
.disclaimer-text span.guide {
  background: #181818;
  color: #fff;
  padding: 3px 6px;
  font-size: 0.7rem;
  border-radius: 4px;
  margin-right: 6px;   /* ← 라벨 오른쪽 여백 */
  vertical-align: top; /* 줄 상단 정렬 */
  white-space: nowrap; /* 줄바꿈 방지 */
}

.disclaimer-text span.guide.accent{
  background: #c53030;
}

/* br 이후 텍스트만 들여쓰기 */
.disclaimer-text .after-br {
  display: block;
  padding-left: 2.3rem;
  margin-top: 4px;
  line-height: 1.5;
}


.sidebar-footer {
  margin-top: auto;
  padding: 1rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-top: 1px solid var(--border-color);
}

.footer-icon {
  width: 32px;
  height: 32px;
}

.footer-text {
  display: flex;
  flex-direction: column;
}

.footer-title {
  font-size: 0.9rem;
  color: var(--text-color);
}

.footer-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary-color);
}

.app-layout.sidebar-collapsed .sidebar-footer {
  justify-content: center;
  padding: 1rem 0;
}

.app-layout.sidebar-collapsed .footer-text {
  display: none;
}

.app-layout .sidebar-open{
  display: block;
}
.app-layout .sidebar-open{
  display: none;
}

/* -----------------------------------------------------------
   코드 블록 UI + 복사 버튼
----------------------------------------------------------- */
.code-block-wrapper {
  background: #111;
  border-radius: 10px;
  border: 1px solid #333;
  margin: 0.75rem 0;
  overflow: hidden;
  font-size: 0.9rem;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border-bottom: 1px solid #333;
  background: #181818;
}

.code-lang-label {
  font-size: 0.8rem;
  color: #bbb;
}

.copy-code-btn {
  border: none;
  border-radius: 6px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  background: #333;
  color: #ddd;
  cursor: pointer;
}

.copy-code-btn:hover {
  background: #444;
}

.code-block-body {
  padding: 0.75rem;
  overflow-x: auto;
}

.code-block-body pre {
  margin: 0;
  background: transparent !important;
}

/* -----------------------------------------------------------
   관련된 추천 UI
----------------------------------------------------------- */
.related-box {
  margin-top: 0.75rem;
  padding: 4px;
  background: var(--chat-background-color);
  border-radius: 10px;
}

.related-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.related-list li {
  padding: 8px 10px;
  margin-bottom: 6px;
  border-radius: 6px;
  cursor: pointer;
  background: var(--chat-background-color);
  border: 1px solid rgb(211 206 206 / 80%);
  transition: 0.15s;
  font-size: 0.9rem;
}

.related-list li:hover {
  color: #d0d0d0;
  color: var(--message-hover-color);
  background: #222;
  background: var(--message-box-bg-hover-color);
}

/* 비활성화된 추천 항목 (다음 요청 이후) */
.related-list li.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

/* (예전 PDF 전용 표시 박스 – 필요시 유지 / JS에서 사용 시) */
.attached-file-box.hidden{
    display: none;
}

/*  전송 중지 버튼 흰색으로 */
#send-button.stop-mode svg rect {
    fill: #ffffff;   /* 흰색 */
}

/* 이벤트 베너 */
#event{
  position: fixed;
  right: 1%;
  bottom: 2%;
}
#event img {
  width: 300px; /* 원하는 크기로 조절 */
  height: auto;
}

/* -----------------------------------------------------------
   반응형
----------------------------------------------------------- */
/* 1500px 이하 */
@media screen and (max-width: 1500px) {
  #event{
    bottom: auto;
    top: 1%;
    right: 1%;
  }
  #event img {
    width: 150px;
    content: url(../img/event_btn_s.png);
  }
}
@media screen and (max-width: 1400px) {
  #event{
  }
  #event img {
    /* content: url(../img/event_btn_s.png); */
    /* width: 160px; */
  }
}
@media screen and (max-width: 780px) {
  #event{
    display: none;
  }
}




@media (max-width: 768px) {
  .sidebar {
    /* position: absolute;
    z-index: 10;
    transform: translateX(-100%); */
  }

  .app-layout.sidebar-collapsed .sidebar {
    /* transform: translateX(0);
    width: var(--sidebar-width);
    padding: 1rem;
    opacity: 1; */
  }

  .main-content {
    padding: 0 1rem;
  }

  .chat-container.is-empty .main-content {
    padding-bottom: 0;
  }

  .chat-input-form {
    max-width: unset;
  }

  .chat-container.is-empty .chat-input-form {
    width: calc(100% - 2rem);
    max-width: unset;
  }

  .attachment-area {
    padding-left: 0.3rem;
  }

  .message {
    max-width: 100%;
  }
}