/* ============================================================
   Hermes Chat — Mobile-first styles
   ============================================================ */

:root {
  --bg-primary:   #0f172a;
  --bg-secondary: #1e293b;
  --bg-bubble-user: #3b82f6;
  --bg-bubble-ai:  #334155;
  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --accent:         #3b82f6;
  --border:         #1e293b;
  --radius:         16px;
  --safe-bottom:    env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* ── App layout ─────────────────────────────────────────── */

.app-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 720px;
  margin: 0 auto;
  border-left:  1px solid var(--border);
  border-right: 1px solid var(--border);
}

/* ── Header ─────────────────────────────────────────────── */

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

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

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.chat-header h1 {
  font-size: 16px;
  font-weight: 600;
}

.status {
  font-size: 12px;
  color: #22c55e;
}

.btn-clear {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 6px 8px;
  border-radius: 8px;
  transition: background 0.15s;
}
.btn-clear:hover {
  background: rgba(255,255,255,0.08);
}

/* ── Messages ───────────────────────────────────────────── */

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  -webkit-overflow-scrolling: touch;
}

.message {
  display: flex;
  max-width: 90%;
}

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

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

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  word-break: break-word;
}

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

.message.assistant .bubble {
  background: var(--bg-bubble-ai);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.bubble p {
  margin: 0;
}

/* ── Typing indicator ───────────────────────────────────── */

.typing .bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 18px;
}

.dot {
  width: 7px;
  height: 7px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: dotPulse 1.4s infinite ease-in-out both;
}
.dot:nth-child(1) { animation-delay: 0.0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40%           { transform: scale(1);   opacity: 1;   }
}

/* ── Input bar ──────────────────────────────────────────── */

.chat-input-bar {
  flex-shrink: 0;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border-radius: 24px;
  padding: 4px 4px 4px 18px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
}
.input-row:focus-within {
  border-color: var(--accent);
}

#messageInput {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-size: 15px;
  padding: 8px 0;
  min-width: 0;
}
#messageInput::placeholder {
  color: var(--text-secondary);
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.btn-send:hover {
  background: #2563eb;
}
.btn-send:active {
  transform: scale(0.93);
}
.btn-send.disabled {
  background: #475569;
  cursor: not-allowed;
}

/* ── Responsive tweaks ──────────────────────────────────── */

@media (min-width: 768px) {
  .message {
    max-width: 70%;
  }
  .chat-messages {
    padding: 20px 24px;
  }
}

@media (max-width: 400px) {
  .chat-header h1 { font-size: 14px; }
  .bubble { font-size: 14px; padding: 8px 12px; }
}