/* ============================================================
   Agent Registry — style.css
   Clean, professional dark-navy header + white card layout
   ============================================================ */

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

:root {
  --navy: #0f1e3c;
  --navy-light: #1a2f5e;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --bg: #f1f5f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --badge-owner-bg: #dbeafe;
  --badge-owner-text: #1d4ed8;
  --badge-operator-bg: #dcfce7;
  --badge-operator-text: #166534;
  --badge-skill-bg: #f3e8ff;
  --badge-skill-text: #6b21a8;
}

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ── Header ── */
header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: white;
  padding: 24px 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

header .brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

header .brand-icon {
  width: 44px;
  height: 44px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

header .subtitle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}

header .stats-bar {
  display: flex;
  gap: 24px;
  align-items: center;
}

header .stat {
  text-align: center;
}

header .stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
}

header .stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Main container ── */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 24px 60px;
}

/* ── Toolbar ── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 14px;
  min-width: 240px;
}

.search-box input {
  border: none;
  outline: none;
  font-size: 0.9rem;
  color: var(--text);
  background: transparent;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* ── Agent grid ── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 24px;
}

/* ── Agent card ── */
.agent-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.agent-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title-area {
  flex: 1;
  min-width: 0;
}

.agent-name {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-description {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.skill-count-badge {
  background: var(--badge-skill-bg);
  color: var(--badge-skill-text);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.card-body {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

/* Owner section */
.owner-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  background: var(--badge-owner-bg);
  color: var(--badge-owner-text);
}

.owner-info {
  flex: 1;
  min-width: 0;
}

.owner-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

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

.role-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.role-badge.owner {
  background: var(--badge-owner-bg);
  color: var(--badge-owner-text);
}

.role-badge.operator {
  background: var(--badge-operator-bg);
  color: var(--badge-operator-text);
}

/* Operators section */
.operators-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.operators-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.operators-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.operator-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-radius: 6px;
  padding: 6px 10px;
}

.operator-avatar {
  width: 26px;
  height: 26px;
  background: var(--badge-operator-bg);
  color: var(--badge-operator-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.operator-info {
  flex: 1;
  min-width: 0;
}

.operator-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
}

.operator-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-operators {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Loading & error states ── */
.state-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 16px;
  color: var(--text-muted);
}

.state-container .state-icon {
  font-size: 3rem;
}

.state-container p {
  font-size: 1rem;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 1rem;
}

/* ── Responsive ── */
@media (max-width: 640px) {
  header {
    flex-direction: column;
    gap: 16px;
    padding: 20px;
    text-align: center;
  }

  header .stats-bar {
    gap: 16px;
  }

  main {
    padding: 20px 16px 40px;
  }

  .agents-grid {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: unset;
  }
}
