/* ========================================
   RESET & BASE — matches lucaslima.xyz
   ======================================== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #ffffff;
  --bg-elevated: #f7f7f7;
  --bg-card: #ffffff;
  --bg-bubble-user: #1a1a2e;
  --bg-bubble-assistant: #f7f7f7;
  --text: #000000;
  --text-on-dark: #ffffff;
  --text-muted: #6b6b7b;
  --accent: #1a1a2e;
  --accent-hover: #2d2d4a;
  --border: rgba(0, 0, 0, 0.08);
  --font-body: 'Inter', -apple-system, sans-serif;
  --font-display: 'Playfair Display', Georgia, serif;
  --max-width: 880px;
  --side-padding: 32px;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ========================================
   HEADER
   ======================================== */
.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 24px var(--side-padding) 28px;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
}

.back-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.back-link {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color 0.2s;
  width: fit-content;
}

.back-link:hover {
  color: var(--text);
}

.app-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.app-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 640px;
}

/* ========================================
   CHAT
   ======================================== */
.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 32px var(--side-padding);
}

.messages {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.msg {
  display: flex;
  max-width: 85%;
}

.msg-user {
  align-self: flex-end;
}

.msg-assistant {
  align-self: flex-start;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-user .msg-bubble {
  background: var(--bg-bubble-user);
  color: var(--text-on-dark);
  border-bottom-right-radius: 4px;
}

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

/* Typing indicator (animated dots) */
.msg-typing .msg-bubble {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 16px;
}

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

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

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

.msg-error .msg-bubble {
  background: #fff4f4;
  color: #8a1f1f;
  border: 1px solid #f1c0c0;
}

/* ========================================
   COMPOSER (input + send button at the bottom)
   ======================================== */
.composer {
  border-top: 1px solid var(--border);
  background: var(--bg);
  padding: 16px var(--side-padding) 20px;
}

.composer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer-input {
  flex: 1;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  resize: none;
  max-height: 180px;
  outline: none;
  transition: border-color 0.15s;
}

.composer-input:focus {
  border-color: var(--accent);
}

.composer-send {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 12px 22px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--text-on-dark);
  cursor: pointer;
  transition: background 0.15s;
}

.composer-send:hover:not(:disabled) {
  background: var(--accent-hover);
}

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

.composer-hint {
  max-width: var(--max-width);
  margin: 8px auto 0;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 640px) {
  :root {
    --side-padding: 16px;
  }
  .app-title {
    font-size: 1.3rem;
  }
  .msg {
    max-width: 95%;
  }
}
