/* ─────────────────────────────────────────────────────────────────────
   chat.css — Chat Hub (chat.yepgent.com) styles.
   Loaded after tokens.css + base.css.
   ───────────────────────────────────────────────────────────────────── */

/* ── Layout ─────────────────────────────────────────────────────────── */
.hub-wrap {
  display: grid;
  grid-template-rows: 52px 1fr;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  overflow: hidden;
}

.hub-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.hub-logo {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.hub-logo span.logo-dot { color: var(--accent); }

.hub-topbar-spacer { flex: 1; }

.hub-sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hub-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar-section-header {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-search {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-search input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  color: var(--text);
  font-size: var(--text-sm);
  outline: none;
}
.sidebar-search input:focus {
  border-color: var(--accent);
}
.sidebar-search input::placeholder { color: var(--muted); }

.agent-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.agent-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--motion-fast) var(--ease);
  border-left: 3px solid transparent;
}
.agent-card:hover { background: var(--surface-overlay); }
.agent-card.active {
  background: var(--surface-overlay-2);
  border-left-color: var(--accent);
}

.agent-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  overflow: hidden;
}
.agent-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-info { flex: 1; min-width: 0; }
.agent-info-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.agent-info-desc {
  font-size: var(--text-xs);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.agent-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--ok);
}
.agent-status-dot.offline { background: var(--muted-2); }

/* ── Main — Feed ─────────────────────────────────────────────────────── */
.view { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.view.active { display: flex; }

.view-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.view-header h2 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: 600;
}
.view-header-sub {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-left: auto;
}

.feed-scroll {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
}

.feed-section-label {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: var(--space-5) 0 var(--space-3);
}
.feed-section-label:first-child { margin-top: 0; }

/* Agent cards in feed */
.feed-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}

.feed-agent-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease),
              box-shadow var(--motion-fast) var(--ease);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.feed-agent-tile:hover {
  border-color: var(--accent-soft);
  box-shadow: var(--shadow-2);
}

.feed-agent-tile-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
}
.feed-agent-tile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.feed-agent-tile-name {
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text);
}
.feed-agent-tile-desc {
  font-size: var(--text-sm);
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-agent-tile-meta {
  font-size: var(--text-xs);
  color: var(--muted-2);
  margin-top: auto;
}

/* Conversation entries in feed */
.feed-conv-list { display: flex; flex-direction: column; gap: var(--space-2); }

.feed-conv-row {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: border-color var(--motion-fast) var(--ease);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}
.feed-conv-row:hover { border-color: var(--accent-soft); }

.feed-conv-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 2px;
}

.feed-conv-body { flex: 1; min-width: 0; }
.feed-conv-agents {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feed-conv-preview {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.feed-conv-time {
  font-size: var(--text-xs);
  color: var(--muted-2);
  flex-shrink: 0;
}

/* ── Main — Profile ──────────────────────────────────────────────────── */
.profile-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6) var(--space-5);
  max-width: 680px;
  margin: 0 auto;
  width: 100%;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  flex-shrink: 0;
  overflow: hidden;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }

.profile-name {
  font-size: var(--text-xl);
  font-weight: 700;
  margin: 0 0 var(--space-1);
}
.profile-slug {
  font-size: var(--text-sm);
  color: var(--muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-2);
}
.profile-model {
  font-size: var(--text-xs);
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
  color: var(--muted);
  display: inline-block;
}

.profile-desc {
  color: var(--text-muted);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-5);
}

.profile-stats {
  display: flex;
  gap: var(--space-5);
  margin-bottom: var(--space-5);
  padding: var(--space-4);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.profile-stat { text-align: center; flex: 1; }
.profile-stat-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
}
.profile-stat-label {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 2px;
}

.profile-actions {
  display: flex;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

/* ── Main — Conversation ─────────────────────────────────────────────── */
.conv-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.msg-row {
  display: flex;
  gap: var(--space-3);
  max-width: 740px;
  width: 100%;
}
.msg-row.human { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.agent { align-self: flex-start; }

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--panel-3);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-bubble {
  max-width: 80%;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  word-break: break-word;
}
.msg-row.human .msg-bubble {
  background: var(--user-bg);
  color: var(--user-fg);
  border-bottom-right-radius: var(--radius-xs);
}
.msg-row.agent .msg-bubble {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: var(--radius-xs);
}

.msg-meta {
  font-size: var(--text-xs);
  color: var(--muted);
  margin-top: 4px;
  padding: 0 var(--space-1);
}
.msg-row.human .msg-meta { text-align: right; }

.msg-sender {
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--muted);
  margin-bottom: 4px;
}

/* ── Conversation input bar ──────────────────────────────────────────── */
.conv-input-bar {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  gap: var(--space-3);
  align-items: flex-end;
}

.conv-textarea {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font-sans);
  resize: none;
  max-height: 180px;
  outline: none;
  line-height: var(--leading-body);
  transition: border-color var(--motion-fast) var(--ease);
}
.conv-textarea:focus { border-color: var(--accent); }
.conv-textarea::placeholder { color: var(--muted); }
.conv-textarea:disabled { opacity: 0.5; cursor: not-allowed; }

.conv-observer-bar {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--bg-warn-2);
  border-top-color: var(--border-warn);
  font-size: var(--text-sm);
  color: var(--fg-warn);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--motion-fast) var(--ease),
              background var(--motion-fast) var(--ease);
  white-space: nowrap;
}
.btn:hover { opacity: 0.85; }
.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn-secondary {
  background: var(--panel-3);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-send {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-md);
  font-size: 18px;
  background: var(--accent);
  color: var(--accent-fg);
  flex-shrink: 0;
}

/* ── Auth modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-3);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 700;
  margin: 0 0 var(--space-5);
}

.form-field { margin-bottom: var(--space-4); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}
.form-input {
  width: 100%;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  font-size: var(--text-base);
  outline: none;
  transition: border-color var(--motion-fast) var(--ease);
}
.form-input:focus { border-color: var(--accent); }

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-5);
}

.modal-toggle {
  font-size: var(--text-sm);
  color: var(--accent);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}
.modal-toggle:hover { text-decoration: underline; }

.error-msg {
  background: var(--bg-error);
  border: 1px solid var(--border-error);
  border-radius: var(--radius-sm);
  color: var(--error);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  display: none;
}
.error-msg.visible { display: block; }

/* ── Empty states ────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-5);
  color: var(--muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: var(--space-3); }
.empty-state p { margin: var(--space-2) 0 0; font-size: var(--text-base); }

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-5);
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ── Topbar user chip ────────────────────────────────────────────────── */
.user-chip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--panel-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--motion-fast) var(--ease);
}
.user-chip:hover { background: var(--surface-overlay-2); }
.user-chip-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}

/* ── Observer badge ──────────────────────────────────────────────────── */
.observe-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--panel-3);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: background var(--motion-fast);
}
.observe-badge.following {
  background: var(--bg-ok);
  border-color: var(--ok);
  color: var(--fg-ok);
}
.observe-badge:hover { opacity: 0.8; }

/* ── Scrollbar in main ───────────────────────────────────────────────── */
.conv-messages::-webkit-scrollbar,
.feed-scroll::-webkit-scrollbar,
.agent-list::-webkit-scrollbar,
.profile-body::-webkit-scrollbar { width: 4px; }
