/**
 * YEO × GOOKIN VN Wash-off Survey — chat.css v2.4.1
 * =================================================
 * v2.4.1 fix: Chat Screen 중앙 정렬 + max-width 복원
 */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: 'Noto Sans KR', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #FAFAFA;
  color: #333;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

/* ═══════════════════════════════════════
 * WELCOME SCREEN
 * ═══════════════════════════════════════ */
.welcome-screen {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, #FFFFFF 0%, #F3E5F5 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px;
  overflow-y: auto;
}

.welcome-container {
  width: 100%;
  max-width: 480px;
  text-align: center;
  padding: 20px 0;
}

.welcome-logo { margin-bottom: 30px; }

.logo-mark {
  font-size: 28px;
  font-weight: 700;
  color: #4A148C;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.logo-sub {
  font-size: 13px;
  color: #9575CD;
  letter-spacing: 1px;
}

.welcome-title {
  font-size: 26px;
  font-weight: 700;
  color: #1A1A1A;
  margin-bottom: 16px;
  line-height: 1.3;
}

.welcome-description {
  font-size: 15px;
  color: #555;
  line-height: 1.7;
  margin-bottom: 24px;
}

.welcome-description strong {
  color: #4A148C;
}

.notice-box {
  background: #FFF8E1;
  border-left: 4px solid #FFA726;
  padding: 16px 18px;
  border-radius: 8px;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.7;
  color: #424242;
  text-align: left;
}

.notice-box h3 {
  font-size: 15px;
  font-weight: 700;
  color: #E65100;
  margin: 0 0 10px 0;
}

.notice-box ul {
  margin: 0;
  padding-left: 18px;
}

.notice-box li { margin-bottom: 6px; }

.notice-box strong { color: #BF360C; }

.welcome-info {
  background: rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 24px;
  text-align: left;
}

.info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 14px;
  color: #555;
}

.info-row:last-child { margin-bottom: 0; }

.info-icon { font-size: 16px; }

.start-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #6A1B9A 0%, #9C27B0 100%);
  color: white;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  box-shadow: 0 4px 12px rgba(106, 27, 154, 0.3);
  margin-bottom: 16px;
}

.start-btn:active { transform: scale(0.98); }

