/* ==========================================================================
   FP-MKS-ASSISTANT — styles (préfixe fp-)
   Design : sobre et chaleureux, fond papier clair, cartes blanches,
   accent orange solaire #f59e0b, neutres ardoise, police système.
   ========================================================================== */

/* L'attribut hidden doit toujours gagner, même contre display:flex */
[hidden] { display: none !important; }

:root {
  /* Charte Mon Kit Solaire (harmonisée avec copilote.monkitsolaire.fr) :
     orange #FF6E00 (action) + indigo #130090 (marque) + fond lavande clair. */
  --fp-bg: #f6f6fb;
  --fp-surface: #ffffff;
  --fp-border: #e6e6ef;
  --fp-border-strong: #d6d6e3;
  --fp-text: #1f2033;
  --fp-muted: #64648a;
  --fp-faint: #9494b0;

  --fp-accent: #ff6e00;
  --fp-accent-hover: #e85f00;
  --fp-accent-deep: #c95400;
  --fp-accent-soft: #ffe3cc;
  --fp-accent-wash: #fff4ea;

  --fp-brand: #130090;
  --fp-brand-deep: #0d0066;
  --fp-brand-soft: #e7e4ff;

  --fp-danger: #b91c1c;
  --fp-danger-bg: #fee2e2;
  --fp-danger-border: #fca5a5;

  --fp-radius: 10px;
  --fp-radius-sm: 7px;
  --fp-shadow: 0 1px 2px rgba(30, 41, 59, 0.05), 0 1px 4px rgba(30, 41, 59, 0.04);
  --fp-shadow-up: 0 -4px 16px rgba(30, 41, 59, 0.08);
  --fp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--fp-bg);
  color: var(--fp-text);
  font-family: var(--fp-font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.fp-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--fp-surface);
  border-bottom: 1px solid var(--fp-border);
}
.fp-header::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--fp-brand), #4b2fd6 25%, var(--fp-accent) 55%, #ff8c33 75%, var(--fp-accent-deep));
}
.fp-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.fp-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: var(--fp-text);
  white-space: nowrap;
}
.fp-brand-logo { height: 26px; width: auto; display: block; }
.fp-brand-tool {
  font-size: 13px;
  font-weight: 600;
  color: var(--fp-brand);
  padding-left: 11px;
  border-left: 1px solid var(--fp-border-strong);
}
.fp-nav { display: flex; gap: 4px; }
.fp-nav a {
  display: inline-block;
  padding: 6px 12px;
  border-radius: var(--fp-radius-sm);
  color: var(--fp-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  transition: color 0.15s, background-color 0.15s;
}
.fp-nav a:hover { color: var(--fp-text); background: var(--fp-bg); }
.fp-nav a.fp-nav-active {
  color: var(--fp-brand);
  background: var(--fp-brand-soft);
  box-shadow: inset 0 -2px 0 var(--fp-brand);
}

/* --------------------------------------------------------------------------
   Bandeau d'erreur
   -------------------------------------------------------------------------- */
.fp-error {
  position: sticky;
  top: 59px;
  z-index: 49;
  background: var(--fp-danger-bg);
  border-bottom: 1px solid var(--fp-danger-border);
  color: var(--fp-danger);
}
.fp-error-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  font-size: 14px;
  font-weight: 500;
}
.fp-error-close {
  flex: none;
  border: none;
  background: none;
  color: var(--fp-danger);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.fp-error-close:hover { opacity: 0.7; }

/* --------------------------------------------------------------------------
   Layout général
   -------------------------------------------------------------------------- */
.fp-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.fp-screen { animation: fp-fade-in 0.18s ease-out; }
@keyframes fp-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.fp-narrow { max-width: 720px; }

.fp-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.fp-page-title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.fp-page-sub { margin: 4px 0 0; color: var(--fp-muted); font-size: 14px; }

.fp-back {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--fp-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.fp-back:hover { color: var(--fp-accent-deep); }

.fp-card {
  background: var(--fp-surface);
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius);
  box-shadow: var(--fp-shadow);
}

.fp-hint { color: var(--fp-faint); font-size: 13px; margin: 10px 0 0; }

/* --------------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------------- */
.fp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--fp-radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.fp-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.fp-btn-primary {
  background: var(--fp-accent);
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(180, 83, 9, 0.3);
}
.fp-btn-primary:hover:not(:disabled) { background: var(--fp-accent-hover); }

.fp-btn-secondary {
  background: var(--fp-surface);
  border-color: var(--fp-border-strong);
  color: var(--fp-text);
}
.fp-btn-secondary:hover:not(:disabled) {
  border-color: var(--fp-accent);
  color: var(--fp-accent-deep);
  background: var(--fp-accent-wash);
}

.fp-btn-ghost { background: transparent; color: var(--fp-muted); }
.fp-btn-ghost:hover:not(:disabled) { color: var(--fp-accent-deep); background: var(--fp-accent-wash); }

.fp-btn-sm { padding: 5px 11px; font-size: 13px; }
.fp-btn-lg { padding: 13px 28px; font-size: 16px; }

.fp-btn-disabled { pointer-events: none; opacity: 0.55; }

.fp-btn.fp-copied {
  border-color: #86efac;
  background: #f0fdf4;
  color: #15803d;
}

/* --------------------------------------------------------------------------
   Champs de formulaire
   -------------------------------------------------------------------------- */
.fp-field { display: block; margin-bottom: 18px; }
.fp-field:last-child { margin-bottom: 0; }
.fp-field-inline { display: inline-flex; align-items: center; gap: 8px; }

.fp-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fp-text);
}
.fp-field-inline .fp-label { margin-bottom: 0; color: var(--fp-muted); font-weight: 500; }
.fp-req { color: var(--fp-accent-deep); font-style: normal; }
.fp-optional { color: var(--fp-faint); font-weight: 400; }

