/* ============================================================
   FENUA FLOW — Interface Agent Builder
   Design : sombre, professionnel, minimaliste
   ============================================================ */

/* === RESET & BASE === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Palette couleurs */
  --bg-primary:     #0d1117;
  --bg-secondary:   #161b22;
  --bg-card:        #1c2230;
  --bg-input:       #0d1117;
  --border:         #30363d;
  --border-focus:   #388bfd;

  /* Texte */
  --text-primary:   #e6edf3;
  --text-secondary: #8b949e;
  --text-muted:     #484f58;

  /* Accent */
  --accent:         #2ea043;
  --accent-hover:   #3fb950;
  --accent-danger:  #f85149;
  --accent-warning: #d29922;
  --accent-info:    #388bfd;

  /* Typographie */
  --font-main:  'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:  'JetBrains Mono', 'Fira Code', monospace;

  /* Espacements */
  --radius:     8px;
  --radius-lg:  12px;
  --gap:        24px;
}

html { font-size: 16px; }

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-main);
  line-height: 1.6;
  min-height: 100vh;
}

/* === HEADER === */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 16px var(--gap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-brand .logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-info));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.header-brand h1 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.header-brand span {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: block;
}

.header-status {
  font-size: 0.75rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* === LAYOUT PRINCIPAL === */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: var(--gap);
}

/* === SECTIONS === */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .step-badge {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--accent-info);
}

/* === CARTE FORMULAIRE === */
.form-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--gap);
  margin-bottom: var(--gap);
}

.form-card + .form-card {
  margin-top: 0;
}

/* === CHAMPS DE FORMULAIRE === */
.field-group {
  margin-bottom: 20px;
}

.field-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

label .required {
  color: var(--accent-danger);
  margin-left: 2px;
}

label .hint {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 6px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.875rem;
  padding: 10px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(56, 139, 253, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

select {
  cursor: pointer;
  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 fill='%238b949e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select option {
  background: var(--bg-secondary);
}

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

/* === GRILLE 2 COLONNES === */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* === CHECKBOXES — OUTILS === */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}

.tool-checkbox {
  display: none;
}

.tool-label {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--text-secondary);
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  user-select: none;
}

.tool-label .tool-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.tool-checkbox:checked + .tool-label {
  border-color: var(--accent-info);
  color: var(--text-primary);
  background: rgba(56, 139, 253, 0.08);
}

.tool-label:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

/* === COMPLEXITÉ === */
.complexity-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.complexity-radio {
  display: none;
}

.complexity-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  user-select: none;
}

.complexity-label .complexity-icon { font-size: 1.5rem; }
.complexity-label .complexity-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}
.complexity-label .complexity-desc {
  font-size: 0.7rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.complexity-radio:checked + .complexity-label {
  border-color: var(--accent);
  background: rgba(46, 160, 67, 0.08);
}

.complexity-label:hover {
  border-color: var(--border-focus);
}

/* === SECTION CREDENTIALS (sécurisée) === */
.credentials-warning {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.3);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 16px;
  font-size: 0.8rem;
  color: var(--accent-warning);
  line-height: 1.5;
}

.credentials-warning .warn-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }

.field-masked {
  position: relative;
}

.field-masked input {
  padding-right: 44px;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

.toggle-visibility {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px;
  line-height: 1;
}

.toggle-visibility:hover { color: var(--text-primary); }

/* === BOUTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-main);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card);
}

.btn-danger {
  background: transparent;
  color: var(--accent-danger);
  border-color: rgba(248, 81, 73, 0.4);
}
.btn-danger:hover {
  background: rgba(248, 81, 73, 0.1);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  width: 100%;
}

/* === BARRE D'ACTIONS === */
.actions-bar {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  align-items: center;
  margin-top: var(--gap);
}

/* === FEEDBACK / ALERTES === */
.alert {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-success {
  background: rgba(46, 160, 67, 0.1);
  border: 1px solid rgba(46, 160, 67, 0.3);
  color: var(--accent-hover);
}

.alert-error {
  background: rgba(248, 81, 73, 0.1);
  border: 1px solid rgba(248, 81, 73, 0.3);
  color: var(--accent-danger);
}

.alert-info {
  background: rgba(56, 139, 253, 0.1);
  border: 1px solid rgba(56, 139, 253, 0.3);
  color: var(--accent-info);
}

#feedback-zone {
  min-height: 0;
  transition: all 0.2s;
}

/* === LOADER === */
.loader {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* === RÉSULTAT WORKFLOW === */
#result-block {
  display: none;
  background: var(--bg-secondary);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--gap);
  margin-top: var(--gap);
}

#result-block h3 {
  font-size: 0.875rem;
  color: var(--accent-hover);
  margin-bottom: 12px;
}

#result-json {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  overflow-x: auto;
  max-height: 400px;
  overflow-y: auto;
}

/* === FOOTER === */
footer {
  text-align: center;
  padding: var(--gap);
  font-size: 0.75rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  margin-top: calc(var(--gap) * 2);
}
