/* components.css - Reusable component styles (unified light/dark via variables) */

/* ---- Navbar ---- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.navbar-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.navbar-logo:hover { text-decoration: none; }
.navbar-logo .logo {
  height: 20px;
  width: auto;
}
@media (prefers-color-scheme: dark) {
  .navbar-logo .logo { filter: invert(1); }
}
.navbar-sep {
  color: var(--text-tertiary);
  font-size: 14px;
  flex-shrink: 0;
  user-select: none;
}
.navbar-crumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
}
.navbar-crumb {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.navbar-crumb a {
  color: var(--text-secondary);
}
.navbar-crumb a:hover {
  color: var(--accent);
}
.navbar-crumb.current {
  color: var(--text-primary);
  font-weight: 500;
}

/* ---- Card ---- */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

/* ---- Badge ---- */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  vertical-align: middle;
}
.repo-badge {
  display: inline-block;
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  border: 1px solid var(--border-light);
}
.conv-badge {
  display: inline-block;
  background: var(--bg-inset);
  color: var(--text-secondary);
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  text-decoration: none;
  border: 1px solid var(--border-light);
}
.conv-badge:hover {
  background: var(--border-light);
  text-decoration: none;
}

/* ---- Status badge (inline) ---- */
.status {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status.queued { background: var(--status-warning-bg); color: var(--status-warning); }
.status.authenticating { background: var(--status-warning-bg); color: var(--status-warning); }
.status.pending { background: var(--status-warning-bg); color: var(--status-warning); }
.status.executing { background: var(--status-info-bg); color: var(--status-info); }
.status.completed.success { background: var(--status-success-bg); color: var(--status-success); }
.status.completed.failed { background: var(--status-error-bg); color: var(--status-error); }

.status-badge {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-badge.live { background: var(--status-success-bg); color: var(--status-success); }
.status-badge.failed { background: var(--status-error-bg); color: var(--status-error); }
.status-badge.reload_pending,
.status-badge.reloading { background: var(--status-info-bg); color: var(--status-info); }

/* ---- Status dot ---- */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.queued { background: var(--status-warning); }
.status-dot.executing { background: var(--status-info); }
.status-dot.success { background: var(--status-success); }
.status-dot.failed { background: var(--status-error); }

/* ---- Status icon ---- */
.status-icon {
  font-size: 13px;
  margin-left: 4px;
}

/* ---- Field ---- */
.field {
  margin-bottom: 14px;
}
.field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 3px;
}
.field-value {
  font-size: 14px;
  color: var(--text-primary);
}
.field-value.mono {
  font-family: var(--font-mono);
}
.field-hint {
  color: var(--text-tertiary);
}

/* ---- Repo status indicator ---- */
.repo-status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.repo-status-indicator.live { background: var(--status-success); }
.repo-status-indicator.failed { background: var(--status-error); }
.repo-status-indicator.reload_pending,
.repo-status-indicator.reloading {
  border: 2px solid var(--status-info);
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}

/* ---- Task card ---- */
.task-card {
  padding: 12px;
  margin-bottom: 8px;
  background: var(--bg-inset);
  border-radius: 4px;
  border-left: 3px solid var(--border);
}
.task-card.queued { border-left-color: var(--status-warning); }
.task-card.pending { border-left-color: var(--status-warning); }
.task-card.executing { border-left-color: var(--status-info); }
.task-card.success { border-left-color: var(--status-success); }
.task-card.failed { border-left-color: var(--status-error); }

/* ---- Reply cards ---- */
.card.reply-error {
  border-color: var(--status-error);
}
.reply-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 14px 0 10px 0;
}
.reply-meta {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

/* ---- Section title (group separator above card groups) ---- */
.section-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 12px;
  margin-top: 24px;
}
.section-title:first-child { margin-top: 0; }