.fp-input, .fp-select, .fp-ta {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--fp-border-strong);
  border-radius: var(--fp-radius-sm);
  background: var(--fp-surface);
  color: var(--fp-text);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.55;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fp-input:focus, .fp-select:focus, .fp-ta:focus {
  outline: none;
  border-color: var(--fp-accent);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}
.fp-input-short { max-width: 220px; }
.fp-select { width: auto; min-width: 160px; cursor: pointer; }
.fp-field .fp-select { width: 100%; }

.fp-ta { resize: vertical; min-height: 72px; }
.fp-ta-form { min-height: 96px; }
.fp-ta::placeholder, .fp-input::placeholder { color: var(--fp-faint); }

/* Zone de sélection de fichiers */
.fp-filedrop {
  display: block;
  padding: 18px 16px;
  border: 1.5px dashed var(--fp-border-strong);
  border-radius: var(--fp-radius-sm);
  background: #fcfbf8;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.fp-filedrop:hover { border-color: var(--fp-accent); background: var(--fp-accent-wash); }
.fp-filedrop input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.fp-filedrop-text { color: var(--fp-muted); font-size: 13px; font-weight: 500; }
.fp-filedrop-compact { padding: 9px 12px; text-align: left; flex: 1; }

.fp-filelist { list-style: none; margin: 8px 0 0; padding: 0; }
.fp-filelist li {
  font-size: 13px;
  color: var(--fp-muted);
  padding: 3px 0 3px 20px;
  position: relative;
}
.fp-filelist li::before {
  content: "PDF";
  position: absolute;
  left: 0;
  top: 6px;
  font-size: 8px;
  font-weight: 700;
  color: var(--fp-accent-deep);
  background: var(--fp-accent-soft);
  border-radius: 3px;
  padding: 1px 3px;
  line-height: 1.2;
}

.fp-form { padding: 24px; }
.fp-form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--fp-border);
}

/* --------------------------------------------------------------------------
   Badges de statut
   -------------------------------------------------------------------------- */
.fp-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.fp-badge::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.fp-badge--brouillon { background: #f1f5f9; color: #475569; }
.fp-badge--relu { background: #dbeafe; color: #1d4ed8; }
.fp-badge--en_attente { background: var(--fp-accent-soft); color: var(--fp-accent-deep); }
.fp-badge--en_ligne { background: #dcfce7; color: #15803d; }

/* --------------------------------------------------------------------------
   Dashboard : filtres + tableau
   -------------------------------------------------------------------------- */
.fp-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 14px;
}

.fp-table-card { overflow: hidden; }
.fp-table-wrap { overflow-x: auto; }

.fp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.fp-table th {
  text-align: left;
  padding: 11px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fp-faint);
  border-bottom: 1px solid var(--fp-border);
  background: #fcfbf8;
  white-space: nowrap;
}
.fp-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--fp-border);
  vertical-align: middle;
}
.fp-table tbody tr:last-child td { border-bottom: none; }
.fp-table tbody tr {
  cursor: pointer;
  transition: background-color 0.12s;
}
.fp-table tbody tr:hover { background: var(--fp-accent-wash); }
.fp-table tbody tr:focus-visible {
  outline: 2px solid var(--fp-accent);
  outline-offset: -2px;
}
.fp-table .fp-cell-title { font-weight: 600; max-width: 380px; }
.fp-table .fp-cell-muted { color: var(--fp-muted); }
.fp-table .fp-num { text-align: right; font-variant-numeric: tabular-nums; }

