/* =========================================
   사주ON — 채팅 전용 CSS
   ========================================= */

body.chat-page {
  overflow: hidden;
  height: 100vh;
}

/* ===== 레이아웃 ===== */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
  background: var(--bg-base);
}

/* ===== 사이드바 ===== */
.chat-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s ease;
}
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.sidebar-close {
  color: var(--text-muted);
  font-size: 1rem;
  display: none;
}
.sidebar-close:hover { color: var(--text-dark); }
.sidebar-inner {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0;
}
.sidebar-group-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 14px 18px 6px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  cursor: pointer;
  transition: background 0.18s;
  border-radius: 0;
}
.sidebar-item:hover { background: var(--bg-base); }
.sidebar-item.active { background: var(--primary-pale); }
.sidebar-item-icon { font-size: 1.05rem; flex-shrink: 0; }
.sidebar-item-name { font-size: 0.88rem; font-weight: 500; color: var(--text-body); flex: 1; }
.sidebar-item.active .sidebar-item-name { color: var(--primary); font-weight: 700; }
.sidebar-item-pt { font-size: 0.72rem; color: var(--text-light); flex-shrink: 0; }

/* ===== 채팅 메인 ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-menu-btn, .chat-reset-btn {
  color: var(--text-muted);
  font-size: 1rem;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
  display: none;
}
.chat-menu-btn:hover, .chat-reset-btn:hover {
  background: var(--bg-base);
  color: var(--primary);
}
.chat-current-cat {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}
.cat-icon-sm { font-size: 1.1rem; }
#catNameLabel { font-weight: 700; font-size: 0.95rem; color: var(--text-dark); }
.chat-reset-btn { display: flex; }

/* ===== 메시지 영역 ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* 환영 메시지 */
.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  max-width: 500px;
  margin: 0 auto;
}
.welcome-icon { font-size: 3.5rem; margin-bottom: 16px; }
.welcome-title { font-size: 1.4rem; font-weight: 800; color: var(--text-dark); margin-bottom: 10px; }
.welcome-sub { font-size: 0.9rem; color: var(--text-muted); line-height: 1.7; margin-bottom: 24px; }
.welcome-examples { display: flex; flex-direction: column; gap: 8px; }
.welcome-example-btn {
  background: var(--bg-base);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.88rem;
  color: var(--text-body);
  transition: all 0.2s;
  cursor: pointer;
}
.welcome-example-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-pale); }

/* 메시지 버블 */
.msg-row {
  display: flex;
  gap: 12px;
  max-width: 820px;
  animation: msgIn 0.3s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.msg-row--user { flex-direction: row-reverse; align-self: flex-end; }
.msg-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.msg-row--ai .msg-avatar { background: var(--primary); }
.msg-row--user .msg-avatar { background: var(--accent); font-size: 0.85rem; font-weight: 700; color: var(--text-dark); }
.msg-content { flex: 1; min-width: 0; }
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 0.75rem;
  color: var(--text-light);
}
.msg-row--user .msg-meta { flex-direction: row-reverse; }
.msg-name { font-weight: 600; color: var(--text-muted); }
.msg-cost-badge {
  background: var(--accent-pale);
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}
.msg-bubble {
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 0 var(--radius-md) var(--radius-md) var(--radius-md);
  padding: 14px 18px;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text-body);
  max-width: 640px;
  word-break: break-word;
}
.msg-row--user .msg-bubble {
  background: var(--primary);
  color: var(--white);
  border-color: var(--primary);
  border-radius: var(--radius-md) 0 var(--radius-md) var(--radius-md);
}
.msg-bubble h4 { font-size: 0.95rem; font-weight: 700; margin-bottom: 8px; color: var(--primary); }
.msg-row--user .msg-bubble h4 { color: var(--accent-light); }
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble ul { padding-left: 18px; list-style: disc; }
.msg-bubble ul li { margin-bottom: 4px; }
.msg-bubble .highlight { color: var(--accent); font-weight: 700; }
.msg-row--user .msg-bubble .highlight { color: var(--accent-light); }

/* 타이핑 인디케이터 */
.typing-indicator .msg-bubble {
  padding: 12px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.typing-dot {
  width: 8px; height: 8px;
  background: var(--primary-light);
  border-radius: 50%;
  animation: typingBounce 1.2s ease infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-8px); } }

/* ===== 입력 영역 ===== */
.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-inner { max-width: 820px; margin: 0 auto; padding: 14px 20px; }
.chat-point-info {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-point-info i { color: var(--accent); }
.chat-point-info strong { color: var(--text-dark); }
.chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.chat-textarea {
  flex: 1;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 0.93rem;
  color: var(--text-dark);
  resize: none;
  max-height: 160px;
  overflow-y: auto;
  transition: border-color 0.2s;
  line-height: 1.5;
}
.chat-textarea:focus { border-color: var(--primary); outline: none; }
.chat-textarea::placeholder { color: var(--text-light); }
.chat-send-btn {
  width: 48px; height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: var(--white);
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: all 0.2s;
}
.chat-send-btn:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); transform: scale(1.05); }
.chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.chat-disclaimer { font-size: 0.72rem; color: var(--text-light); text-align: center; margin-top: 8px; }

/* ===== 모달 ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 40px 32px;
  text-align: center;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
.modal-icon { font-size: 3rem; margin-bottom: 14px; }
.modal h3 { font-size: 1.2rem; font-weight: 800; color: var(--text-dark); margin-bottom: 10px; }
.modal p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }
.modal p strong { color: var(--primary); }
.modal-actions { display: flex; flex-direction: column; gap: 10px; }
.modal-actions .btn { justify-content: center; }

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  body.chat-page { overflow: auto; }
  .chat-layout { flex-direction: column; height: auto; min-height: calc(100vh - var(--header-h)); }
  .chat-sidebar {
    position: fixed;
    left: 0; top: var(--header-h); bottom: 0;
    width: 280px;
    transform: translateX(-100%);
    z-index: 900;
    box-shadow: var(--shadow-lg);
  }
  .chat-sidebar.open { transform: translateX(0); }
  .sidebar-close { display: flex; }
  .chat-menu-btn { display: flex; }
  .chat-main { min-height: calc(100vh - var(--header-h)); }
  .chat-messages { padding: 20px 14px; }
  .msg-bubble { max-width: 85vw; }
  .chat-input-inner { padding: 10px 14px; }
}
