/* public/style.css — mobile-first chat UI, themed via --brand-* custom properties.
   Defaults below are the "default" client palette; chat.js overrides them per client. */

:root {
  --brand-bg:        #181a1c;
  --brand-surface:   #1d2228;
  --brand-surface-2: #2b3035;
  --brand-muted:     #56616a;
  --brand-text:      #d3d8d8;
  --brand-accent:    #3f9a9a;
  --brand-accent-2:  #e0b94c;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--brand-bg);
  color: var(--brand-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;          /* 16px keeps iOS from zooming the input on focus */
  line-height: 1.4;
}

/* Mobile-first: fill the viewport. On wider screens, cap to a centered card. */
#chat-container {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--brand-surface);
}

@media (min-width: 520px) {
  #chat-container {
    height: min(100dvh, 720px);
    margin: max(0px, calc((100dvh - 720px) / 2)) auto;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }
}

/* Header */
#chat-header {
  padding: 16px 20px;
  background: var(--brand-surface-2);
  border-bottom: 2px solid var(--brand-accent-2);
}

#chat-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}

#chat-header p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--brand-muted);
}

/* Message list — the scrollable, flexible region */
#messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* A message = wrapper (.message, handles alignment) + .bubble (text) + .timestamp */
.message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 2px;
}

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

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;     /* preserve newlines from replies */
  overflow-wrap: anywhere;   /* wrap long URLs / unbroken strings */
}

.message.assistant .bubble {
  background: var(--brand-surface-2);
  color: var(--brand-text);
  border-bottom-left-radius: 4px;
}

.message.user .bubble {
  background: var(--brand-accent);
  color: #0d1416;
  border-bottom-right-radius: 4px;
}

.timestamp {
  font-size: 0.68rem;
  color: var(--brand-muted);
  padding: 0 4px;
}

/* Typing indicator (animated dots) — a bubble with no timestamp */
.bubble.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  border-left: 3px solid var(--brand-accent);
  animation: breathe 1.8s ease-in-out infinite;
}

.bubble.typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand-accent);
  animation: blink 1.2s infinite both;
}

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

.typing-label {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--brand-muted);
  margin-left: 2px;
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0.3; }
  40%           { opacity: 1; }
}

@keyframes breathe {
  0%, 100% { opacity: 0.75; }
  50%       { opacity: 1; }
}

/* Input bar — sticky to the bottom, with safe-area padding for notched phones */
#input-area {
  display: flex;
  gap: 8px;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--brand-surface-2);
  border-top: 1px solid var(--brand-muted);
}

#user-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--brand-muted);
  border-radius: 22px;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-size: 1rem;
}

#user-input::placeholder { color: var(--brand-muted); }

#user-input:focus {
  outline: none;
  border-color: var(--brand-accent-2);
}

#send-btn {
  flex: 0 0 auto;
  padding: 0 20px;
  border: none;
  border-radius: 22px;
  background: var(--brand-accent);
  color: #0d1416;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

#send-btn:hover { background: var(--brand-accent-2); }

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