/* ---- Summary grid ---- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.summary-item {
  background: var(--bg-inset);
  padding: 12px;
  border-radius: 6px;
  text-align: center;
  border: 1px solid var(--border-light);
}
.summary-value {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
}
.summary-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

/* ---- Details grid ---- */
.details-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.detail-item {
  background: var(--bg-inset);
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

/* ---- Reply stats ---- */
.reply-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  font-size: 13px;
}
.reply-stat {
  display: flex;
  flex-direction: column;
}
.reply-stat-label {
  font-size: 10px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.reply-stat-value {
  font-family: var(--font-mono);
  color: var(--text-primary);
}

/* ---- Usage grid ---- */
.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.usage-item { font-size: 12px; }
.usage-label {
  color: var(--text-tertiary);
  font-size: 10px;
}
.usage-value {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

/* ---- Action buttons ---- */
.action-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: background-color 0.15s;
  line-height: 1.2;
  box-sizing: border-box;
}
.action-btn.primary {
  background: var(--accent);
  color: #ffffff;
}
.action-btn.primary:hover {
  background: var(--accent-hover);
  text-decoration: none;
}
.stop-btn {
  background: var(--status-error);
  color: #ffffff;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  box-sizing: border-box;
  line-height: 1.2;
}
.stop-btn:hover { background: #a13232; }
.stop-btn:disabled { background: var(--border); cursor: not-allowed; color: var(--text-tertiary); }

/* ---- Stop result ---- */
.stop-result:empty { display: none; }
.stop-result {
  margin-top: 12px;
  padding: 12px;
  border-radius: 6px;
  font-size: 14px;
}
.stop-result.info { background: var(--status-info-bg); color: var(--status-info); }
.stop-result.error { background: var(--status-error-bg); color: var(--status-error); }

/* ---- Todo list ---- */
.todo-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.todo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 4px;
  font-size: 14px;
}
.todo-item.completed { color: var(--status-success); }
.todo-item.in-progress { color: var(--status-info); background: var(--status-info-bg); }
.todo-item.pending { color: var(--text-tertiary); }
.todo-icon {
  font-size: 14px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}
.todo-icon.completed { color: var(--status-success); }
.todo-icon.pending { color: var(--border); }
.todo-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--status-info);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  flex-shrink: 0;
}
.todo-label { line-height: 1.3; }

/* ---- Text content blocks ---- */
.text-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
  margin-top: 12px;
  margin-bottom: 4px;
}
.text-content {
  padding: 0 0 0 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text-primary);
}
.text-content.request { border-left: 3px solid var(--status-info); }
.text-content.response { border-left: 3px solid var(--status-success); }

/* ---- Empty state ---- */
.empty {
  color: var(--text-tertiary);
  font-style: italic;
  padding: 20px;
  text-align: center;
}

/* ---- Error section ---- */
.error-section {
  background: var(--status-error-bg);
  border-left: 3px solid var(--status-error);
  padding: 16px;
  border-radius: 4px;
  margin-top: 16px;
}
.error-type {
  font-family: var(--font-mono);
  color: var(--status-error);
  font-weight: 600;
}
.error-message {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  background: var(--bg-surface);
  padding: 8px;
  border-radius: 4px;
  color: var(--text-primary);
}

/* ---- Subagent (shared across themes) ---- */
.subagent-event {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding-left: 8px;
  border-left: 2px solid var(--subagent-border-color, var(--text-tertiary));
}
.subagent-badge {
  flex: 0 1 auto;
  max-width: min(15%, 140px);
  font-size: 10px;
  color: inherit;
  font-family: var(--font-mono);
  direction: rtl;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subagent-content {
  flex: 1;
  min-width: 0;
}

/* ---- Stream status ---- */
.stream-status {
  position: fixed;
  bottom: 12px;
  right: 16px;
  font-size: 11px;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  padding: 4px 10px;
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

/* ---- Refresh notice ---- */
.refresh-notice {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 20px;
}
