/* Apex Protocol - chat UI minimal dark theme.
   Aligne avec philosophie produit : pas de gimmick, focus signal/data. */

:root {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-msg-user: #1f3a5f;
  --bg-msg-assistant: #1c2128;
  --bg-msg-system: #2a1f10;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #1a73e8;
  --accent-hover: #1557b0;
  --green: #2ea043;
  --red: #da3633;
  --yellow: #d29922;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
}

body {
  display: grid;
  grid-template-columns: 280px 1fr;
}

/* Sidebar */
#sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.5px;
  color: var(--text);
}

.brand .tagline {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 13px;
}

#new-conv-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

#new-conv-btn:hover { background: var(--accent-hover); }

#conv-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.conv-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
}

.conv-item:hover { background: rgba(255,255,255,0.04); }
.conv-item.active { background: rgba(26,115,232,0.15); border-color: var(--accent); }

.sidebar-footer {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 0;
}

.link:hover { color: var(--text); }

/* Main chat */
#chat {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

#chat-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 500;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
}
.dot.pending { background: var(--yellow); }
.dot.ok { background: var(--green); }
.dot.err { background: var(--red); }

#messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  flex-direction: column;
  max-width: 800px;
  width: 100%;
}

.msg-content {
  padding: 12px 16px;
  border-radius: 8px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg-content p { margin: 0 0 0.7em 0; }
.msg-content p:last-child { margin-bottom: 0; }

.msg-user {
  align-self: flex-end;
}
.msg-user .msg-content {
  background: var(--bg-msg-user);
  color: white;
  border: 1px solid rgba(255,255,255,0.05);
}

.msg-assistant {
  align-self: flex-start;
}
.msg-assistant .msg-content {
  background: var(--bg-msg-assistant);
  border: 1px solid var(--border);
}

.msg-system .msg-content {
  background: var(--bg-msg-system);
  border: 1px solid #5a3a18;
  font-size: 13px;
  color: #d4b87f;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.msg-user .msg-meta { text-align: right; }

/* Composer */
#composer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--bg-elev);
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

#composer-input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  resize: vertical;
  min-height: 44px;
  max-height: 200px;
  line-height: 1.5;
}

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

.primary {
  padding: 10px 18px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
}

.primary:hover { background: var(--accent-hover); }
.primary:disabled { background: var(--border); cursor: not-allowed; }

/* Loading state */
.msg-loading .msg-content::after {
  content: '...';
  animation: pulse 1.5s infinite;
}

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

/* Mobile */
@media (max-width: 768px) {
  body {
    grid-template-columns: 1fr;
  }
  #sidebar {
    display: none;
  }
}
