/* ─── Chat Interface ──────────────────────────────────── */

.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* Header */
.chat-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.mentor-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #fb923c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  flex-shrink: 0;
}

.mentor-info {
  display: flex;
  flex-direction: column;
}

.mentor-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
}

.mentor-status {
  font-size: 0.72rem;
  color: var(--fg-muted);
}

/* Flow progress indicator */
.flow-indicator {
  margin-left: auto;
  display: none;
  align-items: center;
  gap: 8px;
}

.flow-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 0.72rem;
  cursor: default;
  transition: all 0.3s ease;
}

.flow-badge:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
}

.flow-label {
  font-weight: 600;
  color: var(--accent);
  text-transform: capitalize;
}

.phase-label {
  color: var(--fg-muted);
  border-left: 1px solid rgba(245, 158, 11, 0.3);
  padding-left: 8px;
  text-transform: capitalize;
}

@media (max-width: 480px) {
  .flow-indicator { display: none !important; }
}

/* Messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 88px 24px 120px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 680px;
  width: 100%;
  animation: msgIn 0.25s ease forwards;
  opacity: 0;
  transform: translateY(8px);
}

@keyframes msgIn {
  to { opacity: 1; transform: translateY(0); }
}

.message--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message--mentor {
  align-self: flex-start;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 2px;
}

.message--user .msg-avatar {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--accent);
}

.message--mentor .msg-avatar {
  background: linear-gradient(135deg, var(--accent) 0%, #fb923c 100%);
  color: #0f172a;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--fg);
}

.message--user .msg-bubble {
  background: var(--accent-dim);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-bottom-right-radius: 4px;
  color: var(--fg);
}

.message--mentor .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* Consecutive message grouping — no double avatar for same-sender chain */
.message + .message--user,
.message--user + .message--user { margin-top: -8px; }
.message + .message--mentor,
.message--mentor + .message--mentor { margin-top: -8px; }
.message--user + .message--user .msg-avatar,
.message--mentor + .message--mentor .msg-avatar { visibility: hidden; }

/* Timestamp badge */
.msg-timestamp {
  font-size: 0.65rem;
  color: var(--fg-muted);
  padding: 0 40px 4px;
  display: block;
}
.message--user .msg-timestamp { text-align: right; }

/* Welcome message — mentor intro */
.welcome-card {
  background: var(--bg-card);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 600px;
  width: 100%;
  position: relative;
  overflow: hidden;
  animation: msgIn 0.5s ease forwards;
}

.welcome-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, rgba(251, 146, 60, 0.4) 60%, transparent 100%);
}

.welcome-card::after {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12) 0%, transparent 70%);
  pointer-events: none;
}

.welcome-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.welcome-label::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.welcome-body {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--fg);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 680px;
  width: 100%;
  animation: msgIn 0.2s ease forwards;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--fg-muted);
  animation: blink 1.2s ease infinite;
}

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

@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: scale(1); }
  30% { opacity: 1; transform: scale(1.2); }
}

/* Input area */
.chat-input-area {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  padding: 20px 24px 28px;
  background: linear-gradient(0deg, var(--bg) 60%, transparent 100%);
  z-index: 100;
}

.chat-input-form {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--fg);
  resize: none;
  min-height: 52px;
  max-height: 160px;
  line-height: 1.5;
  transition: border-color 0.2s ease;
  padding-top: 14px;
}

.chat-input::placeholder {
  color: var(--fg-muted);
  font-size: 0.9rem;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(245, 158, 11, 0.5);
}

.chat-send-btn {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
  flex-shrink: 0;
}

.chat-send-btn:hover { transform: scale(1.06); }
.chat-send-btn:active { transform: scale(0.96); }
.chat-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.chat-send-btn svg {
  width: 20px;
  height: 20px;
  fill: #0f172a;
}

/* Scrollbar */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Mobile */
@media (max-width: 768px) {
  .chat-header { padding: 12px 16px; }
  .chat-messages { padding: 80px 16px 110px; }
  .chat-input-area { padding: 16px 16px 24px; }
  .msg-bubble { font-size: 0.92rem; }
  .welcome-card { padding: 22px 24px; }
}

@media (max-width: 480px) {
  .chat-input-form { gap: 8px; }
  .chat-send-btn { width: 46px; height: 46px; }
}