/* 쇼핑몰 챗봇 기본 스타일 */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f5f5;
  color: #333;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  background: #1a1a2e;
  color: white;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.navbar-brand { font-size: 18px; font-weight: 700; }
.navbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.badge-admin { background: #e94560; padding: 2px 8px; border-radius: 10px; font-size: 11px; }
.btn-logout { background: none; border: 1px solid rgba(255,255,255,0.3); color: white; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 13px; }

.container { flex: 1; overflow: hidden; }

/* 채팅 레이아웃 */
.chat-layout { display: flex; height: 100%; }
.chat-sidebar { width: 280px; background: white; border-right: 1px solid #e0e0e0; display: flex; flex-direction: column; }
.sidebar-header { padding: 16px; border-bottom: 1px solid #e0e0e0; }
.sidebar-header h2 { font-size: 16px; margin-bottom: 12px; }
.chat-list { flex: 1; overflow-y: auto; }
.chat-item { display: block; padding: 12px 16px; border-bottom: 1px solid #f0f0f0; text-decoration: none; color: #333; transition: background 0.15s; }
.chat-item:hover, .chat-item.active { background: #f0f7ff; }
.chat-item-title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-date { font-size: 11px; color: #999; margin-top: 4px; }

/* 메인 채팅 영역 */
.chat-main { flex: 1; display: flex; flex-direction: column; }
.chat-header { padding: 16px 24px; background: white; border-bottom: 1px solid #e0e0e0; }
.chat-header h2 { font-size: 16px; }

.messages-container { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* 메시지 버블 */
.message { display: flex; gap: 10px; max-width: 80%; }
.message-user { align-self: flex-end; flex-direction: row-reverse; }
.message-assistant { align-self: flex-start; }
.message-avatar { width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.message-bubble { padding: 10px 16px; border-radius: 16px; line-height: 1.5; font-size: 14px; word-break: break-word; }
.message-user .message-bubble { background: #0084ff; color: white; border-bottom-right-radius: 4px; }
.message-assistant .message-bubble { background: white; border: 1px solid #e0e0e0; border-bottom-left-radius: 4px; }
.message-error .message-bubble { background: #fff3f3; border: 1px solid #ffcdd2; color: #c62828; }

/* 커서 깜빡임 애니메이션 */
.cursor-blink { animation: blink 1s step-end infinite; color: #0084ff; }
@keyframes blink { 50% { opacity: 0; } }

/* 타이핑 인디케이터 */
.streaming-indicator { padding: 8px; display: flex; align-items: center; }
.typing-dots span { display: inline-block; width: 8px; height: 8px; margin: 0 2px; background: #999; border-radius: 50%; animation: typing 1.4s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-6px); } }

/* 메시지 입력 */
.message-input-container { padding: 16px 24px; background: white; border-top: 1px solid #e0e0e0; }
.message-form { display: flex; gap: 8px; }
.input-message { flex: 1; padding: 10px 16px; border: 1px solid #ddd; border-radius: 24px; font-size: 14px; outline: none; }
.input-message:focus { border-color: #0084ff; }

/* 버튼 */
.btn { display: inline-block; padding: 8px 16px; border-radius: 6px; border: none; cursor: pointer; font-size: 14px; text-decoration: none; text-align: center; }
.btn-primary { background: #0084ff; color: white; }
.btn-send { background: #0084ff; color: white; border-radius: 24px; padding: 10px 20px; }
.btn-kakao { background: #fee500; color: #3c1e1e; font-weight: 600; padding: 12px 32px; border-radius: 8px; font-size: 16px; }
.btn-dev { background: #333; color: white; padding: 12px 32px; border-radius: 8px; font-size: 16px; }

/* 로그인 */
.login-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; gap: 24px; }
.login-container h1 { font-size: 32px; }
.login-container p { color: #666; font-size: 16px; }
.login-buttons { display: flex; flex-direction: column; gap: 12px; }

/* 빈 상태 */
.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #999; }
.empty-state h2 { font-size: 24px; margin-bottom: 8px; }

/* 새 대화 입력 */
.new-chat-form { display: flex; gap: 8px; }
.input-new-chat { flex: 1; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 13px; }

/* 알림 */
.alert { background: #fff3cd; border: 1px solid #ffc107; padding: 12px 24px; text-align: center; font-size: 14px; }

/* 성공 알림 */
.notice { background: #d4edda; border: 1px solid #28a745; padding: 12px 24px; text-align: center; font-size: 14px; color: #155724; }

/* 관리자 버튼 (네비바) */
.btn-admin { background: #e94560; color: white; padding: 4px 12px; border-radius: 4px; text-decoration: none; font-size: 13px; font-weight: 600; }
.btn-admin:hover { background: #c73650; }

/* 관리자 페이지 레이아웃 */
.admin-layout { display: flex; height: 100%; }
.admin-sidebar { width: 240px; background: #1a1a2e; display: flex; flex-direction: column; }
.admin-sidebar .sidebar-header { padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.admin-sidebar .sidebar-header h2 { color: white; font-size: 16px; }
.admin-nav { padding: 8px 0; }
.admin-nav-item { display: block; padding: 10px 16px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 14px; transition: all 0.15s; }
.admin-nav-item:hover { background: rgba(255,255,255,0.1); color: white; }
.admin-nav-item.active { background: rgba(233,69,96,0.2); color: #e94560; border-left: 3px solid #e94560; }

/* 관리자 메인 컨텐츠 */
.admin-main { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.admin-header { padding: 24px 32px 16px; background: white; border-bottom: 1px solid #e0e0e0; }
.admin-header h2 { font-size: 18px; margin-bottom: 4px; }
.admin-description { color: #666; font-size: 13px; }
.admin-content { padding: 24px 32px; flex: 1; }

/* 상태 카드 */
.status-cards { display: flex; gap: 16px; margin-bottom: 24px; }
.status-card { flex: 1; background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; }
.status-card h3 { font-size: 13px; color: #666; margin-bottom: 8px; }
.status-value { font-size: 20px; font-weight: 700; }
.status-ok { color: #28a745; }
.status-error { color: #dc3545; }

/* 관리자 테이블 */
.admin-info { background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; }
.admin-info h3 { font-size: 15px; margin-bottom: 12px; }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table td { padding: 8px 12px; border-bottom: 1px solid #f0f0f0; font-size: 14px; }
.admin-table td:first-child { color: #666; width: 180px; }

/* 관리자 명령 폼 */
.admin-command-form { margin-bottom: 24px; }
.command-input-group { display: flex; gap: 8px; }
.input-command { flex: 1; padding: 12px 16px; border: 2px solid #ddd; border-radius: 8px; font-size: 14px; outline: none; }
.input-command:focus { border-color: #e94560; }
.command-examples { background: #f8f9fa; border-radius: 8px; padding: 16px 20px; margin-bottom: 24px; }
.command-examples h4 { font-size: 13px; color: #666; margin-bottom: 8px; }
.command-examples ul { list-style: none; }
.command-examples li { padding: 4px 0; font-size: 13px; }
.command-examples code { background: #e9ecef; padding: 2px 6px; border-radius: 3px; font-size: 12px; }

/* 실행 결과 */
.command-results, .ingest-result { background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 20px; margin-top: 16px; }
.command-results h3, .ingest-result h3 { font-size: 15px; margin-bottom: 12px; }
.result-box { background: #f8f9fa; border-radius: 6px; padding: 16px; }
.result-box pre { font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.result-row { padding: 6px 0; border-bottom: 1px solid #e9ecef; font-size: 13px; }
.result-row strong { color: #495057; }

/* 학습 데이터 폼 */
.ingest-form { background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #333; margin-bottom: 6px; }
.input-select { width: 100%; padding: 10px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none; }
.input-textarea { width: 100%; padding: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none; resize: vertical; font-family: inherit; }
.input-textarea:focus, .input-select:focus { border-color: #0084ff; }
.btn-lg { padding: 12px 32px; font-size: 15px; }
.btn-outline { background: white; border: 1px solid #0084ff; color: #0084ff; text-decoration: none; display: inline-block; }
.btn-outline:hover { background: #f0f7ff; }


/* 학습 페이지 섹션 구분 */
.ingest-section { background: white; border: 1px solid #e0e0e0; border-radius: 8px; padding: 24px; margin-bottom: 20px; }
.ingest-section h3 { font-size: 16px; font-weight: 700; color: #333; margin-bottom: 8px; }
.section-description { font-size: 13px; color: #666; line-height: 1.6; margin-bottom: 16px; }
.section-divider { border: none; border-top: 1px solid #e9ecef; margin: 24px 0; }


/* 채널톡 수집 진행 상태 */
.ingest-status { background: #f8f9fa; border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px 20px; }
.status-indicator { display: flex; align-items: center; gap: 10px; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; color: white; background: #6c757d; }
.status-badge.status-collecting { background: #0d6efd; }
.status-badge.status-processing { background: #fd7e14; }
.status-badge.status-done { background: #198754; }
.status-badge.status-error { background: #dc3545; }
.status-progress { font-size: 13px; color: #555; }

/* 페르소나 설정 폼 */
.persona-form { max-width: 800px; }
.persona-section { background: #fff; border: 1px solid #e9ecef; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.persona-section h3 { font-size: 16px; margin-bottom: 16px; color: #333; border-bottom: 1px solid #f0f0f0; padding-bottom: 8px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 4px; }
.input-field { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; transition: border-color 0.2s; }
.input-field:focus { border-color: #4a6cf7; outline: none; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }
.input-textarea { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; resize: vertical; font-family: inherit; }
.input-textarea:focus { border-color: #4a6cf7; outline: none; box-shadow: 0 0 0 3px rgba(74,108,247,0.1); }
.form-hint { font-size: 11px; color: #999; margin-top: 2px; display: block; }
.few-shot-row { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 6px; padding: 12px; margin-bottom: 10px; }
.few-shot-pair { display: flex; flex-direction: column; gap: 8px; }
.btn-danger { background: #dc3545; color: white; border: none; padding: 4px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; align-self: flex-end; }
.btn-danger:hover { background: #c82333; }
.btn-sm { font-size: 12px; padding: 4px 12px; }
.btn-lg { font-size: 15px; padding: 10px 24px; }
.persona-actions { display: flex; gap: 12px; align-items: center; margin-top: 20px; }
.save-status { font-size: 13px; font-weight: 500; }
.save-status.status-done { color: #198754; }
.save-status.status-error { color: #dc3545; }
.save-status.status-running { color: #0d6efd; }
.status-badge.status-running { background: #0d6efd; }

/* === 마크다운 렌더링 === */
.markdown-body { line-height: 1.7; word-break: break-word; }
.markdown-body h1 { font-size: 1.5em; font-weight: 700; margin: 16px 0 8px; }
.markdown-body h2 { font-size: 1.3em; font-weight: 700; margin: 14px 0 6px; }
.markdown-body h3 { font-size: 1.15em; font-weight: 700; margin: 12px 0 6px; }
.markdown-body p { margin: 6px 0; }
.markdown-body ul, .markdown-body ol { padding-left: 20px; margin: 6px 0; }
.markdown-body li { margin: 3px 0; }
.markdown-body code { background: #f0f0f0; padding: 2px 6px; border-radius: 3px; font-size: 0.9em; font-family: 'SFMono-Regular', Consolas, monospace; }
.markdown-body pre { background: #1e1e1e; color: #d4d4d4; padding: 14px; border-radius: 8px; overflow-x: auto; margin: 10px 0; }
.markdown-body pre code { background: none; padding: 0; color: inherit; font-size: 0.85em; }
.markdown-body blockquote { border-left: 3px solid #0084ff; padding: 6px 14px; margin: 8px 0; background: #f8f9fa; color: #555; }
.markdown-body a { color: #0084ff; text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.markdown-body th, .markdown-body td { border: 1px solid #ddd; padding: 6px 10px; font-size: 13px; }
.markdown-body th { background: #f5f5f5; font-weight: 600; }
.markdown-body hr { border: none; border-top: 1px solid #e0e0e0; margin: 12px 0; }
.markdown-body strong { font-weight: 700; }
.markdown-body em { font-style: italic; }

/* 마크다운 내 이미지/동영상 */
.markdown-body img.chat-image, .chat-image { max-width: 280px; border-radius: 8px; margin: 4px 0; cursor: pointer; }
.markdown-body video.chat-video, .chat-video { max-width: 320px; border-radius: 8px; margin: 4px 0; }

/* 메시지 첨부파일 컬테이너 */
.message-attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.message-attachments img { max-width: 200px; max-height: 200px; border-radius: 8px; object-fit: cover; }
.message-attachments video { max-width: 260px; border-radius: 8px; }

/* 학습 미디어 강제 표시 영역 (AI 메시지 하단) */
.knowledge-media-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0,0,0,0.08); }
.knowledge-media-attachments img.knowledge-media { max-width: 300px; max-height: 280px; border-radius: 10px; object-fit: cover; cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.knowledge-media-attachments img.knowledge-media:hover { transform: scale(1.03); box-shadow: 0 3px 12px rgba(0,0,0,0.15); }
.knowledge-media-attachments video.knowledge-media { max-width: 360px; border-radius: 10px; box-shadow: 0 1px 4px rgba(0,0,0,0.1); }
.knowledge-media-link { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; background: #f0f7ff; border: 1px solid #d0e3f7; border-radius: 8px; color: #1a73e8; text-decoration: none; font-size: 13px; font-weight: 500; transition: background 0.15s; }
.knowledge-media-link:hover { background: #dceefb; text-decoration: none; }
.knowledge-media-link span { text-decoration: underline; }

/* === 파일 업로드 UI === */
.btn-attach { background: none; border: none; font-size: 20px; cursor: pointer; padding: 6px 8px; border-radius: 50%; transition: background 0.15s; flex-shrink: 0; }
.btn-attach:hover { background: #f0f0f0; }

/* 미리보기 영역 */
.attachment-preview { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0; }
.preview-item { position: relative; width: 72px; height: 72px; border-radius: 8px; overflow: hidden; border: 1px solid #e0e0e0; background: #f5f5f5; }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-video-label { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; font-size: 11px; padding: 4px; text-align: center; word-break: break-all; color: #666; }
.preview-remove { position: absolute; top: 2px; right: 2px; background: rgba(0,0,0,0.6); color: white; border: none; border-radius: 50%; width: 20px; height: 20px; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; }
.preview-remove:hover { background: rgba(220,53,69,0.9); }

/* 드래그 오버 스타일 */
.chat-main.drag-over { position: relative; }
.chat-main.drag-over::after { content: '📎 파일을 여기에 놓으세요'; position: absolute; inset: 0; background: rgba(0, 132, 255, 0.08); border: 2px dashed #0084ff; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 600; color: #0084ff; z-index: 10; pointer-events: none; border-radius: 8px; }

/* === 어시스턴트 메시지 버블 너비 === */
.message-assistant .message-bubble { max-width: 100%; }
/* 툴팁 스타일 */
.tooltip-container {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
  margin-left: 6px;
}
.tooltip-icon {
  background: #f0f0f0;
  color: #666;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  font-size: 12px;
  font-weight: bold;
}
.tooltip-content {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #333;
  color: #fff;
  text-align: left;
  padding: 12px 16px;
  border-radius: 8px;
  z-index: 100;
  width: max-content;
  max-width: 400px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: opacity 0.2s, visibility 0.2s;
  margin-bottom: 8px;
  font-weight: normal;
}
.tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: #333 transparent transparent transparent;
}
.tooltip-container:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
}
.tooltip-content ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}
.tooltip-content li {
  margin-bottom: 4px;
}
.tooltip-content strong {
  color: #4CAF50;
}

/* === 드래그앤드롭 파일 업로드 === */
.drop-zone {
  border: 2px dashed #ccc;
  border-radius: 12px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s;
  background: #fafbfc;
  margin-bottom: 16px;
}
.drop-zone:hover {
  border-color: #4CAF50;
  background: #f0faf0;
}
.drop-zone.drag-over {
  border-color: #4CAF50;
  background: #e8f5e9;
  box-shadow: inset 0 0 0 2px rgba(76, 175, 80, 0.15);
}
.drop-zone-content p {
  margin: 0;
}
