/* aeii_agent — design tokens matching aeii_website */

:root {
  --bg:          #0e0f14;
  --surface:     #14161e;
  --surface2:    #1c1e28;
  --border:      rgba(255,255,255,0.09);
  --text:        #dfe0e8;
  --muted:       #6e7085;
  --accent:      #5b7fff;
  --accent-dim:  #1a2850;
  --accent-hover:#7b9fff;
  --green:       #22c55e;
  --green-dim:   #0e2318;
  --danger:      #ef4444;
  --radius:      10px;
  --font:        'Inter', sans-serif;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.6;
  height: 100dvh;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface2); }

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */

input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 0.6rem 0.9rem;
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

/* ── Layout ───────────────────────────────────────────────────────────────── */

.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 100dvh;
  height: 100dvh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}
.sidebar-logo span { color: var(--accent); }

.sidebar-new-btn {
  background: var(--accent-dim);
  color: var(--accent);
  border: none;
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.sidebar-new-btn:hover { background: #22346a; }

.conversations-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.conversations-list::-webkit-scrollbar { width: 4px; }
.conversations-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.conv-item {
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  transition: background 0.12s, color 0.12s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.conv-item:hover { background: var(--surface2); color: var(--text); }
.conv-item.active { background: var(--accent-dim); color: var(--accent); }

.conv-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-item-label[contenteditable="true"] {
  outline: none;
  border-bottom: 1px solid var(--accent);
  white-space: nowrap;
  overflow: hidden;
}

.conv-item-actions {
  display: none;
  flex-shrink: 0;
  gap: 2px;
  align-items: center;
}
.conv-item:hover .conv-item-actions,
.conv-item.active .conv-item-actions { display: flex; }

.conv-action-btn {
  background: none;
  border: none;
  padding: 2px 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: color 0.12s, background 0.12s;
}
.conv-action-btn:hover { color: var(--text); background: rgba(255,255,255,0.07); }
.conv-action-btn.danger:hover { color: var(--danger); }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.user-email {
  font-size: 0.8rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* Chat area */
.chat-area {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.message-row {
  display: flex;
  gap: 1rem;
  padding: 0 2rem;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.message-row.user { justify-content: flex-end; }

.message-bubble {
  max-width: 70%;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  line-height: 1.6;
  font-size: 0.9rem;
}

.message-row.user .message-bubble {
  background: var(--accent-dim);
  color: var(--text);
  border: 1px solid rgba(91,127,255,0.2);
}

.message-row.assistant .message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 100%;
}

/* Skill visualization area inside assistant bubble */
.skill-container {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.skill-commentary {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.875rem;
}

/* Typing indicator */
.typing-dots {
  display: flex;
  gap: 4px;
  padding: 0.5rem 0;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Input bar */
.chat-input-bar {
  padding: 1rem 2rem 1.5rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.input-row textarea {
  resize: none;
  min-height: 44px;
  max-height: 160px;
  border-radius: var(--radius);
  padding: 0.65rem 0.9rem;
  line-height: 1.5;
}

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

/* Empty state */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--muted);
  text-align: center;
  padding: 2rem;
}

.chat-empty h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
}

.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.4rem 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--accent); color: var(--text); }

/* Usage bar */
.usage-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.usage-sep { opacity: 0.4; }
.usage-over { color: var(--danger); }

/* Responsive */
@media (max-width: 700px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .message-row { padding: 0 1rem; }
  .chat-input-bar { padding: 0.75rem 1rem 1rem; }
}
