/* GPT 똑똑한 봇 - 챗봇 위젯 스타일 */
/* 2025 UX/UI Trends + Dark Mode + SF Pro 폰트 */

/* ===== 챗봇 버튼 (우측 하단) ===== */
.chat-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B35 0%, #FF8C42 100%);
  box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: all 0.2s ease;
}

.chat-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(255, 107, 53, 0.4);
}

.chat-button:active {
  transform: scale(0.95);
}



/* ===== 챗봇 창 ===== */
.chat-window {
  display: none;
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 400px;
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #000000;
  border: 1px solid #333333;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
  z-index: 9998;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s ease;
}

.chat-window.active {
  display: flex;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 헤더 ===== */
.chat-header {
  background: #000000;
  color: white;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 107, 53, 0.3);
}

.chat-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-button {
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  padding: 6px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-button:hover {
  background: rgba(255, 107, 53, 0.2);
}

.icon-button:active {
  transform: scale(0.95);
}

/* ===== 메시지 영역 ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #000000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ===== 메시지 ===== */
.message {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message.bot {
  align-items: flex-start;
}

.message.user {
  align-items: flex-end;
}

.message-avatar {
  display: none;
}

.message-content {
  max-width: 85%;
  padding: 10px 0;
  word-wrap: break-word;
  line-height: 1.6;
  font-size: 14px;
  color: #FFFFFF;
}

.message.bot .message-content {
  background: transparent;
  border: none;
  color: #CCCCCC;
}

.message.user .message-content {
  background: transparent;
  color: #FFFFFF;
  text-align: right;
}

/* ===== 초기 메뉴 ===== */
.initial-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.menu-button {
  padding: 12px 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid #222222;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  display: flex;
  gap: 10px;
  align-items: center;
}

.menu-button:hover {
  border-bottom-color: #FF6B35;
}

.menu-button:active {
  transform: translateY(0);
}

.menu-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.menu-text {
  flex: 1;
}

.menu-title {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: #FFFFFF;
}

.menu-desc {
  font-size: 12px;
  color: #888888;
  line-height: 1.4;
}

/* ===== 사용 횟수 표시 ===== */
.usage-counter {
  background: #1a1a1a;
  border-top: 1px solid #333333;
  padding: 10px 20px;
  text-align: center;
  font-size: 12px;
  color: #FF6B35;
  font-weight: 500;
}

.usage-counter.warning {
  background: #1a1a1a;
  border-top-color: #FF6B35;
  color: #FF6B35;
}

.usage-counter a {
  color: #FF6B35;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s;
}

.usage-counter a:hover {
  opacity: 0.8;
}

/* ===== 입력 영역 ===== */
.chat-input-area {
  padding: 16px;
  background: #000000;
  border-top: 1px solid #333333;
  display: flex;
  gap: 8px;
  align-items: center;
}

#chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #333333;
  border-radius: 8px;
  outline: none;
  font-size: 14px;
  background: #1a1a1a;
  color: white;
  transition: all 0.2s;
}

#chat-input:focus {
  border-color: #FF6B35;
  background: #1a1a1a;
}

#chat-input::placeholder {
  color: #666666;
}

.send-button {
  padding: 10px 20px;
  background: #FF6B35;
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
}

.send-button:hover {
  background: #FF8C42;
}

.send-button:active {
  transform: translateY(0);
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ===== 로딩 애니메이션 ===== */
.typing-indicator {
  display: inline-flex;
  gap: 6px;
  padding: 4px 0;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: #FF6B35;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-12px);
    opacity: 1;
  }
}

/* ===== Pulse 애니메이션 (음성 인식 중) ===== */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* ===== 모바일 대응 (360×780pt) ===== */
@media (max-width: 480px) {
  .chat-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
    right: 12px;
    bottom: 90px;
    border-radius: 20px;
  }

  .chat-button {
    right: 16px;
    bottom: 16px;
    width: 68px;
    height: 68px;
  }

  .chat-header {
    padding: 20px 16px;
  }

  .chat-header h3 {
    font-size: 16px;
    letter-spacing: -0.3px;
  }

  .chat-messages {
    padding: 24px 20px;
  }

  .message-avatar {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .message-content {
    font-size: 17px;
    padding: 18px 20px;
    max-width: 80%;
    line-height: 1.6;
  }

  .menu-button {
    padding: 22px 20px;
  }
  
  .menu-icon {
    font-size: 36px;
  }

  .menu-title {
    font-size: 19px;
  }

  .menu-desc {
    font-size: 15px;
    line-height: 1.5;
  }

  .chat-input-area {
    padding: 16px;
    gap: 10px;
  }

  #chat-input {
    padding: 14px 18px;
    font-size: 16px;
    min-height: 48px;
  }

  .send-button {
    padding: 14px 20px;
    font-size: 16px;
    white-space: nowrap;
  }

  .icon-button {
    width: 40px;
    height: 40px;
    font-size: 20px;
  }
  
  .usage-counter {
    padding: 16px 20px;
    font-size: 15px;
  }
}

@media (max-width: 768px) and (min-width: 481px) {
  .chat-window {
    width: 380px;
  }
}

/* ===== 추가: 스무스 스크롤 ===== */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== BEAI 타이포그래피 스타일 ===== */
.message-content.beai-style,
.message.bot .message-content {
  /* BEAI 스타일 기본 설정 */
  font-size: 14px;
  line-height: 1.65;
  letter-spacing: -0.02em;
  word-break: keep-all;
  overflow-wrap: break-word;
}

/* 강조 텍스트 (볼드) */
.message-content strong {
  font-weight: 700;
  color: #FFFFFF;
}

/* 이탤릭 (인용) */
.message-content em {
  font-style: italic;
  color: #CCCCCC;
  opacity: 0.9;
}

/* 링크 */
.message-content a {
  color: #FF6B35;
  text-decoration: none;
  transition: color 0.2s;
}

.message-content a:hover {
  color: #FF8C42;
  text-decoration: underline;
}

/* 문단 간격 (br 태그 후) */
.message-content br + br {
  display: block;
  content: "";
  margin-top: 8px;
}

/* 리스트 스타일 */
.message-content ul,
.message-content ol {
  margin: 8px 0;
  padding-left: 20px;
}

.message-content li {
  margin: 4px 0;
  line-height: 1.6;
}

/* 코드/인용 블록 */
.message-content code {
  background: #1a1a1a;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #FF8C42;
}

/* 구분선 */
.message-content hr {
  border: none;
  border-top: 1px solid #333333;
  margin: 12px 0;
}

/* 이모지 크기 조정 */
.message-content {
  /* 이모지가 너무 작지 않도록 */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Apple Color Emoji', 'Segoe UI Emoji', sans-serif;
}

/* 모바일에서 BEAI 스타일 최적화 */
@media (max-width: 480px) {
  .message-content.beai-style,
  .message.bot .message-content {
    font-size: 17px;
    line-height: 1.7;
    letter-spacing: -0.02em;
  }
  
  .message-content strong {
    font-weight: 700;
  }
  
  .message-content li {
    margin: 6px 0;
    line-height: 1.65;
  }
}

/* PC에서 최대 폭 제한 (가독성) */
@media (min-width: 769px) {
  .message.bot .message-content {
    max-width: 90%;
  }
}
