/* ============================================================
   LAYOUT DE LA PAGE CONFIG
   ============================================================ */

.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.config-page body,
body.config-page {
  background: var(--color-bg);
}

.config-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  margin-top: 24px;
  margin-bottom: 40px;
  align-items: start;
}

/* ============================================================
   BARRE LATÉRALE
   ============================================================ */

.config-sidebar {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: sticky;
  top: 20px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-border-light);
}

.sidebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
}

.btn-add-agent {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-add-agent:hover { background: var(--color-primary-dark); }

.agents-sidebar-list { padding: 6px 0; }

.sidebar-loading {
  padding: 20px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Entrée de la liste */
.sidebar-agent-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-agent-item:hover { background: var(--color-border-light); }

.sidebar-agent-item.is-active {
  background: var(--color-primary-dim);
  border-left-color: var(--color-primary);
}

.sidebar-agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-agent-item.is-disabled .sidebar-agent-avatar {
  background: var(--color-text-light);
}

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

.sidebar-agent-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-agent-specialty {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-agent-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--color-success);
}

.sidebar-agent-item.is-disabled .sidebar-agent-status {
  background: var(--color-text-light);
}

/* ============================================================
   FORMULAIRE PRINCIPAL
   ============================================================ */

.config-main {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* État vide */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 40px;
  gap: 10px;
  text-align: center;
}

.empty-state-icon { font-size: 48px; }
.empty-state-title { font-size: 18px; font-weight: 700; color: var(--color-text); }
.empty-state-desc  { font-size: 13px; color: var(--color-text-muted); }

/* Barre d'outils du formulaire */
.form-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-border-light);
  gap: 12px;
  flex-wrap: wrap;
}

.form-agent-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  margin: 0;
}

.form-toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Formulaire d'édition */
.agent-form { padding: 0; }

.form-section {
  padding: 22px 24px;
  border-bottom: 1px solid var(--color-border-light);
}

.form-section:last-child { border-bottom: none; }

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.section-hint {
  font-size: 12px;
  font-weight: 400;
  color: var(--color-text-muted);
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 5px;
}

.required { color: var(--color-error); }

.form-input {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-dim);
}

select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.form-label-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-left: 4px;
}

/* Note contextuelle sous le sélecteur de provider LLM d'un agent */
.agent-llm-hint {
  font-size: 12px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  margin-top: 6px;
  line-height: 1.5;
}

.agent-llm-hint.hint-demo {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.agent-llm-hint.hint-info {
  background: var(--color-primary-dim);
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  transition: border-color var(--transition);
  line-height: 1.6;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-dim);
}

/* Textarea monospace pour les prompts */
.form-textarea-code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 12.5px;
  background: #fafbfc;
  line-height: 1.7;
}

/* Toggle actif/inactif */
.form-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toggle-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-text-light);
  border-radius: 10px;
  transition: background var(--transition);
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle-switch input:checked + .toggle-track { background: var(--color-success); }
.toggle-switch input:checked + .toggle-track::after { transform: translateX(16px); }

.toggle-hint { font-size: 11px; color: var(--color-text-muted); }

/* Boutons petits */
.btn-sm { padding: 6px 12px; font-size: 12px; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-error);
  background: var(--color-error-dim);
  border: 1px solid #fca5a5;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-danger:hover { background: #fee2e2; }

/* ============================================================
   MODAL DE TEST
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.modal-title { font-size: 15px; font-weight: 700; margin: 0; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--color-text-muted);
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--transition);
}

.modal-close:hover { color: var(--color-error); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.test-result {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.test-result-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--color-text-muted);
  padding: 8px 14px;
  background: var(--color-border-light);
  border-bottom: 1px solid var(--color-border);
}

.test-result-content {
  padding: 14px;
  font-size: 13px;
  line-height: 1.7;
  max-height: 300px;
  overflow-y: auto;
}

.test-loading { text-align: center; padding: 10px 0; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 2000;
  animation: toastIn 200ms ease;
  max-width: 320px;
}

.toast-success { background: var(--color-success); }
.toast-error   { background: var(--color-error); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 720px) {
  .config-layout { grid-template-columns: 1fr; }
  .config-sidebar { position: static; }
  .form-row-2 { grid-template-columns: 1fr; }
}
