@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --accent:           #4f46e5;
  --accent-dark:      #3730a3;
  --accent-light:     #ede9fe;
  --text:             #111827;
  --text-muted:       #6b7280;
  --bg:               #ffffff;
  --bg-subtle:        #f9fafb;
  --border:           #e5e7eb;
  --user-bg:          #4f46e5;
  --user-text:        #ffffff;
  --ai-bg:            #f3f4f6;
  --ai-text:          #111827;
  --shadow:           0 2px 8px rgba(0,0,0,0.08);
  --radius:           12px;
  --radius-sm:        8px;
  --ease:             ease-in-out;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Simulated background page ───────────────────────────────── */
.page-bg {
  min-height: 100vh;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.page-hero {
  text-align: center;
  color: rgba(255,255,255,0.9);
}
.page-hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  margin-bottom: 12px;
  letter-spacing: -0.02em;
}
.page-hero p {
  font-size: 1.1rem;
  opacity: 0.75;
}

/* ── Chat bubble (shown when chat is closed) ─────────────────── */
.chat-bubble {
  position: fixed;
  bottom: 28px;
  right: 28px;
  height: 56px;
  padding: 0 20px 0 16px;
  border-radius: 28px;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(79,70,229,0.45);
  transition: background 0.2s var(--ease), transform 0.2s var(--ease);
  z-index: 1000;
}
.chat-bubble:hover { background: var(--accent-dark); transform: scale(1.04); }
.chat-bubble svg { width: 22px; height: 22px; flex-shrink: 0; }

/* ── Chat window ─────────────────────────────────────────────── */
.chat-window {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: 580px;
  max-height: calc(100vh - 56px);
  background: var(--bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1000;
  transform-origin: bottom right;
  animation: popIn 0.3s var(--ease) both;
}
.chat-window.hidden {
  display: none;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(0.88) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ──────────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.header-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.header-avatar svg { width: 22px; height: 22px; }
.header-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.header-name  { font-weight: 700; font-size: 0.95rem; }
.header-status {
  font-size: 0.72rem; opacity: 0.85;
  display: flex; align-items: center; gap: 5px;
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.35; }
}
.close-btn {
  background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,0.8);
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.close-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.close-btn svg   { width: 18px; height: 18px; }

/* ── Messages ────────────────────────────────────────────────── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.message {
  display: flex; flex-direction: column;
  max-width: 84%;
  animation: msgIn 0.2s ease both;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.message.user  { align-self: flex-end;  align-items: flex-end; }
.message.ai    { align-self: flex-start; align-items: flex-start; }

.message-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 0.88rem;
  line-height: 1.55;
  word-break: break-word;
}
.message.user .message-bubble {
  background: var(--user-bg); color: var(--user-text);
  border-bottom-right-radius: 4px;
}
.message.ai .message-bubble {
  background: var(--ai-bg); color: var(--ai-text);
  border-bottom-left-radius: 4px;
}
.message-time {
  font-size: 0.68rem; color: var(--text-muted);
  margin-top: 4px; padding: 0 4px;
}

/* ── Typing indicator ────────────────────────────────────────── */
.typing-indicator {
  display: flex; align-items: center; gap: 5px;
  padding: 10px 14px;
  background: var(--ai-bg);
  border-radius: 18px; border-bottom-left-radius: 4px;
  width: fit-content;
}
.typing-dot {
  width: 7px; height: 7px;
  border-radius: 50%; background: var(--text-muted);
  animation: bounce 1.3s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ──────────────────────────────────────────────── */
.chat-input-area {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.chat-input {
  flex: 1; resize: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 0.88rem; font-family: inherit;
  color: var(--text); background: var(--bg-subtle);
  outline: none; line-height: 1.4;
  max-height: 120px; overflow-y: auto;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
  background: var(--bg);
}
.chat-input::placeholder { color: #9ca3af; }

.send-btn {
  flex-shrink: 0; width: 42px; height: 42px;
  border-radius: 50%; background: var(--accent);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.send-btn:hover:not(:disabled) { background: var(--accent-dark); transform: scale(1.08); }
.send-btn:disabled { background: var(--border); cursor: default; }
.send-btn svg { width: 20px; height: 20px; color: #fff; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 460px) {
  .chat-window { width: calc(100vw - 20px); right: 10px; bottom: 10px; height: calc(100vh - 20px); border-radius: 14px; }
  .chat-bubble  { right: 16px; bottom: 16px; }
}
