/* ===== RESET & BASE ===== */

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

:root {
  --teal: #0E8585;
  --teal-light: #E8F5F5;
  --teal-dark: #0A6B6B;
  --navy: #1B3A5C;
  --navy-light: #2A4F75;
  --text: #1A1A1A;
  --text-soft: #555;
  --bg: #FAFAF9;
  --white: #FFFFFF;
  --border: #E2E2E0;
  --user-bg: #EDF2F7;
  --assistant-bg: #FFFFFF;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
  --radius: 12px;
  --font-body: 'DM Sans', system-ui, sans-serif;
  --font-display: 'DM Serif Display', Georgia, serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
}


/* ===== HEADER ===== */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 16px;
}

.logo {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--navy);
  font-weight: 400;
  letter-spacing: -0.01em;
}

.tagline {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.new-chat-btn {
  padding: 8px 16px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--navy);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.new-chat-btn:hover {
  background: var(--white);
  border-color: var(--navy);
}

.donate-link {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--teal-dark);
  background: var(--teal-light);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s;
}

.donate-link:hover {
  background: #D4EDED;
}


/* ===== CHAT AREA ===== */

.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
}


/* ===== WELCOME SCREEN ===== */

.welcome {
  max-width: 520px;
  margin: auto;
  text-align: center;
  padding: 40px 20px;
  animation: fadeIn 0.4s ease;
}

.welcome h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  color: var(--navy);
  margin-bottom: 16px;
  font-weight: 400;
}

.welcome p {
  font-size: 1rem;
  color: var(--text-soft);
  line-height: 1.6;
  margin-bottom: 8px;
}

.welcome-sub {
  font-size: 0.85rem !important;
  margin-bottom: 32px !important;
}

.starters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 340px;
  margin: 0 auto;
}

.starter-btn {
  padding: 14px 20px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--navy);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}

.starter-btn:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}


/* ===== MESSAGES ===== */

.messages {
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  padding: 16px 20px;
  border-radius: var(--radius);
  line-height: 1.65;
  font-size: 0.95rem;
  animation: slideIn 0.25s ease;
}

.message.user {
  background: var(--user-bg);
  align-self: flex-end;
  max-width: 85%;
  border-bottom-right-radius: 4px;
}

.message.assistant {
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  align-self: flex-start;
  max-width: 92%;
  box-shadow: var(--shadow-sm);
}

.message p {
  margin-bottom: 10px;
}

.message p:last-child {
  margin-bottom: 0;
}

.message strong {
  font-weight: 600;
}

.message em {
  font-style: italic;
}

.message ul,
.message ol {
  margin: 8px 0 10px 20px;
}

.message li {
  margin-bottom: 4px;
}

.message table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
}

.message th,
.message td {
  padding: 8px 12px;
  border: 1px solid var(--border);
  text-align: left;
}

.message th {
  background: var(--bg);
  font-weight: 600;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 5px;
  padding: 16px 20px;
  align-self: flex-start;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--teal);
  border-radius: 50%;
  opacity: 0.4;
  animation: blink 1.2s infinite;
}

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

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


/* ===== INPUT AREA ===== */

.input-area {
  padding: 16px 24px;
  background: var(--white);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-wrapper {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.15s;
}

.input-wrapper:focus-within {
  border-color: var(--teal);
}

#userInput {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  padding: 4px 0;
}

#userInput::placeholder {
  color: #999;
}

.send-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.send-btn:hover {
  background: var(--teal-dark);
}

.send-btn:active {
  transform: scale(0.95);
}

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

.input-footer {
  text-align: center;
  font-size: 0.75rem;
  color: #999;
  margin-top: 8px;
}


/* ===== ANIMATIONS ===== */

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

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

@keyframes blink {
  0%, 60%, 100% { opacity: 0.4; }
  30% { opacity: 1; }
}


/* ===== RESPONSIVE ===== */

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }

  .header-left {
    flex-direction: column;
    gap: 2px;
  }

  .header-right {
    width: 100%;
  }

  .new-chat-btn,
  .donate-link {
    flex: 1;
    text-align: center;
  }

  .chat-container {
    padding: 16px;
  }

  .message.user {
    max-width: 92%;
  }

  .welcome {
    padding: 24px 8px;
  }

  .welcome h2 {
    font-size: 1.5rem;
  }

  .input-area {
    padding: 12px 16px;
  }
}
