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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--bark);
  -webkit-font-smoothing: antialiased;
}

/* ===== LAYOUT: header / messages / input ===== */
.chat-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 800px;
  margin: 0 auto;
}

/* ===== HEADER ===== */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid var(--cream-dark);
  background: var(--white);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--bark);
}

.chat-header-left svg {
  width: 28px;
  height: 28px;
}

.chat-header-left .logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
}

.chat-header-left .logo-label {
  font-size: 0.8rem;
  color: var(--moss);
  font-weight: 400;
  margin-left: 2px;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--moss);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sage);
}

.status-dot.online {
  background: #4ade80;
  box-shadow: 0 0 6px #4ade8066;
}

.status-dot.offline {
  background: #f87171;
}

/* ===== MESSAGES AREA ===== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
}

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  padding: 20px;
}

.empty-state h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--bark);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--moss);
  font-size: 0.95rem;
  margin-bottom: 28px;
  max-width: 400px;
  line-height: 1.5;
}

.example-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 420px;
}

.example-prompt {
  background: var(--white);
  border: 1px solid var(--cream-dark);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: var(--bark-light);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: var(--font-body);
}

.example-prompt:hover {
  border-color: var(--sage);
  box-shadow: 0 2px 8px var(--shadow);
}

/* ===== MESSAGE BUBBLES ===== */
.message {
  margin-bottom: 16px;
  display: flex;
}

.message-user {
  justify-content: flex-end;
}

.message-assistant {
  justify-content: flex-start;
}

.message-error {
  justify-content: center;
}

.message-bubble {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.92rem;
  line-height: 1.6;
  word-wrap: break-word;
}

.user-bubble {
  background: var(--forest);
  color: var(--white);
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.assistant-bubble {
  background: var(--white);
  color: var(--bark);
  border: 1px solid var(--cream-dark);
  border-bottom-left-radius: 4px;
}

.error-bubble {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  font-size: 0.85rem;
  border-radius: 10px;
}

/* ===== STREAMING CURSOR ===== */
.streaming-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--forest);
  margin-left: 2px;
  animation: blink 0.8s infinite;
  vertical-align: text-bottom;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* ===== CUT SHORT NOTICE ===== */
.cut-short-notice {
  font-size: 0.78rem;
  color: var(--moss);
  font-style: italic;
  margin-top: 6px;
}

/* ===== MARKDOWN CONTENT ===== */
.message-content p {
  margin-bottom: 0.6em;
}

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

.message-content pre {
  background: var(--bark);
  color: var(--cream);
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  margin: 8px 0;
  line-height: 1.5;
}

.message-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--cream-dark);
  padding: 1px 5px;
  border-radius: 4px;
}

.message-content pre code {
  background: none;
  padding: 0;
  font-size: inherit;
}

.message-content ul, .message-content ol {
  padding-left: 1.4em;
  margin: 6px 0;
}

.message-content li {
  margin-bottom: 2px;
}

.message-content a {
  color: var(--forest);
  text-decoration: underline;
}

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

/* ===== INPUT AREA ===== */
.input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--cream-dark);
  background: var(--white);
  flex-shrink: 0;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-row textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--cream-dark);
  border-radius: 12px;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.5;
  background: var(--cream);
  color: var(--bark);
  outline: none;
  min-height: 44px;
  max-height: 200px;
  transition: border-color 0.15s;
}

.input-row textarea:focus {
  border-color: var(--sage);
}

.input-row textarea:disabled {
  opacity: 0.6;
}

.input-row textarea::placeholder {
  color: var(--sage);
}

.send-btn, .stop-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}

.send-btn {
  background: var(--forest);
  color: var(--white);
}

.send-btn:hover {
  background: var(--forest-light);
}

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

.stop-btn {
  background: #f87171;
  color: white;
  display: none;
}

.stop-btn:hover {
  background: #ef4444;
}

.disclaimer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--sage);
  margin-top: 8px;
  line-height: 1.4;
}

.disclaimer a {
  color: var(--moss);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .chat-layout {
    max-width: 100%;
  }

  .chat-header {
    padding: 10px 14px;
  }

  .messages-container {
    padding: 16px 14px;
  }

  .input-area {
    padding: 10px 14px 14px;
  }

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

  .empty-state h2 {
    font-size: 1.25rem;
  }

  .example-prompts {
    max-width: 100%;
  }
}
