/* ============================================================
   style.css — RAG Chatbot UI
   Design: Refined dark theme with teal accent
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sora:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
:root {
  --bg-base:      #0d0f14;
  --bg-surface:   #151820;
  --bg-card:      #1c2030;
  --bg-input:     #222638;
  --border:       #2a2f45;
  --border-light: #343a54;

  --accent:       #00c9a7;
  --accent-dim:   rgba(0, 201, 167, 0.12);
  --accent-glow:  rgba(0, 201, 167, 0.25);

  --text-primary:   #e8eaf0;
  --text-secondary: #8b91a8;
  --text-muted:     #555c78;

  --user-bubble:  #1e3a5f;
  --bot-bubble:   #1c2030;

  --shadow-soft: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-glow: 0 0 30px rgba(0, 201, 167, 0.15);

  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --font-main: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

/* ── Reset & Base ──────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-main);
  background: var(--bg-base);
  color: var(--text-primary);
  overflow: hidden;
}

/* ── Background texture ────────────────────────────────── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(0,201,167,0.04) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(99,102,241,0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ────────────────────────────────────────────── */
.chat-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.bot-avatar {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #00c9a7, #0095ff);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 16px rgba(0,201,167,0.3);
  flex-shrink: 0;
}

.header-info h1 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.status-dot {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

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

.header-actions {
  display: flex;
  gap: 8px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--bg-input);
  color: var(--text-primary);
  border-color: var(--border-light);
}

/* ── Messages Area ─────────────────────────────────────── */
.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

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

/* ── Welcome Screen ────────────────────────────────────── */
.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 24px;
  padding: 40px;
  animation: fadeUp 0.5s ease;
}

.welcome-icon {
  font-size: 52px;
  filter: drop-shadow(0 0 20px rgba(0,201,167,0.4));
}

.welcome-screen h2 {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #e8eaf0 0%, #00c9a7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.welcome-screen p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
  max-width: 380px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 8px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 9px 18px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: var(--font-main);
  transition: all 0.2s;
}

.chip:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

/* ── Message Bubbles ───────────────────────────────────── */
.message {
  display: flex;
  gap: 12px;
  animation: fadeUp 0.3s ease;
  max-width: 100%;
}

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

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

.msg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.bot .msg-avatar {
  background: linear-gradient(135deg, #00c9a7, #0095ff);
  box-shadow: 0 2px 12px rgba(0,201,167,0.25);
}

.message.user .msg-avatar {
  background: var(--user-bubble);
  border: 1px solid #2a4a6e;
}

.msg-content {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.message.user .msg-content { align-items: flex-end; }

.msg-bubble {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 14.5px;
  line-height: 1.65;
  word-break: break-word;
}

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

.message.user .msg-bubble {
  background: linear-gradient(135deg, #1e4a7a, #1a3d6a);
  border: 1px solid #2a5a8a;
  border-bottom-right-radius: 4px;
  color: var(--text-primary);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 0 4px;
}

.msg-sources {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.source-tag {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(0,201,167,0.2);
  border-radius: 4px;
  padding: 1px 7px;
  font-size: 10px;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Typing Indicator ──────────────────────────────────── */
.typing-indicator {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  animation: fadeUp 0.3s ease;
}

.typing-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  padding: 14px 18px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.typing-bubble span {
  width: 7px;
  height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce 1.2s ease-in-out infinite;
}

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

@keyframes typing-bounce {
  0%, 100% { transform: translateY(0); background: var(--text-muted); }
  50%       { transform: translateY(-6px); background: var(--accent); }
}

/* ── Token Counter ─────────────────────────────────────── */
.token-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.token-info {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
}

.token-count {
  color: var(--accent);
  font-weight: 500;
}

.model-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* ── Input Area ────────────────────────────────────────── */
.input-area {
  padding: 16px 0 20px;
  flex-shrink: 0;
}

.input-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#userInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14.5px;
  line-height: 1.5;
  resize: none;
  min-height: 22px;
  max-height: 120px;
  overflow-y: auto;
}

#userInput::placeholder { color: var(--text-muted); }

#userInput::-webkit-scrollbar { width: 0; }

.send-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #00c9a7, #0095ff);
  border: none;
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(0,201,167,0.3);
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0,201,167,0.4);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

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

/* ── Error Message ─────────────────────────────────────── */
.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  color: #fc8181;
  text-align: center;
  animation: fadeUp 0.3s ease;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
  .chat-wrapper { padding: 0 12px; }
  .msg-content  { max-width: 88%; }
  .suggestion-chips { gap: 8px; }
  .chip { font-size: 12px; padding: 8px 14px; }
  .welcome-screen h2 { font-size: 22px; }
}
