/* ── Agents page ── */

.agent-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ── */
.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
}
.agent-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
  letter-spacing: -0.02em;
}
.agent-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #144629;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.agent-new-btn:hover { opacity: 0.85; }

/* ── Main content ── */
#agents-content {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── Cards (attention + in-flight) ── */
.agent-card {
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.08);
  overflow: hidden;
}
.agent-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}
.agent-card-head-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-card-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.agent-card-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-badge-count {
  font-size: 11px;
  font-weight: 700;
  padding: 0 7px;
  height: 20px;
  line-height: 20px;
  border-radius: 10px;
  text-align: center;
}
.agent-attn-dismiss-all {
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  color: #92400e;
  background: rgba(251, 191, 36, 0.15);
  border: none;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s;
  white-space: nowrap;
}
.agent-attn-dismiss-all:hover { background: rgba(251, 191, 36, 0.25); }

/* ── Attention card ── */
.agent-card-attention {
  background: #fffbeb;
  border: none;
}
.agent-card-attention .agent-card-head {
  border-bottom: none;
}
.agent-card-attention .agent-card-label { color: #92400e; }
.agent-card-attention .agent-badge-count {
  background: #fbbf24;
  color: #78350f;
}
.agent-icon-warning { color: #f59e0b; }

.agent-attn-list {
  display: flex;
  flex-direction: column;
}
.agent-attn-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
}
a.agent-attn-row:hover { background: rgba(251, 191, 36, 0.08); }

.agent-attn-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.agent-attn-dot-amber { background: #f59e0b; }
.agent-attn-dot-red { background: #ef4444; }

.agent-attn-text {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #1a1a1a;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-attn-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.agent-attn-badge-fail {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}
.agent-attn-time {
  font-size: 11px;
  color: #b45309;
  flex-shrink: 0;
  white-space: nowrap;
}
.agent-attn-chevron {
  flex-shrink: 0;
  color: #d97706;
  opacity: 0.4;
}
a.agent-attn-row:hover .agent-attn-chevron { opacity: 1; }

/* Stale items (older than 3 days) */
.agent-attn-stale { opacity: 0.55; }
.agent-attn-stale:hover { opacity: 0.8; }

/* Overflow items hidden by default, shown on expand */
.agent-attn-overflow { display: none; }
.agent-attn-expanded .agent-attn-overflow { display: flex; }

.agent-attn-expand {
  display: block;
  width: 100%;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #92400e;
  background: rgba(251, 191, 36, 0.08);
  border: none;
  cursor: pointer;
  transition: background 0.1s;
}
.agent-attn-expand:hover { background: rgba(251, 191, 36, 0.15); }

/* ── In-flight card ── */
.agent-card-live {
  background: rgba(20, 70, 41, 0.03);
  border-color: rgba(20, 70, 41, 0.12);
}
.agent-card-live .agent-card-head {
  border-bottom: 1px solid rgba(20, 70, 41, 0.06);
}
.agent-card-live .agent-card-label { color: #144629; }
.agent-card-live .agent-badge-count {
  background: rgba(20, 70, 41, 0.1);
  color: #144629;
}

.agent-live-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #16a34a;
  animation: agent-pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes agent-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

.agent-live-list {
  display: flex;
  flex-direction: column;
}
.agent-live-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s;
  border-bottom: 1px solid rgba(20, 70, 41, 0.04);
}
.agent-live-row:last-child { border-bottom: none; }
a.agent-live-row:hover { background: rgba(20, 70, 41, 0.04); }

.agent-live-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(20, 70, 41, 0.08);
  color: #144629;
  flex-shrink: 0;
}
.agent-live-icon-chat { background: rgba(37, 99, 235, 0.08); color: #2563eb; }
.agent-live-icon-task { background: rgba(124, 58, 237, 0.08); color: #7c3aed; }

.agent-live-info { flex: 1; min-width: 0; }
.agent-live-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-live-meta {
  display: block;
  font-size: 11px;
  color: #888;
  margin-top: 1px;
}

.agent-live-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #16a34a;
  animation: agent-pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

/* ── Sections (schedules, suggested, activity) ── */
.agent-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.agent-section-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0;
}
.agent-section-count {
  font-size: 11px;
  font-weight: 600;
  color: #999;
  background: rgba(0,0,0,0.04);
  padding: 1px 7px;
  border-radius: 10px;
}

/* ── Schedule cards ── */
.agent-sched-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-sched-card {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.07);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.agent-sched-card:hover {
  border-color: rgba(20, 70, 41, 0.2);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.agent-sched-paused {
  opacity: 0.6;
}
.agent-sched-paused:hover { opacity: 0.8; }

.agent-sched-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.agent-sched-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}
.agent-sched-name {
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.agent-badge-paused {
  font-size: 9px;
  font-weight: 700;
  color: #999;
  background: rgba(0,0,0,0.05);
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.agent-sched-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.agent-sched-freq {
  font-size: 12px;
  color: #888;
}
.agent-sched-next {
  font-size: 12px;
  color: #999;
}
.agent-sched-next::before {
  content: '·';
  margin-right: 8px;
  color: #ccc;
}
.agent-overdue {
  color: #dc2626;
  font-weight: 600;
}

/* Run history */
.agent-sched-history {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.agent-sched-history-label {
  font-size: 10px;
  font-weight: 600;
  color: #bbb;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.agent-sched-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}
.agent-run-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e5e7eb;
  cursor: default;
  transition: transform 0.1s;
}
.agent-run-dot:hover { transform: scale(1.5); }
.agent-run-dot.success { background: #4ade80; }
.agent-run-dot.fail { background: #f87171; }
.agent-run-dot.running { background: #fbbf24; animation: agent-pulse 1.5s ease-in-out infinite; }
.agent-run-dot.pending { background: #e5e7eb; }

/* Schedule action buttons */
.agent-sched-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,0.04);
}
.agent-sched-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: #666;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.1s, color 0.1s;
}
.agent-sched-btn:hover {
  background: rgba(0,0,0,0.03);
  color: #333;
}

/* ON/OFF toggle */
.agent-toggle-form {
  display: inline-flex;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
}
.agent-toggle {
  display: block;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  position: relative;
  transition: background 0.2s;
  cursor: pointer;
}
.agent-toggle[data-enabled="true"] { background: #144629; }
.agent-toggle[data-enabled="false"] { background: #d1d5db; }
.agent-toggle::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.agent-toggle[data-enabled="true"]::after { left: 18px; }
.agent-toggle[data-enabled="false"]::after { left: 2px; }

/* ── Suggested cards ── */
.agent-suggest-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.agent-suggest-card {
  padding: 14px 16px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.06);
  background: #fff;
}
.agent-suggest-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.agent-source {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 4px;
}
.agent-source-email { color: #1d4ed8; background: rgba(37, 99, 235, 0.08); }
.agent-source-calendar { color: #6d28d9; background: rgba(124, 58, 237, 0.08); }
.agent-source-pattern { color: #92400e; background: rgba(245, 158, 11, 0.08); }
.agent-source-room { color: #144629; background: rgba(20, 70, 41, 0.08); }

.agent-confidence {
  font-size: 11px;
  color: #999;
  font-weight: 500;
}
.agent-suggest-title {
  font-size: 14px;
  font-weight: 500;
  color: #1a1a1a;
  line-height: 1.4;
  margin-bottom: 4px;
}
.agent-suggest-reason {
  font-size: 12px;
  color: #888;
  line-height: 1.5;
  margin-bottom: 10px;
}
.agent-suggest-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.agent-btn-start {
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: #144629;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.12s;
}
.agent-btn-start:hover { opacity: 0.85; }
.agent-btn-dismiss {
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  color: #999;
  background: transparent;
  border: none;
  text-decoration: none;
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.12s;
}
.agent-btn-dismiss:hover { color: #555; }

/* ── Activity feed ── */
.agent-activity-feed {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.agent-activity-date {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #bbb;
  margin-bottom: 6px;
}
.agent-activity-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  transition: background 0.1s;
  margin-bottom: 2px;
}
.agent-activity-row:hover { background: rgba(0,0,0,0.015); }

.agent-activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}
.agent-activity-dot.ok { background: #4ade80; }
.agent-activity-dot.fail { background: #f87171; }

.agent-activity-body { flex: 1; min-width: 0; }
.agent-activity-headline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}
.agent-activity-name {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}
.agent-activity-status {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.agent-activity-status.ok { color: #166534; background: rgba(20, 70, 41, 0.08); }
.agent-activity-status.fail { color: #b91c1c; background: rgba(239, 68, 68, 0.06); }

.agent-activity-detail {
  font-size: 12px;
  color: #999;
  line-height: 1.5;
}
.agent-activity-error { color: #dc2626; }

.agent-activity-link {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  color: #144629;
  text-decoration: none;
  padding: 3px 10px;
  background: rgba(20, 70, 41, 0.05);
  border-radius: 6px;
  margin-top: 2px;
  transition: background 0.12s;
}
.agent-activity-link:hover { background: rgba(20, 70, 41, 0.1); }

/* ── Empty states ── */
.agent-empty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  border-radius: 12px;
  border: 1px dashed rgba(0,0,0,0.1);
  text-align: center;
  color: #999;
}
.agent-empty-card svg { opacity: 0.3; }
.agent-empty-text-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: #666;
  margin: 0 0 4px;
}
.agent-empty-text-group p {
  font-size: 13px;
  color: #999;
  margin: 0;
  line-height: 1.4;
}
.agent-empty-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #144629;
  border-radius: 8px;
  text-decoration: none;
  transition: opacity 0.15s;
}
.agent-empty-cta:hover { opacity: 0.85; }
.agent-muted-text {
  font-size: 13px;
  color: #bbb;
  margin: 0;
  padding: 8px 0;
}

/* ── Mobile ── */
@media (max-width: 700px) {
  .agent-page { padding: 0 16px; }
  .agent-sched-card { padding: 12px 14px; }
  .agent-attn-text { font-size: 12px; }
  .agent-attn-time { display: none; }
  .agent-activity-headline { flex-wrap: wrap; }
}

/* ── Dark mode ── */
[data-theme="wistful_juniper"],
[data-theme="deep_current"] {
  .agent-header h1 { color: var(--color-text-primary); }
  .agent-new-btn { background: var(--color-brand); color: var(--color-brand-text); }

  /* Cards */
  .agent-card { border-color: rgba(255,255,255,0.08); }
  .agent-card-attention {
    background: rgba(245, 158, 11, 0.06);
    border: none;
  }
  .agent-card-attention .agent-card-head { border: none; }
  .agent-card-attention .agent-card-label { color: #fbbf24; }
  .agent-card-attention .agent-badge-count { background: rgba(251, 191, 36, 0.2); color: #fbbf24; }
  .agent-icon-warning { color: #fbbf24; }
  .agent-attn-row { border: none; }
  a.agent-attn-row:hover { background: rgba(245, 158, 11, 0.06); }
  .agent-attn-text { color: var(--color-text-primary); }
  .agent-attn-badge { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
  .agent-attn-badge-fail { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
  .agent-attn-time { color: rgba(251, 191, 36, 0.6); }
  .agent-attn-chevron { color: rgba(251, 191, 36, 0.4); }
  .agent-attn-dismiss-all { color: #fbbf24; background: rgba(251, 191, 36, 0.12); }
  .agent-attn-dismiss-all:hover { background: rgba(251, 191, 36, 0.2); }
  .agent-attn-expand { background: rgba(245, 158, 11, 0.06); border: none; color: #fbbf24; }
  .agent-attn-expand:hover { background: rgba(245, 158, 11, 0.12); }

  .agent-card-live {
    background: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.08);
  }
  .agent-card-live .agent-card-head { border-color: rgba(255,255,255,0.04); }
  .agent-card-live .agent-card-label { color: var(--color-text-primary); }
  .agent-card-live .agent-badge-count { background: rgba(255,255,255,0.06); color: var(--color-text-secondary); }
  .agent-live-row { border-color: rgba(255,255,255,0.03); }
  a.agent-live-row:hover { background: rgba(255,255,255,0.03); }
  .agent-live-icon { background: rgba(255,255,255,0.06); color: var(--color-text-secondary); }
  .agent-live-icon-chat { background: rgba(59, 130, 246, 0.1); color: #93c5fd; }
  .agent-live-icon-task { background: rgba(139, 92, 246, 0.1); color: #c4b5fd; }
  .agent-live-name { color: var(--color-text-primary); }
  .agent-live-meta { color: var(--color-text-muted); }

  /* Section heads */
  .agent-section-head h2 { color: var(--color-text-primary); }
  .agent-section-count { background: rgba(255,255,255,0.06); color: var(--color-text-muted); }

  /* Schedule cards */
  .agent-sched-card {
    background: rgba(255,255,255,0.02);
    border-color: rgba(255,255,255,0.06);
  }
  .agent-sched-card:hover { border-color: rgba(255,255,255,0.12); box-shadow: 0 1px 4px rgba(0,0,0,0.2); }
  .agent-sched-name { color: var(--color-text-primary); }
  .agent-sched-freq { color: var(--color-text-muted); }
  .agent-sched-next { color: var(--color-text-muted); }
  .agent-sched-next::before { color: rgba(255,255,255,0.15); }
  .agent-badge-paused { background: rgba(255,255,255,0.06); color: var(--color-text-muted); }
  .agent-sched-history-label { color: var(--color-text-muted); }
  .agent-run-dot { background: rgba(255,255,255,0.08); }
  .agent-run-dot.success { background: #4ade80; }
  .agent-run-dot.fail { background: #f87171; }
  .agent-sched-actions { border-color: rgba(255,255,255,0.04); }
  .agent-sched-btn { color: var(--color-text-muted); border-color: rgba(255,255,255,0.08); }
  .agent-sched-btn:hover { background: rgba(255,255,255,0.05); color: var(--color-text-primary); }
  .agent-toggle[data-enabled="true"] { background: var(--color-brand); }
  .agent-toggle[data-enabled="false"] { background: rgba(255,255,255,0.12); }
  .agent-overdue { color: #fca5a5; }

  /* Suggested */
  .agent-suggest-card { background: rgba(255,255,255,0.02); border-color: rgba(255,255,255,0.06); }
  .agent-suggest-title { color: var(--color-text-primary); }
  .agent-suggest-reason { color: var(--color-text-secondary); }
  .agent-confidence { color: var(--color-text-muted); }
  .agent-source-email { color: #93c5fd; background: rgba(59, 130, 246, 0.1); }
  .agent-source-calendar { color: #c4b5fd; background: rgba(139, 92, 246, 0.1); }
  .agent-source-pattern { color: #fcd34d; background: rgba(252, 211, 77, 0.08); }
  .agent-source-room { color: var(--color-brand); background: rgba(255,255,255,0.06); }
  .agent-btn-start { background: var(--color-brand); color: var(--color-brand-text); }
  .agent-btn-dismiss { color: var(--color-text-muted); }
  .agent-btn-dismiss:hover { color: var(--color-text-secondary); }

  /* Activity */
  .agent-activity-date { color: var(--color-text-muted); }
  .agent-activity-row:hover { background: rgba(255,255,255,0.02); }
  .agent-activity-name { color: var(--color-text-primary); }
  .agent-activity-status.ok { color: #4ade80; background: rgba(74, 222, 128, 0.1); }
  .agent-activity-status.fail { color: #fca5a5; background: rgba(252, 165, 165, 0.08); }
  .agent-activity-detail { color: var(--color-text-muted); }
  .agent-activity-error { color: #fca5a5; }
  .agent-activity-link { color: var(--color-brand); background: rgba(255,255,255,0.05); }
  .agent-activity-link:hover { background: rgba(255,255,255,0.08); }

  /* Empty */
  .agent-empty-card { border-color: rgba(255,255,255,0.06); }
  .agent-empty-text-group h3 { color: var(--color-text-secondary); }
  .agent-empty-text-group p { color: var(--color-text-muted); }
  .agent-empty-cta { background: var(--color-brand); color: var(--color-brand-text); }
  .agent-muted-text { color: var(--color-text-muted); }

  @media (max-width: 700px) {
    .agent-sched-actions { border-color: rgba(255,255,255,0.04); }
  }
}
