/**
 * Dynamic Agents UI Styles
 * Estilos para la interfaz de agentes dinámicos
 */

/* Container principal */
#dynamicAgentsView {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header de la vista */
.agents-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.agents-header h2 {
  font-size: 28px;
  line-height: 1.1;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 12px;
}

.agents-header h2 i {
  color: var(--accent-primary);
}

/* Lista de agentes */
#dynamicAgentsList {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
}

/* Tarjeta de agente */
.agent-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color var(--dur) var(--ease);
  box-shadow: var(--shadow-1);
}

.agent-card:hover {
  border-color: var(--accent-primary);
}

.agent-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.agent-icon {
  width: 48px;
  height: 48px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--accent-primary);
  flex-shrink: 0;
}

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

.agent-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-id {
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.agent-status {
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.agent-status.active {
  background: var(--success-wash);
  color: var(--success-text);
}

.agent-status.inactive {
  background: var(--error-wash);
  color: var(--error-text);
}

.agent-card-body {
  margin-bottom: 16px;
}

.agent-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.agent-meta i {
  margin-right: 4px;
}

.agent-triggers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.trigger-badge {
  padding: 4px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.agent-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

/* Botones */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--accent-primary);
  color: var(--accent-on);
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--accent-primary);
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--error);
  color: #fff;
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--dur) var(--ease);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm.btn-danger {
  padding: 6px 12px;
  font-size: 13px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state h3 {
  font-size: 20px;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.empty-state p {
  margin-bottom: 24px;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2);
}

.modal-content.modal-large {
  max-width: 900px;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-btn {
  background: none;
  border: none;
  font-size: 28px;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all var(--dur) var(--ease);
}

.close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-description {
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Form elements */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  transition: all var(--dur) var(--ease);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: var(--ring);
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

/* Examples section */
.examples-section {
  margin-top: 20px;
  padding: 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-sm);
}

.examples-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.example-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.example-chip {
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-pill);
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--dur) var(--ease);
}

.example-chip:hover {
  background: var(--accent-primary);
  color: var(--accent-on);
  border-color: var(--accent-primary);
}

/* Agent details */
.agent-details-grid {
  display: grid;
  gap: 20px;
  margin-bottom: 24px;
}

.detail-section {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.detail-section h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.detail-item:last-child {
  border-bottom: none;
}

.detail-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.detail-value {
  font-size: 13px;
  color: var(--text-primary);
  text-align: right;
}

.text-success {
  color: var(--success-text) !important;
}

.text-danger {
  color: var(--error-text) !important;
}

.api-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.api-badge {
  background: var(--bg-secondary);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.trigger-detail {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--border-color);
}

.trigger-type {
  display: inline-block;
  padding: 4px 8px;
  background: var(--accent-primary);
  color: var(--accent-on);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.trigger-info {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  white-space: pre-wrap;
}

.detail-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Code block */
.code-block {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 20px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  max-height: 500px;
  overflow-y: auto;
}

.code-block code {
  color: var(--text-primary);
}

/* Execution result */
.execution-result {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.result-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
}

.result-item:last-child {
  border-bottom: none;
}

.result-label {
  display: block;
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.result-value {
  display: block;
  font-size: 13px;
  color: var(--text-primary);
}

.result-json {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 12px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  margin-top: 8px;
}

/* Executions list */
.executions-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.execution-item {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.execution-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.execution-id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
}

/* Es un <span>: theme.css fuerza el color de los span con !important */
.execution-status {
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.execution-status.status-success {
  background: var(--success-wash);
  color: var(--success-text) !important;
}

.execution-status.status-error {
  background: var(--error-wash);
  color: var(--error-text) !important;
}

.execution-status.status-timeout {
  background: var(--warning-wash);
  color: var(--warning-text) !important;
}

.execution-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
}

.execution-meta i {
  margin-right: 4px;
}

.execution-error {
  margin-top: 12px;
  padding: 12px;
  background: var(--error-wash);
  border-left: 3px solid var(--error);
  border-radius: 8px;
  font-size: 12px;
  color: var(--error-text);
}


/* Responsive */
@media (max-width: 768px) {
  #dynamicAgentsList {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .agents-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .agent-card-actions {
    flex-direction: column;
  }

  .detail-actions {
    flex-direction: column;
  }
}

