/* ── Agent Management ── */

.agents-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Header */
.agents-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border, #30363d);
  flex-shrink: 0;
}

.agents-header-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text, #e6edf3);
}

.agents-btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.1);
  color: var(--accent, #58a6ff);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.agents-btn-add:active {
  background: rgba(88, 166, 255, 0.2);
}

/* Scope Bar */
.agents-scope-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border, #30363d);
  flex-shrink: 0;
}

.agents-scope-btn {
  min-height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--border, #30363d);
  background: transparent;
  color: var(--text-dim, #8b949e);
  font-size: 13px;
  cursor: pointer;
}

.agents-scope-btn.active {
  background: rgba(88, 166, 255, 0.12);
  border-color: var(--accent, #58a6ff);
  color: var(--accent, #58a6ff);
}

.agents-project-picker {
  flex: 1;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  color: var(--text, #e6edf3);
  font-size: 13px;
}

/* List */
.agents-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px;
}

.agents-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
  color: var(--text-dim, #8b949e);
  text-align: center;
  gap: 8px;
}

.agents-empty-icon {
  font-size: 32px;
  opacity: 0.5;
}

/* Card */
.agents-card {
  background: var(--surface, #161b22);
  border: 1px solid var(--border, #30363d);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}

.agents-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.agents-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #e6edf3);
}

.agents-card-actions {
  display: flex;
  gap: 4px;
}

.agents-card-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-dim, #8b949e);
  cursor: pointer;
  padding: 0;
}

.agents-card-action:active {
  background: rgba(255, 255, 255, 0.08);
}

.agents-card-action.delete:active {
  color: #f85149;
}

/* Description snippet */
.agents-card-desc {
  font-size: 12px;
  color: var(--text-dim, #8b949e);
  margin-bottom: 8px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.agents-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Model badges row */
.agents-model-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.agents-model-pill {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim, #8b949e);
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-weight: 500;
}

/* Reuse MCP presence badge styles */
.agents-badges {
  display: flex;
  gap: 4px;
}

.agents-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.agents-badge.present {
  color: #fff;
}

.agents-badge.absent {
  border: 1px solid;
  background: transparent;
  opacity: 0.35;
}

.agents-badge.claude        { background: #6366f1; border-color: #6366f1; }
.agents-badge.claude.absent { color: #6366f1; }
.agents-badge.codex         { background: #22c55e; border-color: #22c55e; }
.agents-badge.codex.absent  { color: #22c55e; }
.agents-badge.gemini        { background: #a855f7; border-color: #a855f7; }
.agents-badge.gemini.absent { color: #a855f7; }

/* ── Form ── */

.agents-form {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.agents-form-section {
  margin-bottom: 20px;
}

.agents-form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim, #8b949e);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.agents-form-input {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  color: var(--text, #e6edf3);
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
}

.agents-form-input:focus {
  outline: none;
  border-color: var(--accent, #58a6ff);
}

.agents-form-select {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  color: var(--text, #e6edf3);
  font-size: 14px;
  appearance: auto;
}

.agents-form-hint {
  font-size: 11px;
  color: var(--text-dim, #8b949e);
  margin-top: 4px;
}

/* Instructions textarea */
.agents-instructions-textarea {
  width: 100%;
  min-height: 200px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  color: var(--text, #e6edf3);
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  white-space: pre-wrap;
  tab-size: 2;
}

.agents-instructions-textarea:focus {
  outline: none;
  border-color: var(--accent, #58a6ff);
}

/* Collapsible tool-specific sections */
.agents-tool-section {
  border: 1px solid var(--border, #30363d);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.agents-tool-section.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.agents-tool-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
  min-height: 42px;
}

.agents-tool-section-header .agents-badge {
  flex-shrink: 0;
}

.agents-tool-section-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e6edf3);
  flex: 1;
}

.agents-tool-section-chevron {
  color: var(--text-dim, #8b949e);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.agents-tool-section.open .agents-tool-section-chevron {
  transform: rotate(180deg);
}

.agents-tool-section-body {
  display: none;
  padding: 12px 14px;
  border-top: 1px solid var(--border, #30363d);
}

.agents-tool-section.open .agents-tool-section-body {
  display: block;
}

/* Deploy-to checkboxes (reuse mcp pattern) */
.agents-tools-grid {
  display: flex;
  gap: 10px;
}

.agents-tool-check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  cursor: pointer;
  flex: 1;
  min-height: 48px;
}

.agents-tool-check.checked {
  border-color: var(--accent, #58a6ff);
  background: rgba(88, 166, 255, 0.08);
}

.agents-tool-check input[type="checkbox"] {
  accent-color: var(--accent, #58a6ff);
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.agents-tool-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #e6edf3);
}

/* Form footer */
.agents-form-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border, #30363d);
  flex-shrink: 0;
}

.agents-btn-save {
  width: 100%;
  min-height: 48px;
  border-radius: 10px;
  border: none;
  background: var(--accent, #58a6ff);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.agents-btn-save:active {
  opacity: 0.85;
}

.agents-btn-save:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Error banner */
.agents-error {
  margin: 8px 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: #f85149;
  font-size: 13px;
}

/* Paste markdown panel */
.agents-paste-panel {
  padding: 12px 16px 0;
  flex-shrink: 0;
}

.agents-paste-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px dashed var(--border, #30363d);
  background: transparent;
  color: var(--text-dim, #8b949e);
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  justify-content: center;
}

.agents-paste-toggle:active,
.agents-paste-toggle.active {
  border-color: var(--accent, #58a6ff);
  color: var(--accent, #58a6ff);
  border-style: solid;
}

.agents-paste-area {
  margin-top: 10px;
}

.agents-paste-textarea {
  width: 100%;
  min-height: 140px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, #30363d);
  background: var(--surface, #161b22);
  color: var(--text, #e6edf3);
  font-size: 12px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  resize: vertical;
  box-sizing: border-box;
}

.agents-paste-textarea:focus {
  outline: none;
  border-color: var(--accent, #58a6ff);
}

.agents-paste-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}

.agents-paste-parse {
  min-height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  border: none;
  background: var(--accent, #58a6ff);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
}

.agents-paste-parse:active {
  opacity: 0.85;
}

.agents-paste-error {
  margin-top: 6px;
  font-size: 12px;
  color: #f85149;
}

/* Copy/Duplicate Modal */
.agents-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.agents-copy-modal {
  background: var(--bg, #0d1117);
  border: 1px solid var(--border, #30363d);
  border-radius: 16px 16px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.agents-copy-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text, #e6edf3);
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border, #30363d);
}

.agents-copy-section-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim, #8b949e);
  padding: 12px 16px 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.agents-copy-project-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: 40vh;
}

.agents-copy-option {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 48px;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--border, #30363d);
  background: transparent;
  color: var(--text, #e6edf3);
  font-size: 14px;
  cursor: pointer;
}

.agents-copy-option:active {
  background: rgba(88, 166, 255, 0.08);
  color: var(--accent, #58a6ff);
}

.agents-copy-cancel {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 14px 16px;
  border: none;
  border-top: 1px solid var(--border, #30363d);
  background: transparent;
  color: var(--text-dim, #8b949e);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}

.agents-copy-cancel:active {
  background: rgba(255, 255, 255, 0.05);
}

/* Back button in form header */
.agents-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-dim, #8b949e);
  cursor: pointer;
  padding: 0;
  margin-right: 8px;
}

.agents-back-btn:active {
  background: rgba(255, 255, 255, 0.08);
}
