/* Commun aux écrans de configuration : formulaire générique, interrupteurs, listes, sous-tableaux, recherche de membre.
   Ordre de chargement fixé dans index.html (ex-style.css découpé : ne pas le changer). */
/* ---------- Formulaire générique ---------- */
/* Le panneau suit la largeur disponible (sidebar + marge mises à part) au
   lieu de rester coincé dans une colonne étroite — le plafond n'intervient
   que sur très grand écran, pour ne pas étirer les lignes de description
   à l'infini. */
.schema-panel { max-width: 1400px; }
.panel-header { margin-bottom: 20px; }
.panel-header h2 { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: 0.01em; }
.panel-header p { max-width: 62ch; }

/* La carte qui porte tout le contenu éditable d'un écran de config — sépare
   "ce qu'on modifie" du titre de page, posé lui directement sur le fond. */
.panel-card {
  position: relative;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 28px 22px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.panel-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cyan), var(--violet) 60%, transparent);
  opacity: 0.6;
}
.banner-slot:empty { display: none; }
.banner {
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 18px;
  font-size: 14px;
}
.banner-error { background: rgba(255, 56, 96, 0.12); border: 1px solid rgba(255, 56, 96, 0.4); color: #ff8fa3; }
.banner-success { background: rgba(46, 204, 113, 0.12); border: 1px solid rgba(46, 204, 113, 0.4); color: #7fe7ab; }
.banner ul { margin: 6px 0 0; padding-left: 20px; }

/* Espacement réduit : chaque .field-row porte déjà son propre padding +
   filet de séparation (voir plus bas), un grand gap ici doublerait l'air
   entre les lignes au lieu de structurer la liste de réglages. */
.form { display: flex; flex-direction: column; gap: 4px; }

/* Chaque champ occupe sa propre ligne pleine largeur, en grille 2 colonnes :
   le label/contrôle à gauche (largeur fixe, confortable pour un switch, un
   champ texte ou un select), l'explication de ce que ça fait à droite — pour
   que la page réponde elle-même à "à quoi ça sert ?" sans renvoyer au README.
   Un filet sépare chaque ligne, comme une liste de réglages. */
.field-row {
  display: grid;
  grid-template-columns: minmax(0, 400px) 1fr;
  column-gap: 28px;
  row-gap: 6px;
  align-items: start;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.field-row:last-child { border-bottom: none; padding-bottom: 0; }
.field-row:first-child { padding-top: 0; }
.field-control { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-control > label, .field-row-label { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.field-description { color: var(--text-muted); font-size: 13px; line-height: 1.6; max-width: 56ch; margin: 0; padding-top: 2px; }

input[type="text"], input[type="number"], textarea, select {
  background: var(--bg-elevated-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  width: 100%;
  max-width: 480px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15);
}
textarea { resize: vertical; min-height: 70px; max-width: 100%; }

.input-with-counter { position: relative; max-width: 480px; }
.input-with-counter input, .input-with-counter textarea { max-width: 100%; }
.char-counter { display: block; text-align: right; font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* Interrupteur (booléens) */
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; width: fit-content; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.toggle-track {
  width: 40px; height: 22px; border-radius: 999px; background: var(--bg-elevated-2);
  border: 1px solid var(--border); position: relative; flex-shrink: 0; transition: background 0.15s;
}
.toggle-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: var(--text-muted); transition: transform 0.15s, background 0.15s;
}
.toggle input:checked + .toggle-track { background: rgba(0, 229, 255, 0.2); border-color: var(--cyan); }
.toggle input:checked + .toggle-track::after { transform: translateX(18px); background: var(--cyan); box-shadow: 0 0 8px var(--glow-cyan); }
.toggle-label { font-size: 14px; font-weight: 400; color: var(--text); }

/* Listes à cocher (rôles, filtre Twitch) */
.checklist { display: flex; flex-direction: column; gap: 4px; max-width: 480px; max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.checklist-item { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 14px; cursor: pointer; }
.checklist-item:hover { background: var(--bg-elevated-2); }
.color-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* Mots-clés (string-list) */
.string-list { max-width: 480px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-elevated-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 13px;
}
.chip-remove { background: none; border: none; color: var(--text-muted); border-radius: 50%; width: 18px; height: 18px; font-size: 11px; }
.chip-remove:hover { color: var(--red); }
.chip-add { display: flex; gap: 8px; }
.chip-add input { flex: 1; }

/* Tableaux de sous-lignes (subtable / list) */
/* Les tableaux (rôles par niveau, annuaire...) sont posés en retrait dans
   leur propre renfoncement — ils forment un sous-groupe distinct des champs
   simples au lieu de se fondre dans le même bloc. */
.subtable-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-elevated-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.subtable { display: flex; flex-direction: column; gap: 6px; overflow-x: auto; }
.subtable-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) 44px; gap: 10px; align-items: center; }
.subtable-header { font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.subtable-row:not(.subtable-header) { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.subtable-cell input, .subtable-cell select, .subtable-cell textarea { max-width: 100%; }
.subtable-cell-actions { display: flex; justify-content: center; }
.readonly-value { color: var(--text-muted); font-size: 14px; }

/* Ajout d'une chaîne Twitch/YouTube suivie directement depuis le site
   (voir field.addVia dans schemas.js) : un champ + bouton, pas une ligne de
   tableau vide — la résolution se fait côté serveur avant toute insertion. */
.add-via-row { display: flex; gap: 8px; }
.add-via-row input { flex: 1; max-width: 320px; }
.add-via-error { color: var(--red); margin: 6px 0 0; }
.add-via-error:empty { display: none; }

/* Recherche de membre (annuaire) */
.member-cell { position: relative; min-width: 180px; }
.member-name { font-weight: 700; }
.member-dropdown {
  /* position: fixed (pas absolute) : top/left/width posés en JS depuis les
     coordonnées réelles du champ (voir positionMemberDropdown dans app.js).
     Un .panel-card a overflow:hidden (pour son liseré du haut) — en absolute,
     une carte courte (ex. fiche membre avant sélection) rognait la liste. */
  position: fixed; z-index: 30;
  background: var(--bg-elevated-2); border: 1px solid var(--border); border-radius: 8px;
  max-height: 220px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.member-dropdown.hidden { display: none; }
.member-option {
  display: block; width: 100%; text-align: left; background: none; border: none;
  color: var(--text); padding: 8px 12px; font-size: 13px; border-bottom: 1px solid var(--border);
}
.member-option:last-child { border-bottom: none; }
.member-option:hover { background: var(--bg-elevated); }
.member-dropdown-empty { padding: 10px 12px; color: var(--text-muted); font-size: 13px; }

.save-bar { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--border); }
.loading { padding: 20px 0; }

/* Repère visuel sur les pages "données en direct" de la sidebar (tableau de
   bord, historique, activité, fiche membre, sauvegardes) : un petit point
   lumineux après le libellé, pour les distinguer d'un simple formulaire de
   configuration sans avoir à dupliquer tout le style d'un badge. */
.nav-item-live::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cyan);
  margin-left: 8px;
  box-shadow: 0 0 6px var(--glow-cyan);
  vertical-align: middle;
}


/* Interrupteur : contour visible au clavier (la vraie case est invisible) */
.toggle input:focus-visible + .toggle-track { outline: 2px solid var(--cyan); outline-offset: 2px; }
.toggle input:disabled + .toggle-track { opacity: 0.4; cursor: not-allowed; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Page « Fonctions » : une ligne par fonction ; l'état est écrit en toutes lettres (pas seulement la couleur) */
.features-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-width: 760px; }
.feature-row {
  display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 14px;
  padding: 12px 16px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-left: 3px solid var(--border); border-radius: 12px; transition: border-color 0.15s, opacity 0.15s;
}
.feature-row[data-state="on"] { border-left-color: var(--cyan); }
.feature-row[data-state="off"] { border-left-color: var(--red); }
.feature-row[data-state="none"] { opacity: 0.7; }
.feature-row[data-busy] { opacity: 0.6; }
.feature-state { font-size: 13px; font-weight: 700; letter-spacing: 0.02em; }
.feature-row[data-state="on"] .feature-state { color: var(--cyan); }
.feature-row[data-state="off"] .feature-state { color: var(--red); }
.feature-row[data-state="none"] .feature-state { color: var(--text-muted); }
.features-live { min-height: 1.4em; }
@media (max-width: 600px) { .feature-row { grid-template-columns: auto 1fr; } .feature-state { grid-column: 2; } }