.fp-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--fp-muted);
}
.fp-empty p { margin: 0 0 16px; }

/* --------------------------------------------------------------------------
   Éditeur de fiche : en-tête
   -------------------------------------------------------------------------- */
.fp-fiche-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 24px;
  margin-bottom: 16px;
  border-left: 4px solid var(--fp-accent);
}
.fp-fiche-head-main { min-width: 0; }
.fp-fiche-head .fp-page-title { font-size: 21px; }
.fp-fiche-head-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex: none;
}

/* --------------------------------------------------------------------------
   Sources
   -------------------------------------------------------------------------- */
.fp-sources { margin-bottom: 16px; }
.fp-sources summary {
  padding: 13px 24px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: var(--fp-text);
  list-style: none;
  position: relative;
}
.fp-sources summary::-webkit-details-marker { display: none; }
.fp-sources summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--fp-accent);
  transition: transform 0.15s;
}
.fp-sources[open] summary::before { transform: rotate(90deg); }
.fp-sources summary:hover { color: var(--fp-accent-deep); }

.fp-sources-body { padding: 4px 24px 18px; border-top: 1px solid var(--fp-border); }
.fp-sources-list { list-style: none; margin: 12px 0; padding: 0; }
.fp-sources-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--fp-border);
  font-size: 14px;
}
.fp-sources-list li:last-child { border-bottom: none; }
.fp-source-kind {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 4px;
  background: #eef2f7;
  color: var(--fp-muted);
}
.fp-source-kind--pdf { background: var(--fp-accent-soft); color: var(--fp-accent-deep); }
.fp-source-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.fp-source-date { color: var(--fp-faint); font-size: 12px; white-space: nowrap; }
.fp-source-del {
  flex: none;
  border: none;
  background: none;
  color: var(--fp-faint);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
}
.fp-source-del:hover { color: var(--fp-danger); background: var(--fp-danger-bg); }
.fp-sources-empty { color: var(--fp-faint); font-size: 13px; margin: 12px 0; }
.fp-sources-add { display: flex; align-items: center; gap: 10px; margin-top: 6px; }

/* --------------------------------------------------------------------------
   Zone de génération (fiche vierge)
   -------------------------------------------------------------------------- */
.fp-genzone {
  padding: 44px 32px;
  text-align: center;
  background:
    radial-gradient(circle at 50% -60px, rgba(245, 158, 11, 0.12), transparent 60%),
    var(--fp-surface);
}
.fp-genzone-title { margin: 0 0 8px; font-size: 19px; font-weight: 700; }
.fp-genzone-text {
  margin: 0 auto 22px;
  max-width: 560px;
  color: var(--fp-muted);
  font-size: 14px;
}
.fp-genzone-consignes {
  margin: -8px auto 22px;
  max-width: 560px;
  font-size: 13px;
  color: var(--fp-accent-deep);
  background: var(--fp-accent-wash);
  border: 1px solid var(--fp-accent-soft);
  border-radius: var(--fp-radius-sm);
  padding: 10px 14px;
  text-align: left;
}

/* --------------------------------------------------------------------------
   Blocs de l'éditeur
   -------------------------------------------------------------------------- */
.fp-blocks { display: flex; flex-direction: column; gap: 14px; }