.language-select {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.lang-btn {
  padding: 8px 16px;
  background: white;
  border: 1.5px solid #E0E0E0;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  color: #666;
}

.lang-btn.active {
  border-color: #9C27B0;
  background: #9C27B0;
  color: white;
}

/* ═══════════════════════════════════════
 * CHAT SCREEN (v2.4.1 중앙 정렬 복원)
 * ═══════════════════════════════════════ */
.chat-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  max-width: 560px;            /* v2.4.1: 와이드 화면 제한 */
  margin: 0 auto;              /* v2.4.1: 중앙 정렬 */
  background: #FAFAFA;
  border-left: 1px solid #EEEEEE;   /* 양옆 구분선 (데스크톱) */
  border-right: 1px solid #EEEEEE;
  box-shadow: 0 0 24px rgba(0,0,0,0.04);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: white;
  border-bottom: 1px solid #EEEEEE;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6A1B9A, #9C27B0);
  color: white;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-name {
  font-size: 15px;
  font-weight: 600;
  color: #1A1A1A;
}

.header-sub {
  font-size: 12px;
  color: #999;
}

.tester-id {
  font-size: 11px;
  color: #BDBDBD;
  font-family: 'Inter', monospace;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #FAFAFA;
}

.message {
  margin-bottom: 16px;
  display: flex;
  gap: 10px;
  animation: fadeInUp 0.3s ease;
}

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

.message-user { justify-content: flex-end; }
.message-assistant { justify-content: flex-start; }

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6A1B9A, #9C27B0);
  color: white;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.message-bubble {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.message-user .message-bubble {
  background: #9C27B0;
  color: white;
  border-bottom-right-radius: 4px;
}

.message-assistant .message-bubble {
  background: white;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.message-error .message-bubble {
  background: #FFEBEE;
  color: #C62828;
}

.typing-indicator {
  display: flex;
  gap: 10px;
  padding: 0 20px 16px;
  align-items: flex-end;
}

.typing-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6A1B9A, #9C27B0);
  color: white;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
}

.typing-bubble {
  background: white;
  padding: 14px 18px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-bubble span {
  width: 6px;
  height: 6px;
  background: #BDBDBD;
  border-radius: 50%;
  animation: typingDot 1.4s infinite;
}

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

@keyframes typingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.chat-footer {
  padding: 12px 16px;
  background: white;
  border-top: 1px solid #EEEEEE;
  flex-shrink: 0;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

.input-wrapper {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

textarea#user-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 16px;
  border: 1px solid #E0E0E0;
  border-radius: 22px;
  font-family: inherit;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  background: #FAFAFA;
}

textarea#user-input:focus {
  border-color: #9C27B0;
  background: white;
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6A1B9A, #9C27B0);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s, opacity 0.2s;
}

.send-btn:active { transform: scale(0.95); }

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* 데스크톱에서 Chat Screen 배경 (좌우 여백 영역) */
@media (min-width: 561px) {
  body:has(.chat-screen:not(.hidden)) {
    background: linear-gradient(160deg, #FAFAFA 0%, #F3E5F5 100%);
  }
}

/* ═══════════════════════════════════════
 * COMPLETION SCREEN
 * ═══════════════════════════════════════ */
.completion-screen {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(160deg, #FFFFFF 0%, #F3E5F5 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 20px;
  overflow-y: auto;
}

.completion-container {
  width: 100%;
  max-width: 520px;
  text-align: center;
  padding: 20px 0;
}

.completion-icon {
  font-size: 56px;
  margin-bottom: 16px;
}

.completion-title {
  font-size: 22px;
  font-weight: 700;
  color: #1A1A1A;
  margin-bottom: 20px;
  line-height: 1.4;
}

.completion-message {
  font-size: 15px;
  color: #666;
  line-height: 1.7;
  margin-bottom: 32px;
}

.summary-card {
  background: linear-gradient(135deg, #FAFAFA 0%, #F3E5F5 100%);
  border-radius: 16px;
  padding: 24px;
  margin: 20px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  text-align: left;
}

.summary-card h3 {
  font-size: 16px;
  color: #4A148C;
  margin: 0 0 8px 0;
  font-weight: 700;
}

.summary-card .section {
  margin: 18px 0;
  padding: 12px 14px;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
}

.summary-card .section-title {
  font-size: 13px;
  font-weight: 600;
  color: #6A1B9A;
  margin-bottom: 8px;
}

.summary-card .section-content {
  font-size: 14px;
  color: #333;
  line-height: 1.6;
}

.summary-card .skin-insight {
  background: #FFF3E0;
  border-left: 3px solid #FF7043;
  padding: 10px 12px;
  border-radius: 6px;
  margin: 8px 0;
  font-size: 13px;
  color: #5D4037;
  line-height: 1.5;
}

.summary-card .bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-size: 13px;
}

.summary-card .bar-label {
  min-width: 64px;
  color: #555;
}

.summary-card .bar-track {
  flex: 1;
  height: 8px;
  background: #E0E0E0;
  border-radius: 4px;
  overflow: hidden;
}

.summary-card .bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #9C27B0 0%, #CE93D8 100%);
  border-radius: 4px;
}

.summary-card .bar-value {
  min-width: 38px;
  text-align: right;
  color: #333;
  font-weight: 600;
  font-size: 12px;
}

.summary-card .priority-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.summary-card .priority-list li {
  padding: 6px 0;
  font-size: 13px;
  color: #333;
}

.summary-card .priority-list li::before {
  content: attr(data-rank) '  ';
  font-weight: 700;
  color: #9C27B0;
}

.summary-card .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.summary-card .tag {
  background: #F3E5F5;
  color: #6A1B9A;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.summary-card .tag.deal-breaker {
  background: #FFEBEE;
  color: #C62828;
}

.summary-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.summary-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s;
}

.summary-actions .btn-primary {
  background: #9C27B0;
  color: white;
}

.summary-actions .btn-secondary {
  background: #E0E0E0;
  color: #333;
}

.summary-actions button:active { transform: scale(0.98); }

.completion-footer {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.completion-logo {
  font-size: 16px;
  font-weight: 700;
  color: #4A148C;
  margin-bottom: 4px;
}

.completion-tagline {
  font-size: 12px;
  color: #9575CD;
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════
 * MOBILE RESPONSIVE
 * ═══════════════════════════════════════ */
@media (max-width: 600px) {
  .welcome-screen,
  .completion-screen {
    padding: 20px 16px;
  }

  .welcome-title { font-size: 22px; }
  .welcome-description { font-size: 14px; }

  .notice-box {
    font-size: 13px;
    padding: 14px 16px;
  }

  .completion-title { font-size: 20px; }
  .summary-card { padding: 18px; }

  .summary-card .section { padding: 10px 12px; }

  .chat-screen {
    max-width: 100%;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }

  .chat-messages { padding: 16px; }

  .message-bubble {
    max-width: 80%;
    font-size: 13.5px;
  }

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

@media (max-width: 380px) {
  .welcome-title { font-size: 19px; }
  .notice-box { font-size: 12.5px; }

  .summary-card .bar-label {
    min-width: 54px;
    font-size: 12px;
  }
}
