/* ── Variables ── */
:root {
  --primary:    #1a3a2a;
  --accent:     #c9a84c;
  --bg:         #f5f0e8;
  --surface:    #ffffff;
  --border:     #e2dbd0;
  --text:       #1a1a1a;
  --text-muted: #6b6560;
  --user-bg:    #1a3a2a;
  --user-text:  #ffffff;
  --tool-bg:    #f0ebe0;
  --radius:     12px;
  --shadow:     0 2px 12px rgba(0,0,0,0.08);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: var(--bg); color: var(--text); }

/* ── Layout ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 800px;
  margin: 0 auto;
}

/* ── Header ── */
.header {
  background: var(--primary);
  padding: 0 24px;
  height: 56px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.header-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--primary);
  font-weight: bold;
}

.logo-text {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.3px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6fcf97;
}

.status-dot.thinking {
  background: var(--accent);
  animation: pulse 1s infinite;
}

.status-dot.error {
  background: #eb5757;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Chat Area ── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 16px;
  scroll-behavior: smooth;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ── Welcome ── */
.welcome-card {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.welcome-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

.welcome-card h2 {
  font-size: 22px;
  color: var(--primary);
  margin-bottom: 8px;
}

.welcome-card p {
  font-size: 15px;
}

/* ── Messages ── */
.message {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  animation: fadeIn 0.2s ease;
}

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

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

.message.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.message.assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow);
}

.message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* ── Tool Call Card ── */
.tool-card {
  align-self: flex-start;
  max-width: 88%;
  background: var(--tool-bg);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  animation: fadeIn 0.2s ease;
}

.tool-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.tool-name {
  color: var(--primary);
  font-weight: 700;
}

.tool-card-body {
  color: var(--text-muted);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.5;
  word-break: break-all;
}

/* ── Thinking indicator ── */
.thinking-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text-muted);
  box-shadow: var(--shadow);
}

.dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}

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

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── File Preview ── */
.file-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.file-tag {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--tool-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.file-tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 2px;
}

/* ── Input Area ── */
.input-area {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px;
  flex-shrink: 0;
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  padding: 8px 8px 8px 12px;
  transition: border-color 0.2s;
}

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

.upload-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.upload-btn:hover {
  background: var(--border);
  color: var(--primary);
}

.textarea-wrapper {
  flex: 1;
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  resize: none;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

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

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

.send-btn:hover   { background: #2a5a40; }
.send-btn:active  { transform: scale(0.95); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; }

/* ── Scrollbar ── */
.chat-area::-webkit-scrollbar { width: 4px; }
.chat-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .message { max-width: 90%; }
  .chat-area { padding: 16px 12px; }
}