.fp-block { padding: 16px 20px 18px; }
.fp-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.fp-block-label {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fp-accent-deep);
}
.fp-block-tools { display: flex; align-items: center; gap: 12px; }
.fp-count {
  font-size: 12px;
  color: var(--fp-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.fp-count--over { color: var(--fp-danger); font-weight: 600; }

.fp-block .fp-ta { min-height: 64px; overflow: hidden; }
.fp-block .fp-ta-large { min-height: 300px; }

/* Panneau de régénération inline */
.fp-regen {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  background: var(--fp-accent-wash);
  border: 1px solid var(--fp-accent-soft);
  border-radius: var(--fp-radius-sm);
}
.fp-regen .fp-input { flex: 1; background: var(--fp-surface); }

/* Warnings */
.fp-warnings { list-style: none; margin: 10px 0 0; padding: 0; }
.fp-warnings li {
  position: relative;
  padding: 7px 12px 7px 32px;
  margin-top: 6px;
  font-size: 13px;
  color: #92400e;
  background: var(--fp-accent-wash);
  border-left: 3px solid var(--fp-accent);
  border-radius: 0 var(--fp-radius-sm) var(--fp-radius-sm) 0;
}
.fp-warnings li::before {
  content: "⚠";
  position: absolute;
  left: 11px;
  top: 6px;
  color: var(--fp-accent);
}

/* --------------------------------------------------------------------------
   Barre d'actions sticky
   -------------------------------------------------------------------------- */
.fp-actionbar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius);
  box-shadow: var(--fp-shadow-up);
}
.fp-actionbar-btns { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.fp-dirty {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fp-accent-deep);
}
.fp-dirty-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--fp-accent);
  animation: fp-pulse 1.6s ease-in-out infinite;
}
@keyframes fp-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* --------------------------------------------------------------------------
   Export
   -------------------------------------------------------------------------- */
.fp-export-section { padding: 18px 22px 20px; margin-bottom: 16px; }
.fp-export-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.fp-export-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.fp-export-tools { display: flex; align-items: center; gap: 12px; }

.fp-preview {
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius-sm);
  background: #fcfbf8;
  padding: 16px 18px;
  font-size: 14px;
  overflow-x: auto;
}
.fp-preview-scroll { max-height: 420px; overflow-y: auto; }
.fp-preview h2 { font-size: 18px; margin: 18px 0 8px; }
.fp-preview h3 { font-size: 15px; margin: 14px 0 6px; }
.fp-preview h4 { font-size: 14px; margin: 12px 0 4px; }
.fp-preview > :first-child { margin-top: 0; }
.fp-preview p { margin: 0 0 10px; }
.fp-preview ul { margin: 0 0 10px; padding-left: 22px; }
.fp-preview a { color: var(--fp-accent-deep); }
.fp-preview table { border-collapse: collapse; margin: 0 0 12px; width: 100%; }
.fp-preview th, .fp-preview td {
  border: 1px solid var(--fp-border-strong);
  padding: 6px 10px;
  font-size: 13px;
  text-align: left;
}
.fp-preview th { background: var(--fp-accent-wash); }

.fp-seo-rows { display: flex; flex-direction: column; }
.fp-seo-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--fp-border);
}
.fp-seo-row:last-child { border-bottom: none; }
.fp-seo-label {
  flex: none;
  width: 150px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fp-muted);
  padding-top: 2px;
}
.fp-seo-value {
  flex: 1;
  min-width: 0;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.fp-seo-value--empty { color: var(--fp-faint); }
.fp-seo-row .fp-btn { flex: none; }

.fp-export-note {
  padding: 14px 18px;
  font-size: 14px;
  background: var(--fp-accent-wash);
  border-color: var(--fp-accent-soft);
  border-left: 4px solid var(--fp-accent);
  color: #78350f;
}

/* --------------------------------------------------------------------------
   Spinner & chargement
   -------------------------------------------------------------------------- */
.fp-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(120, 113, 108, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: fp-spin 0.7s linear infinite;
  vertical-align: -2px;
  flex: none;
}
@keyframes fp-spin { to { transform: rotate(360deg); } }

.fp-loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 80px 0;
  color: var(--fp-muted);
  font-size: 14px;
}
.fp-loading-page .fp-spinner { width: 20px; height: 20px; }

/* --------------------------------------------------------------------------
   Encadré d'information & aides de champ
   -------------------------------------------------------------------------- */
.fp-infobox {
  margin-bottom: 16px;
  padding: 12px 16px;
  font-size: 13px;
  color: #78350f;
  background: var(--fp-accent-wash);
  border: 1px solid var(--fp-accent-soft);
  border-left: 4px solid var(--fp-accent);
  border-radius: var(--fp-radius-sm);
}
.fp-infobox-in-form { margin-bottom: 18px; }

