/* agents.css — inherits design tokens from slides.css */
:root {
  --accent: #8b5cf6;
  --accent-2: #6ea8ff;
}

/* Legacy .btn aliases — used by agents.js dynamic button creation */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius-xs);
  font-size: 12.5px; font-weight: 500; font-family: inherit;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--fg);
  cursor: pointer; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.btn:hover { background: var(--bg-elev-2); border-color: var(--line-2); }
.btn-primary { background: var(--accent); border-color: transparent; color: white; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--hover); }
.btn-ghost.danger:hover { border-color: var(--danger); color: var(--danger); background: rgba(248,113,113,.07); }
.btn-sm { padding: 4px 8px; font-size: 11.5px; }

/* ── Agents shell ── */
.agents-shell {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
}

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

.agents-empty {
  text-align: center; color: var(--fg-mute);
  padding: 60px 20px; font-size: 14px; margin: 0;
}
.agents-empty[hidden] { display: none; }
.agents-empty a { color: var(--accent); font-weight: 600; }

/* ── Agent card ── */
.agent-card {
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  display: flex; flex-direction: column; gap: 12px;
}
.agent-card:hover {
  border-color: var(--line-2);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0,0,0,.3);
}

.agent-card-header {
  display: flex; align-items: center; gap: 12px;
}
.agent-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: white;
  flex-shrink: 0;
}
.agent-card-info { flex: 1; min-width: 0; }
.agent-card-name {
  font-size: 15px; font-weight: 700; margin: 0; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agent-card-desc {
  font-size: 12px; color: var(--fg-mute); margin: 3px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.agent-card-caps {
  display: flex; flex-wrap: wrap; gap: 4px;
}
.cap-badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px;
  background: rgba(139,92,246,.1); color: var(--accent);
  border: 1px solid rgba(139,92,246,.18);
}

.agent-card-actions {
  display: flex; gap: 6px; margin-top: auto;
}
.agent-card-actions .ds-btn { flex: 1; justify-content: center; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.55); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  width: 100%; max-width: 520px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  max-height: 85vh;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.modal-header h2 { font-size: 18px; margin: 0; color: var(--fg); }
.modal-close {
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  border: none; background: transparent;
  color: var(--fg-mute); cursor: pointer; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.modal-close:hover { background: var(--hover); color: var(--fg); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 16px; }
.modal-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--line);
}
.spacer { flex: 1; }

/* ── Form fields ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
  font-size: 12px; font-weight: 700; color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: .04em;
}
.form-input {
  width: 100%; font: inherit; font-size: 13px; color: var(--fg);
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius-xs); padding: 8px 11px; outline: none;
  transition: border-color var(--dur) var(--ease);
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--fg-mute); }
textarea.form-input { resize: vertical; min-height: 80px; line-height: 1.55; }
.form-hint { font-size: 12px; color: var(--fg-dim); margin: 0; }

/* ── Color picker ── */
.color-options { display: flex; gap: 8px; flex-wrap: wrap; }
.color-option {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid transparent; cursor: pointer;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  padding: 0;
}
.color-option:hover { transform: scale(1.12); }
.color-option.active { border-color: white; }

/* ── Capability checkboxes ── */
.cap-options { display: flex; flex-wrap: wrap; gap: 8px; }
.cap-option {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 11px; border-radius: var(--radius-xs);
  background: var(--bg-elev); border: 1px solid var(--line);
  cursor: pointer; font-size: 13px; color: var(--fg-mute);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease);
  user-select: none;
}
.cap-option:hover { border-color: var(--line-2); color: var(--fg); }
.cap-option.active {
  border-color: var(--accent);
  background: rgba(139,92,246,.1);
  color: var(--fg);
}
.cap-option input { display: none; }

/* ── API key notice ── */
.api-notice {
  padding: 12px 16px;
  background: rgba(251,191,36,.07);
  border: 1px solid rgba(251,191,36,.2);
  border-radius: var(--radius-sm);
  font-size: 13px; color: var(--warning);
  display: flex; align-items: center; gap: 8px;
}
.api-notice[hidden] { display: none; }
.api-notice a { color: var(--warning); font-weight: 600; text-decoration: underline; }

/* ── Template gallery ── */
.modal-wide { max-width: 800px; }
.modal-subtitle { font-size: 12px; color: var(--fg-mute); margin: 3px 0 0; }
.template-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.template-card {
  padding: 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color var(--dur) var(--ease);
}
.template-card:hover { border-color: var(--line-2); }
.template-card .ds-btn { width: 100%; justify-content: center; margin-top: auto; }

/* ── Responsive ── */
@media (max-width: 700px) {
  /* Layout */
  .app { grid-template-columns: 1fr; }
  .rail { display: none; }

  /* Topbar */
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  .crumbs { flex: 1 1 auto; }
  .topbar-actions { flex: 1 1 auto; justify-content: flex-end; }
  .topbar-divider { display: none; }
  #presenceBarDoc { display: none !important; }

  /* Shell & grid */
  .agents-shell { padding: 12px 14px; }
  .agents-grid { grid-template-columns: 1fr; }

  /* Cards: larger tap targets */
  .agent-card { padding: 16px; }
  .agent-card-actions .ds-btn { padding: 8px 12px; }

  /* Modal: bottom sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 90vh;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
  }
  .modal-header { padding: 16px 16px 12px; }
  .modal-header h2 { font-size: 16px; }
  .modal-body { padding: 16px; gap: 14px; }
  .modal-footer { padding: 12px 16px 24px; }

  /* Bottom padding for nav bar */
  body::after { content: ''; display: block; height: 60px; }
}

/* Bottom nav (mobile only) */
.mobile-bottom-nav { display: none; }
@media (max-width: 700px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: var(--bg-elev);
    border-top: 1px solid var(--line);
    z-index: 100;
    align-items: center;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding: 0 12px; gap: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--fg-mute);
    text-decoration: none;
    padding: 6px 10px;
    border-radius: var(--radius-xs);
    transition: color var(--dur);
    min-width: 56px; flex-shrink: 0;
    text-align: center;
  }
  .mobile-nav-item[data-active] { color: var(--accent); }
  .mobile-nav-item svg { flex-shrink: 0; }
}
