/* Coral Chatbot — DR Branding Theme */

:root {
  /* DR Brand Palette (Nourished Studio V.2) */
  --dr-pine-needle-green: #3E4843;
  --dr-forest-fern: #566D49;
  --dr-sage: #8AA382;
  --dr-olive: #D0D9A3;
  --dr-deep-blue: #3A708E;
  --dr-coastal: #89B1CC;
  --dr-ivory: #F3E9DE;
  --dr-mist: #C1D7E9;

  /* Typography */
  --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--dr-ivory);
  color: var(--dr-pine-needle-green);
}

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

/* Screen-reader only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Header */
.chat-header {
  background: var(--dr-pine-needle-green);
  color: var(--dr-ivory);
  padding: 1rem 1.5rem;
  flex-shrink: 0;
}

.header-content {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
}

.header-title {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
}

.header-subtitle {
  font-size: 0.875rem;
  opacity: 0.7;
}

/* Messages area */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}

.messages {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Message bubbles */
.message {
  display: flex;
  animation: fadeIn 0.2s ease-out;
}

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

.message-content {
  max-width: 85%;
  padding: 0.875rem 1.125rem;
  border-radius: 0.75rem;
  line-height: 1.6;
  font-size: 0.9375rem;
}

/* User messages — right-aligned, Forest Fern accent */
.user-message {
  justify-content: flex-end;
}

.user-message .message-content {
  background: var(--dr-forest-fern);
  color: white;
  border-bottom-right-radius: 0.25rem;
}

/* Assistant messages — left-aligned, white card */
.assistant-message {
  justify-content: flex-start;
}

.assistant-message .message-content {
  background: white;
  color: var(--dr-pine-needle-green);
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(62, 72, 67, 0.1);
}

/* Markdown content inside assistant messages */
.assistant-message .message-content h1,
.assistant-message .message-content h2,
.assistant-message .message-content h3 {
  font-family: var(--font-heading);
  margin-top: 0.75rem;
  margin-bottom: 0.375rem;
}

.assistant-message .message-content h1 { font-size: 1.25rem; }
.assistant-message .message-content h2 { font-size: 1.125rem; }
.assistant-message .message-content h3 { font-size: 1rem; }

.assistant-message .message-content p {
  margin-bottom: 0.5rem;
}

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

.assistant-message .message-content ul,
.assistant-message .message-content ol {
  margin: 0.375rem 0 0.5rem 1.25rem;
}

.assistant-message .message-content li {
  margin-bottom: 0.25rem;
}

.assistant-message .message-content code {
  background: rgba(62, 72, 67, 0.08);
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-size: 0.85em;
}

.assistant-message .message-content pre {
  background: var(--dr-pine-needle-green);
  color: var(--dr-ivory);
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.assistant-message .message-content pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.assistant-message .message-content a {
  color: var(--dr-deep-blue);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.assistant-message .message-content a:hover {
  color: var(--dr-forest-fern);
}

.assistant-message .message-content strong {
  font-weight: 600;
}

.assistant-message .message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.5rem 0;
  font-size: 0.875rem;
}

.assistant-message .message-content th,
.assistant-message .message-content td {
  border: 1px solid var(--dr-olive);
  padding: 0.375rem 0.625rem;
  text-align: left;
}

.assistant-message .message-content th {
  background: rgba(208, 217, 163, 0.3);
  font-weight: 600;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 0.25rem;
  padding: 0.875rem 1.125rem;
  background: white;
  border-radius: 0.75rem;
  border-bottom-left-radius: 0.25rem;
  box-shadow: 0 1px 3px rgba(62, 72, 67, 0.1);
  max-width: 85%;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: var(--dr-sage);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}

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

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

/* Error message styling */
.error-message .message-content {
  background: #fef2f2;
  color: #991b1b;
  border-left: 3px solid #ef4444;
}

/* Input area */
.chat-input-area {
  flex-shrink: 0;
  background: white;
  border-top: 1px solid var(--dr-olive);
  padding: 1rem 1.5rem 0.75rem;
}

.input-form {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  resize: none;
  border: 2px solid var(--dr-olive);
  border-radius: 0.75rem;
  padding: 0.625rem 1rem;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--dr-pine-needle-green);
  background: var(--dr-ivory);
  max-height: 150px;
  outline: none;
  transition: border-color 0.15s ease;
}

.chat-input::placeholder {
  color: var(--dr-sage);
}

.chat-input:focus {
  border-color: var(--dr-forest-fern);
}

.send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--dr-forest-fern);
  color: white;
  border: none;
  border-radius: 0.75rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.15s ease;
}

.send-btn:hover {
  background: var(--dr-pine-needle-green);
}

.send-btn:disabled {
  background: var(--dr-sage);
  cursor: not-allowed;
}

.send-btn:focus-visible {
  outline: 2px solid var(--dr-deep-blue);
  outline-offset: 2px;
}

.input-footer {
  max-width: 800px;
  margin: 0.5rem auto 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-count {
  font-size: 0.75rem;
  color: var(--dr-sage);
}

.char-count.near-limit {
  color: #d97706;
}

.char-count.at-limit {
  color: #dc2626;
  font-weight: 500;
}

.footer-text {
  font-size: 0.75rem;
  color: var(--dr-sage);
}

/* Responsive */
@media (max-width: 640px) {
  .chat-header {
    padding: 0.75rem 1rem;
  }

  .header-content {
    flex-direction: column;
    gap: 0.125rem;
  }

  .header-title {
    font-size: 1.25rem;
  }

  .chat-container {
    padding: 1rem;
  }

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

  .chat-input-area {
    padding: 0.75rem 1rem 0.5rem;
  }

  .input-footer {
    flex-direction: column-reverse;
    gap: 0.25rem;
    align-items: center;
  }
}