.fp-help {
  display: block;
  margin-top: 5px;
  font-size: 12px;
  color: var(--fp-faint);
  font-weight: 400;
}
.fp-help-block { margin: 0 0 10px; }

.fp-link { color: var(--fp-accent-deep); text-decoration: none; }
.fp-link:hover { text-decoration: underline; }

.fp-ta-mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.5;
}

/* Champs d'édition de template : hauteur fixe scrollable (pas d'autoresize).
   Les system prompts font plusieurs milliers de caractères : l'auto-agrandissement
   faisait sauter la page à chaque frappe. Override du overflow:hidden des blocs. */
.fp-block .fp-ta.fp-ta-scroll {
  overflow: auto;
  resize: vertical;
  height: 340px;
  min-height: 120px;
  max-height: 75vh;
}
.fp-block .fp-ta-large.fp-ta-scroll { height: 520px; }

.fp-add-form { padding: 20px 24px; margin-bottom: 16px; }

.fp-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.fp-checkbox input { accent-color: var(--fp-accent); width: 15px; height: 15px; cursor: pointer; }

/* --------------------------------------------------------------------------
   Marques : panneau d'édition inline sous la ligne
   -------------------------------------------------------------------------- */
.fp-cell-notes { max-width: 320px; overflow-wrap: anywhere; }

.fp-table tbody tr.fp-edit-row { cursor: default; }
.fp-table tbody tr.fp-edit-row:hover { background: transparent; }
.fp-table tbody tr.fp-edit-row > td {
  padding: 0;
  background: #fcfbf8;
  border-bottom: 1px solid var(--fp-border);
}
.fp-brand-edit {
  padding: 18px 20px 20px;
  border-top: 2px solid var(--fp-accent-soft);
}
.fp-brand-edit .fp-form-actions { margin-top: 16px; padding-top: 14px; }
.fp-brand-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

/* --------------------------------------------------------------------------
   Templates : badges de statut + éditeur
   -------------------------------------------------------------------------- */
