/* =========================================================
   CHAT PAGE
========================================================= */
.chat-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 70px;
  background: var(--cream);
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 0;
}

/* ---------- MESSAGES AREA ---------- */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

/* ---------- MESSAGE BUBBLES ---------- */
.msg {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.6;
  animation: fadeUp 0.25s var(--ease);
}

.msg-bot {
  align-self: flex-start;
  background: var(--white);
  color: var(--ink);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.msg-user {
  align-self: flex-end;
  background: var(--green);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

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

/* ---------- TYPING INDICATOR ---------- */
.typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 14px 20px;
  background: var(--white);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
}

.typing span {
  width: 7px;
  height: 7px;
  background: var(--ink-lighter);
  border-radius: 50%;
  animation: bounce 1.4s ease-in-out infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ---------- ERROR BUBBLE ---------- */
.msg-error {
  background: #fff5f5 !important;
  color: #8b1a1a !important;
  border: 1px solid #f5c2c2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 100% !important;
}

/* ---------- TOOLBAR ---------- */
.chat-toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 8px 4px 0;
}
.chat-restart {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.12);
  color: #555;
  font: inherit;
  font-size: 0.82rem;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.chat-restart:hover {
  background: rgba(0,0,0,0.04);
  color: #111;
  border-color: rgba(0,0,0,0.2);
}
.chat-restart svg { width: 14px; height: 14px; }

/* ---------- INPUT BAR ---------- */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 16px 0 24px;
  border-top: 1px solid var(--line);
  background: var(--cream);
}

.chat-input-bar textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  font-family: var(--font-b);
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--white);
  outline: none;
  max-height: 120px;
  transition: border-color 0.2s;
}

.chat-input-bar textarea:focus {
  border-color: var(--green);
}

.chat-input-bar textarea::placeholder {
  color: var(--ink-lighter);
}

.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--orange);
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s var(--ease);
}

.chat-send:hover {
  background: var(--orange-hover);
  transform: scale(1.05);
}

.chat-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chat-send svg {
  width: 18px;
  height: 18px;
}

/* ---------- CONTACT CARD (in-chat) ---------- */
.contact-card {
  align-self: flex-start;
  max-width: 380px;
  background: var(--white);
  border: 1.5px solid var(--green-light);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  padding: 24px;
  box-shadow: 0 4px 16px rgba(27,94,75,.08);
  animation: fadeUp 0.35s var(--ease);
}

.contact-card h3 {
  font-size: 1.05rem;
  margin-bottom: 4px;
  color: var(--green);
}

.contact-card p {
  font-size: 0.82rem;
  color: var(--ink-light);
  margin-bottom: 16px;
  line-height: 1.5;
}

.contact-card .tab-row {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.contact-card .tab-btn {
  flex: 1;
  padding: 8px 0;
  font-size: 0.82rem;
  font-weight: 600;
  border: none;
  background: var(--cream);
  color: var(--ink-light);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-b);
}

.contact-card .tab-btn.active {
  background: var(--green);
  color: var(--white);
}

.contact-card .input-wrap {
  display: flex;
  align-items: center;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: var(--white);
  transition: border-color 0.2s;
}

.contact-card .input-wrap:focus-within {
  border-color: var(--green);
}

.contact-card .input-prefix {
  padding: 0 12px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-lighter);
  background: var(--cream);
  height: 42px;
  display: flex;
  align-items: center;
  border-right: 1.5px solid var(--line);
}

.contact-card input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 12px;
  font-family: var(--font-b);
  font-size: 0.9rem;
  color: var(--ink);
  background: transparent;
}

.contact-card input::placeholder {
  color: var(--ink-lighter);
}

.contact-card .submit-btn {
  width: 100%;
  padding: 11px;
  margin-top: 12px;
  border: none;
  border-radius: 10px;
  background: var(--orange);
  color: var(--white);
  font-family: var(--font-b);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s var(--ease);
}

.contact-card .submit-btn:hover {
  background: var(--orange-hover);
  transform: translateY(-1px);
}

.contact-card .skip-link {
  display: block;
  text-align: center;
  margin-top: 10px;
  font-size: 0.75rem;
  color: var(--ink-lighter);
  cursor: pointer;
  transition: color 0.2s;
}

.contact-card .skip-link:hover {
  color: var(--ink-light);
}

.contact-card .error-msg {
  font-size: 0.78rem;
  color: #DC2626;
  margin-top: 6px;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
  .chat-container {
    padding: 16px 16px 0;
  }

  .msg {
    max-width: 90%;
  }

  .contact-card {
    max-width: 100%;
  }
}
