/* chat.css — 대화하기 화면.
 * 구 components/chat/*.tsx 의 Tailwind 클래스 이식.
 */

.chat-shell {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--background);
}

/* ── 빈 상태 ──────────────────────────────────────────────── */
.welcome-screen {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 16px;
  text-align: center;
  color: var(--muted-foreground);
}

.welcome-icon {
  font-size: 36px;
}

.welcome-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--foreground);
}

@media (min-width: 768px) {
  .welcome-screen { padding: 48px 24px; }
  .welcome-icon { font-size: 48px; }
}

/* ── 메시지 리스트 ────────────────────────────────────────── */
.message-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.message-list-inner {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 768px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 768px) {
  .message-list-inner { padding: 24px; }
}

.message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.message.is-user {
  justify-content: flex-end;
}

.message-avatar {
  display: flex;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--muted);
  color: var(--muted-foreground);
}
.message-avatar.is-error {
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  color: var(--destructive);
}

/* 어시스턴트 컬럼은 width:100% 를 더해 항상 max-width 까지 채운다 — 컨트롤 줄이
   응답 길이와 무관하게 일정 폭을 가져야 피드백 팝오버가 그 폭 기준으로 열린다.
   사용자 메시지는 우측 정렬 + 컨텐츠 폭이라 100% 를 주지 않는다. */
.message-column {
  display: flex;
  max-width: 75%;
  flex-direction: column;
  gap: 8px;
}
.message.is-assistant .message-column {
  width: 100%;
}

.bubble-body {
  font-size: var(--text-sm);
  word-break: break-word;
}
.bubble-body.is-plain {
  white-space: pre-wrap;
}

.bubble-body.is-user {
  border-radius: 16px;
  padding: 10px 16px;
  background: var(--primary);
  color: var(--primary-foreground);
}

.bubble-body.is-error {
  align-self: flex-start;
  border-radius: 16px;
  padding: 10px 16px;
  background: color-mix(in oklab, var(--destructive) 10%, transparent);
  color: var(--destructive);
}

/* 중지 안내 — 사용자가 의도한 중단이라 destructive 가 아닌 muted 톤 평문.
   레이아웃은 정상 응답과 동일(좌측 정렬). */
.bubble-body.is-stopped {
  align-self: flex-start;
  padding: 6px 4px;
  color: var(--muted-foreground);
}

/* 어시스턴트 정상 응답은 배경 없이 평문처럼 흐른다 — 타임라인·컨트롤 줄과
   좌측 정렬을 맞추기 위해 패딩/라운드를 제거(구버전 결정 그대로). */
.bubble-body.is-assistant {
  align-self: flex-start;
  padding: 6px 4px;
  color: var(--foreground);
}

/* ── 진행 타임라인 ────────────────────────────────────────── */
.progress-timeline {
  width: 100%;
  align-self: flex-start;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: color-mix(in oklab, var(--muted) 40%, transparent);
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.progress-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  border-radius: 16px;
  cursor: pointer;
  list-style: none;
  transition: background-color 0.15s;
}
.progress-summary::-webkit-details-marker { display: none; }
.progress-summary:hover {
  background: color-mix(in oklab, var(--muted) 60%, transparent);
}

.progress-summary-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
}

.progress-chevron {
  transition: transform 0.15s;
}
.progress-timeline[open] .progress-chevron {
  transform: rotate(180deg);
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
}

.progress-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.progress-marker {
  display: flex;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
}
.progress-item.is-live .progress-marker {
  color: var(--foreground);
}

/* 모든 단계 동일한 글머리 점 — 라벨 자체에 백엔드가 단계 종류를 함축해 보내므로
   좌측 아이콘은 시각 잡음을 최소화한다(구버전 결정). */
.progress-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: currentColor;
}

.progress-text {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.progress-label {
  font-size: var(--text-xs);
  word-break: break-word;
}
.progress-item.is-live .progress-label {
  color: var(--foreground);
}

.progress-detail {
  font-size: var(--text-xs);
  color: color-mix(in oklab, var(--muted-foreground) 80%, transparent);
  word-break: break-word;
}

@media (min-width: 640px) {
  .progress-summary-text,
  .progress-label { font-size: var(--text-sm); }
}

/* ── 컨트롤 줄(피드백 + 출처 칩) ──────────────────────────── */
.feedback-row {
  position: relative;
  display: flex;
  width: 100%;
  align-items: center;
}

.feedback-icons {
  display: flex;
  align-items: center;
  gap: 2px;
}

.feedback-icon.is-active {
  color: var(--foreground);
}
.feedback-icon.is-negative {
  color: var(--destructive);
}

.feedback-chip-slot {
  display: flex;
  align-items: center;
  margin-left: 4px;
}

.feedback-done {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.source-chip {
  height: 28px;
  padding: 0 8px;
  font-size: var(--text-xs);
}

/* 피드백 팝오버 — anchor(컨트롤 줄) 좌측 정렬 + 그 폭을 그대로 따른다.
   구버전은 --radix-popper-anchor-width 로 같은 효과를 냈다. */
.feedback-popover {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  width: 100%;
}

.feedback-label {
  display: block;
  margin-bottom: 8px;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--muted-foreground);
}

.feedback-comment {
  min-height: 80px;
  max-height: 160px;
  overflow-y: auto;
}

.feedback-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.feedback-counter {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.feedback-buttons {
  display: flex;
  gap: 6px;
}

/* ── 입력 영역 ────────────────────────────────────────────── */
.chat-input-area {
  flex-shrink: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--background);
}

@media (min-width: 768px) {
  .chat-input-area { padding: 16px 24px; }
}

.chat-input-wrap {
  display: flex;
  max-width: 768px;
  margin: 0 auto;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--input);
  border-radius: 12px;
  background: var(--background);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.chat-input-wrap:focus-within {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}

.chat-textarea {
  flex: 1;
  min-height: 24px;
  max-height: 150px;
  padding: 0;
  border: 0;
  resize: none;
  overflow-y: auto;
  line-height: 1.5;
}
.chat-textarea:focus-visible {
  outline: none;
}

/* 전송 ⇄ 중지 — 같은 자리에서 교체되므로 위치/시선 이동이 없다. */
.chat-send-btn {
  display: flex;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: var(--primary);
  color: var(--primary-foreground);
  transition: background-color 0.15s;
}
.chat-send-btn:hover:not(:disabled) {
  background: color-mix(in oklab, var(--primary) 90%, var(--background));
}