.fp-badge--tpl-draft { background: #f1f5f9; color: #475569; }
.fp-badge--tpl-actif { background: #dcfce7; color: #15803d; }
.fp-badge--tpl-archive { background: #f5f5f4; color: var(--fp-faint); }

/* Statuts Notion (par groupe To-do / In progress / Complete) */
.fp-badge--notion-todo { background: #f1f5f9; color: #475569; }
.fp-badge--notion-progress { background: #fef3c7; color: #b45309; }
.fp-badge--notion-done { background: #dcfce7; color: #15803d; }

.fp-ticket-types { font-size: 11.5px; color: var(--fp-faint); margin-top: 3px; }
.fp-error-inline {
  padding: 12px 16px; margin-bottom: 16px; border-radius: var(--fp-radius-sm);
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; font-size: 13px;
}

.fp-cell-slug {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
}

.fp-tpl-label {
  width: 100%;
  margin: -4px 0 0 -8px;
  padding: 2px 8px;
  border: 1px solid transparent;
  border-radius: var(--fp-radius-sm);
  background: transparent;
  color: var(--fp-text);
  font-family: inherit;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.fp-tpl-label:hover { border-color: var(--fp-border-strong); background: var(--fp-surface); }
.fp-tpl-label:focus {
  outline: none;
  border-color: var(--fp-accent);
  background: var(--fp-surface);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

/* --------------------------------------------------------------------------
   Nouvelle fiche : aide variables + section kit
   -------------------------------------------------------------------------- */
.fp-varform-help {
  margin-bottom: 18px;
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius-sm);
  background: #fcfbf8;
}
.fp-varform-help summary {
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fp-muted);
  cursor: pointer;
  list-style: none;
}
.fp-varform-help summary::-webkit-details-marker { display: none; }
.fp-varform-help summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 8px;
  color: var(--fp-accent);
  transition: transform 0.15s;
}
.fp-varform-help[open] summary::before { transform: rotate(90deg); }
.fp-varform-help pre {
  margin: 0;
  padding: 4px 14px 14px;
  border-top: 1px dashed var(--fp-border);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--fp-muted);
  max-height: 320px;
  overflow-y: auto;
}

.fp-kitzone {
  margin-bottom: 18px;
  padding: 16px 18px 18px;
  background: var(--fp-accent-wash);
  border: 1px solid var(--fp-accent-soft);
  border-radius: var(--fp-radius-sm);
}
.fp-kitzone-title {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fp-accent-deep);
}
.fp-kitzone .fp-input, .fp-kitzone .fp-select { background: var(--fp-surface); }

/* Lignes de composants */
.fp-comp-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.fp-comp-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
/* .fp-field .fp-select impose width:100% : on re-cadre avec la même spécificité */
.fp-comp-row .fp-comp-role { flex: none; width: 160px; min-width: 160px; }
.fp-comp-search { position: relative; flex: 1; min-width: 0; }
.fp-comp-row .fp-comp-qty { flex: none; width: 74px; text-align: right; }
.fp-comp-del {
  flex: none;
  align-self: center;
  border: none;
  background: none;
  color: var(--fp-faint);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--fp-radius-sm);
}
.fp-comp-del:hover { color: var(--fp-danger); background: var(--fp-danger-bg); }

/* Autocomplete des FP internes */
.fp-comp-dd {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--fp-surface);
  border: 1px solid var(--fp-border-strong);
  border-radius: var(--fp-radius-sm);
  box-shadow: 0 8px 24px rgba(30, 41, 59, 0.14);
  max-height: 260px;
  overflow-y: auto;
}
.fp-comp-dd li {
  padding: 7px 10px;
  font-size: 13px;
  border-radius: 5px;
  cursor: pointer;
}
.fp-comp-dd li:hover { background: var(--fp-accent-wash); color: var(--fp-accent-deep); }

.fp-comp-linked {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  white-space: nowrap;
}
.fp-comp-search:has(.fp-comp-linked:not([hidden])) .fp-input { padding-right: 76px; }

/* --------------------------------------------------------------------------
   Toast de succès
   -------------------------------------------------------------------------- */
.fp-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 100;
  transform: translate(-50%, 12px);
  opacity: 0;
  padding: 11px 20px;
  background: #14532d;
  color: #dcfce7;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(20, 83, 45, 0.35);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
  max-width: min(90vw, 560px);
}
.fp-toast--in { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  .fp-header-inner { height: auto; padding: 10px 16px; flex-wrap: wrap; }
  .fp-brand-sub { display: none; }
  .fp-main { padding: 20px 14px 70px; }
  .fp-page-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .fp-fiche-head { flex-direction: column; }
  .fp-fiche-head-status { align-items: flex-start; flex-direction: row; align-items: center; }
  .fp-filters { gap: 10px; }
  .fp-field-inline { flex-wrap: wrap; }
  .fp-actionbar { flex-wrap: wrap; }
  .fp-actionbar-btns { margin-left: 0; flex-wrap: wrap; }
  .fp-seo-row { flex-wrap: wrap; }
  .fp-seo-label { width: 100%; padding-top: 0; }
  .fp-regen { flex-wrap: wrap; }
  .fp-form { padding: 18px 16px; }
  .fp-brand-edit-grid { grid-template-columns: 1fr; }
  .fp-comp-row { flex-wrap: wrap; }
  .fp-comp-row .fp-comp-role { width: 100%; }
  .fp-comp-search { flex: 1 1 200px; }
  .fp-block { padding: 14px 14px 16px; }
  .fp-export-head { flex-wrap: wrap; }
}

/* Bouton suppression fiche (discret, rouge au survol) */
.fp-delete-btn { color: var(--fp-faint); }
.fp-delete-btn:hover:not(:disabled) { color: var(--fp-danger); background: var(--fp-danger-bg); }

/* --------------------------------------------------------------------------
   Aperçu markdown des blocs (mode preview de l'éditeur de fiche)
   -------------------------------------------------------------------------- */
