/* Persona Platform — Chat UI (Phase 4.3) */
:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --user-bg: #1f6feb;
  --assistant-bg: #21262d;
  --radius: 12px;
  --max-width: 720px;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: var(--max-width);
  margin: 0 auto;
}

/* Header */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.persona-info { display: flex; align-items: center; gap: 12px; }

.avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.persona-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#persona-name {
  font-size: 1.1rem;
  font-weight: 600;
}

.description {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.3;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

#new-chat-btn {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
#new-chat-btn:hover { background: rgba(88, 166, 255, 0.1); }

/* Messages */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-break: break-word;
  animation: fadeIn 0.2s ease-in;
}

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

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

.message.assistant {
  align-self: flex-start;
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.message.typing {
  color: var(--text-muted);
  font-style: italic;
}

/* Typing dots animation */
.typing-dots span {
  animation: blink 1.4s infinite;
  font-size: 1.2rem;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Welcome message */
.welcome {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
  font-size: 0.95rem;
  line-height: 1.6;
}

.welcome h2 {
  font-size: 1.3rem;
  color: var(--text);
  margin-bottom: 8px;
}

/* Input area */
#input-area {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.status-bar {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  min-height: 1em;
}

#chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#message-input {
  flex: 1;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
}
#message-input:focus {
  outline: none;
  border-color: var(--accent);
}

#send-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
#send-btn:hover:not(:disabled) { opacity: 0.85; }

/* Scrollbar */
#messages::-webkit-scrollbar { width: 6px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* Mobile */
@media (max-width: 600px) {
  #app { max-width: 100%; }
  .message { max-width: 92%; }
  .description { max-width: 160px; }
  .avatar { width: 34px; height: 34px; font-size: 0.85rem; }
}