.fp-block-preview {
  padding: 14px 16px;
  border: 1px solid var(--fp-border);
  border-radius: var(--fp-radius-sm);
  background: #fcfbf8;
  font-size: 14px;
  min-height: 30px;
}
.fp-md > :first-child { margin-top: 0; }
.fp-md > :last-child { margin-bottom: 0; }
.fp-md p { margin: 0 0 10px; }
.fp-md-h { font-weight: 700; letter-spacing: -0.01em; margin: 18px 0 8px; }
.fp-md-h1 { font-size: 19px; }
.fp-md-h2 { font-size: 17px; }
.fp-md-h3 { font-size: 15px; color: var(--fp-accent-deep); }
.fp-md-h4 { font-size: 14px; color: var(--fp-muted); }
.fp-md-ul { margin: 0 0 10px; padding-left: 22px; }
.fp-md-ul li { margin: 2px 0; }
.fp-md-link {
  color: var(--fp-accent-deep);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  cursor: help;
}
.fp-md-tablewrap { overflow-x: auto; margin: 0 0 12px; }
.fp-md-table { border-collapse: collapse; width: 100%; }
.fp-md-table th, .fp-md-table td {
  border: 1px solid var(--fp-border-strong);
  padding: 6px 10px;
  font-size: 13px;
  text-align: left;
}
.fp-md-table th { background: var(--fp-accent-wash); }
.fp-md-empty { color: var(--fp-faint); font-style: italic; margin: 0; }
.fp-md-json {
  margin: 0;
  font-family: var(--fp-mono, ui-monospace, monospace);
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Panneau de régénération complète avec consigne (éditeur de fiche) */
.fp-regen-consigne-panel { margin-top: 12px; }
.fp-regen-consigne-panel .fp-field { margin-bottom: 0; }

/* --------------------------------------------------------------------------
   Marques v2 : sync, brief, CTA de génération
   -------------------------------------------------------------------------- */
.fp-page-head-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.fp-brand-site-row { display: flex; gap: 8px; align-items: flex-start; }
.fp-brand-site-row .fp-input { flex: 1; min-width: 0; }
.fp-brand-site-row .fp-btn { flex: none; margin-top: 3px; }
.fp-brief-ok {
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #15803d;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Nouvelle fiche : warning inline (marque sans brief)
   -------------------------------------------------------------------------- */
.fp-inline-warning {
  display: block;
  margin-top: 6px;
  padding: 7px 12px;
  font-size: 13px;
  color: #92400e;
  background: var(--fp-accent-wash);
  border-left: 3px solid var(--fp-accent);
  border-radius: 0 var(--fp-radius-sm) var(--fp-radius-sm) 0;
}

/* Toast d'avertissement (non bloquant) */
.fp-toast--warn {
  background: #78350f;
  color: #fef3c7;
  box-shadow: 0 8px 24px rgba(120, 53, 15, 0.35);
}

/* --------------------------------------------------------------------------
   Wizard nouveau type : radios de mode + panneau de progression du job
   -------------------------------------------------------------------------- */
.fp-mode-radios {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px dashed var(--fp-border);
}
.fp-radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.fp-radio input { accent-color: var(--fp-accent); width: 15px; height: 15px; cursor: pointer; }

.fp-jobpanel { padding: 22px 24px; margin-bottom: 16px; border-left: 4px solid var(--fp-accent); }
.fp-jobpanel-title { margin: 0 0 6px; font-size: 17px; font-weight: 700; }
.fp-jobpanel-sub { margin: 0 0 16px; color: var(--fp-muted); font-size: 13px; }
.fp-job-steps { list-style: none; margin: 0; padding: 0; }
.fp-job-step {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--fp-border);
  font-size: 14px;
}
.fp-job-step:last-child { border-bottom: none; }
.fp-job-step-icon {
  flex: none;
  width: 22px;
  text-align: center;
  font-size: 14px;
}
.fp-job-step-label { font-weight: 600; white-space: nowrap; }
.fp-job-step-detail { color: var(--fp-muted); font-size: 13px; min-width: 0; overflow-wrap: anywhere; }
.fp-job-step--pending { color: var(--fp-faint); }
.fp-job-step--pending .fp-job-step-label { font-weight: 500; }
.fp-job-step--running .fp-job-step-icon { animation: fp-pulse 1.6s ease-in-out infinite; }
.fp-job-step--done .fp-job-step-icon { color: #15803d; font-weight: 700; }
.fp-job-step--error .fp-job-step-icon { color: var(--fp-danger); }
.fp-job-step--error .fp-job-step-detail { color: #92400e; }
.fp-jobpanel-footer { margin: 14px 0 0; }

/* --------------------------------------------------------------------------
   Réglages (superadmin)
   -------------------------------------------------------------------------- */
.fp-settings-section { margin-bottom: 16px; }
.fp-section-title { margin: 0 0 14px; font-size: 16px; font-weight: 700; }
.fp-secrets-table .fp-secret-name {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  font-weight: 600;
}
.fp-secrets-table td { padding: 8px 12px; }
.fp-secrets-table tbody tr { cursor: default; }
.fp-secrets-table tbody tr:hover { background: transparent; }
.fp-secret-mask {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12.5px;
  white-space: nowrap;
}
.fp-secret-mask--empty { font-style: italic; font-family: var(--fp-font); }
.fp-secret-source {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.fp-secret-source--reglages { background: var(--fp-accent-soft); color: var(--fp-accent-deep); }
.fp-secret-source--env { background: #e0f2fe; color: #0369a1; }
.fp-secret-source--absente { background: var(--fp-danger-bg); color: var(--fp-danger); }
.fp-secret-input-cell { min-width: 200px; }
.fp-secret-input-cell .fp-input { padding: 6px 10px; font-size: 13px; }

@media (max-width: 720px) {
  .fp-brand-site-row { flex-wrap: wrap; }
  .fp-mode-radios { gap: 10px; flex-direction: column; }
  .fp-job-step { flex-wrap: wrap; }
}

/* --------------------------------------------------------------------------
   Recherche dans les barres de filtres + sélecteur de ticket Notion
   -------------------------------------------------------------------------- */
.fp-field-grow { flex: 1 1 260px; }
.fp-field-grow .fp-input { flex: 1; min-width: 0; }
.fp-checkbox-inline { margin-bottom: 0; }

.fp-ticket-picker { display: flex; flex-direction: column; gap: 6px; }
.fp-ticket-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border: 1px solid var(--fp-border-strong);
  border-radius: var(--fp-radius-sm); background: var(--fp-accent-wash);
}
.fp-ticket-chip-icon { font-size: 14px; }
.fp-ticket-chip-label { flex: 1; font-weight: 500; font-size: 14px; min-width: 0; }
.fp-ticket-dd-etat { color: var(--fp-faint); font-size: 12px; }

.fp-ticket-fiches { display: flex; flex-direction: column; gap: 4px; }
.fp-ticket-fiche { font-size: 13px; }

.fp-fiche-ticket { display: flex; flex-direction: column; gap: 8px; }
.fp-fiche-ticket .fp-label { margin-bottom: 0; }

/* Indicateur fiche reliée à un ticket (dashboard) + tags de source (composants kit) */
.fp-ticket-flag { font-size: 12px; opacity: 0.85; }
.fp-comp-opt-tag {
  display: inline-block; font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.02em; padding: 1px 6px; border-radius: 4px; vertical-align: middle;
}
.fp-comp-opt-tag--outil { background: var(--fp-accent-soft); color: var(--fp-accent-deep); }
.fp-comp-opt-tag--catalogue { background: #e0e7ff; color: #4338ca; }

/* Sélecteur de mode de quantité (composant de kit) : par kit / par panneau */
.fp-comp-row .fp-comp-mode { flex: none; width: 128px; min-width: 128px; font-size: 13px; }

/* Composant de kit : 2e ligne « limité aux puissances » (cas rare : compo variable) */
.fp-comp { display: flex; flex-direction: column; gap: 5px; }
.fp-comp-powers { display: flex; align-items: baseline; gap: 8px; padding-left: 2px; flex-wrap: wrap; }
.fp-comp-powers-label { font-size: 12px; font-weight: 500; color: var(--fp-muted); white-space: nowrap; }
.fp-comp-powers-input { flex: none; width: 190px; font-size: 13px; padding: 4px 9px; }
.fp-comp-powers .fp-help { margin-top: 0; }

/* Rédaction en lot : colonne de cases + barre d'action */
.fp-check-col { width: 40px; text-align: center; }
.fp-check-col input { cursor: pointer; width: 15px; height: 15px; accent-color: var(--fp-accent); }
.fp-batchbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; margin-bottom: 14px;
  background: var(--fp-accent-wash); border: 1px solid var(--fp-accent-soft);
  border-radius: var(--fp-radius-sm);
}
.fp-batchbar-count { font-weight: 600; font-size: 14px; color: var(--fp-accent-deep); }
.fp-batchbar-actions { display: flex; gap: 8px; }

/* Lien de déconnexion (login unique) : discret, à droite de la nav */
.fp-nav-logout { color: var(--fp-faint) !important; font-weight: 500; }
.fp-nav-logout:hover { color: var(--fp-danger) !important; background: transparent !important; }
