/* Forms Premium C.3 — capacité terrain de la PWA existante.
   Réutilise les tokens field-forms / pwa. Contrôles tactiles, lisibilité. */

.fp-shell {
  margin: 12px 0 18px;
}

.fp-shell h3 {
  margin: 0 0 8px;
}

.fp-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid rgba(148, 163, 184, 0.4);
  color: #e2e8f0;
}

.fp-badge-preview {
  background: #7c2d12;
  border-color: #fb923c;
  color: #ffedd5;
}

.fp-assign-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fp-form-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.fp-progress {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 10px;
  padding: 0;
  max-width: 100%;
  overflow-x: auto;
}

.fp-shell button,
.fp-shell .secondary-button,
.fp-shell .primary-button,
.fp-nav button {
  min-height: 44px;
  min-width: 44px;
  padding: 10px 14px;
  box-sizing: border-box;
}

.fp-progress-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #17233b;
  color: #e2e8f0;
  font-weight: 600;
  box-sizing: border-box;
}

.fp-repeat-card.is-deleted {
  opacity: 0.72;
  border-style: dashed;
}

.fp-shell,
.fp-form,
.fp-section {
  max-width: 100%;
  overflow-x: hidden;
}

.fp-progress-btn.is-active {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
}

.fp-progress-btn.has-error {
  border-color: #f87171;
}

.fp-progress-label,
.fp-gps-value,
.fp-gps-quality {
  color: var(--text-muted, #94a3b8);
  font-size: 0.86rem;
}

.fp-section .fp-question,
.fp-repeat-card .fp-question {
  margin-bottom: 14px;
}

.fp-section input,
.fp-section textarea,
.fp-section select,
.fp-repeat-card input,
.fp-repeat-card textarea,
.fp-repeat-card select {
  min-height: 44px;
  width: 100%;
  max-width: 100%;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #0b1220;
  color: #f8fafc;
}

.fp-nav {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 10px;
  padding: 12px 0;
  background: linear-gradient(180deg, transparent, #0f172a 30%);
}

.fp-nav button {
  flex: 1;
  min-height: 48px;
}

.fp-repeat-card {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: rgba(2, 6, 23, 0.4);
}

.fp-repeat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.fp-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.fp-info {
  color: #93c5fd;
}

.fp-warn {
  color: #fdba74;
}

.fp-error-summary {
  border: 1px solid rgba(248, 113, 113, 0.45);
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
}

.fp-map svg {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.fp-conflict-pre {
  max-height: 160px;
  overflow: auto;
  font-size: 0.75rem;
  background: #020617;
  padding: 8px;
  border-radius: 8px;
}

.fp-entity-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}

.fp-catalog-search {
  display: block;
  margin: 10px 0 14px;
}

.fp-catalog-search input {
  min-height: 44px;
  width: 100%;
  max-width: 480px;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: #0b1220;
  color: #f8fafc;
}

.fp-card-desc {
  margin: 6px 0 8px;
  color: #cbd5e1;
  font-size: 0.92rem;
  line-height: 1.4;
}

.fp-tech-code {
  margin: 6px 0 0;
  color: #64748b;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.fp-catalog {
  margin-bottom: 18px;
}

.fp-catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.fp-catalog-family {
  margin: 14px 0 18px;
}

.fp-catalog-family h4 {
  margin: 0 0 8px;
}

.fp-badge-missing {
  background: #1e293b;
  border-color: #64748b;
  color: #cbd5e1;
}

.fp-demo-banner {
  background: #7c2d12;
  color: #ffedd5;
  border-radius: 8px;
  padding: 8px 10px;
  font-weight: 700;
}

.fp-catalog-panel {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 10px 0;
  background: rgba(2, 6, 23, 0.45);
}

.fp-catalog-card .ff-dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.fp-workspace {
  margin: 0 0 18px;
}

.ff-tabs[hidden],
[data-fp-tabs][hidden],
.fp-view-body[hidden],
#ff-legacy-wrap[hidden] {
  display: none !important;
}

.fp-engine-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.fp-view-body {
  min-height: 120px;
}

.fp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}

.fp-kpi {
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(2, 6, 23, 0.45);
  color: #e2e8f0;
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 72px;
  cursor: pointer;
}

.fp-kpi-label {
  display: block;
  color: #94a3b8;
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.fp-kpi-value {
  font-size: 1.4rem;
}

.fp-legacy-head h3 {
  margin: 0 0 6px;
}

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

.fp-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.fp-table th,
.fp-table td {
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
  padding: 8px 10px;
  text-align: left;
}

.fp-decision-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
  margin-top: 14px;
}

.fp-decision-bar textarea {
  min-height: 44px;
  min-width: 220px;
}

.fp-analytics {
  margin-top: 10px;
}

.fp-conflict-card {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(251, 146, 60, 0.45);
  background: rgba(124, 45, 18, 0.2);
  margin-bottom: 10px;
}

.fp-answer-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}

.fp-answer-list li {
  display: flex;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
}

@media (max-width: 768px) {
  .fp-kpi-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .fp-form-head {
    flex-direction: column;
  }
  .fp-nav {
    flex-direction: column;
  }
}

/* ——— D.1.3 Terrain institutionnel, mobile-first ——— */
.fp-form {
  --fp-radius: 14px;
  --fp-pad: 14px;
  padding-bottom: 88px;
}

.fp-brand-head {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 16px;
  align-items: start;
  padding: 4px 0 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  margin-bottom: 12px;
}

.fp-logo {
  width: 72px;
  height: auto;
  object-fit: contain;
  background: #f8fafc;
  border-radius: 10px;
  padding: 6px;
}

.fp-brand-head h3 {
  margin: 0 0 4px;
  font-size: 1.2rem;
  line-height: 1.25;
}

.fp-brand-meta {
  margin: 0;
  color: var(--text-muted, #94a3b8);
  font-size: 0.86rem;
  line-height: 1.4;
}

.fp-progress-track {
  height: 4px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
  margin: 8px 0 4px;
}

.fp-progress-fill {
  height: 100%;
  background: #38bdf8;
  border-radius: 999px;
}

.fp-stepper {
  list-style: none;
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  padding: 4px 0 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.fp-stepper li { flex: 0 0 auto; }

.fp-progress-btn {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 0.82rem;
  border-radius: 999px;
}

.fp-progress-btn.is-complete { border-color: #34d399; }
.fp-progress-btn.is-current { box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35); }
.fp-progress-btn.is-idle { opacity: 0.78; }

.fp-section {
  background: rgba(2, 6, 23, 0.28);
  border-radius: var(--fp-radius);
  padding: var(--fp-pad);
}

.fp-section h4 {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.fp-req-legend {
  margin: 0 0 12px;
  color: #94a3b8;
  font-size: 0.78rem;
}

.fp-question {
  margin-bottom: 16px;
}

.fp-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.3;
}

.fp-req { color: #f87171; font-weight: 700; }

.fp-help, .fp-computed {
  margin: 0 0 8px;
  color: #94a3b8;
  font-size: 0.82rem;
}

.fp-control,
.fp-section input.fp-control,
.fp-section textarea.fp-control,
.fp-section select.fp-control {
  min-height: 48px;
  border-radius: 12px;
  font-size: 16px;
}

.fp-select-wrap { position: relative; }
.fp-select {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, #94a3b8 50%), linear-gradient(135deg, #94a3b8 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.fp-choice-list, .fp-choice-grid {
  display: grid;
  gap: 8px;
}
.fp-choice-list { grid-template-columns: 1fr; }
.fp-choice-grid { grid-template-columns: 1fr 1fr; }

.fp-choice-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  margin: 0;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(148, 163, 184, 0.28));
  background: var(--surface-soft, var(--surface, #111827));
  color: var(--text, inherit);
  cursor: pointer;
}
.fp-choice-row input {
  width: 20px;
  height: 20px;
  min-height: 20px;
  min-width: 20px;
  margin: 0;
  flex: 0 0 auto;
  accent-color: #38bdf8;
}
.fp-choice-row:hover, .fp-choice-row:focus-within {
  border-color: #38bdf8;
}

.fp-field-error {
  margin: 6px 0 0;
  color: #fca5a5;
  font-size: 0.82rem;
}

.fp-error-summary {
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(127, 29, 29, 0.2);
}
.fp-error-summary a { color: #7dd3fc; }

.fp-nav {
  position: sticky;
  bottom: 0;
  z-index: 6;
  display: flex;
  gap: 8px;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, transparent, #0f172a 28%);
}
.fp-nav button { flex: 1; min-height: 48px; }

.fp-tel { display: flex; gap: 8px; align-items: center; }
.fp-tel-prefix {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 12px;
  background: #17233b;
  color: #cbd5e1;
  font-weight: 600;
}
.fp-tel .fp-control { flex: 1; }

.fp-entity-results {
  max-height: 240px;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #0b1220;
  padding: 6px;
}
.fp-entity-item {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 44px;
  border: 0;
  background: transparent;
  color: #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
}
.fp-entity-item:hover, .fp-entity-item:focus { background: #17233b; }
.fp-entity-parents {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}
.fp-parent-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  font-size: 0.9rem;
}
.fp-parent-row dt { color: #94a3b8; margin: 0; }
.fp-parent-row dd { margin: 0; font-weight: 600; }

.fp-tech details {
  margin-top: 10px;
  color: #64748b;
  font-size: 0.78rem;
}

.fp-nav {
  position: sticky;
  bottom: 0;
  z-index: 8;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface, #111827);
  border-top: 1px solid var(--border, rgba(148, 163, 184, 0.18));
}

.fp-control, .fp-select {
  min-height: 48px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border, rgba(148, 163, 184, 0.35));
  background: var(--surface, #111827);
  color: var(--text, inherit);
  padding: 10px 12px;
  font-size: 1rem;
}

.fp-select-wrap { position: relative; }
.fp-select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2394a3b8' d='M1 1l5 5 5-5'/></svg>");
  background-position: right 12px center;
  background-repeat: no-repeat;
}

.fp-q-card {
  border: 1px solid var(--border, rgba(148, 163, 184, 0.2));
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--surface, transparent);
}
.fp-q-card h3 { margin: 0 0 6px; }
.fp-entity-meta { color: var(--text-muted, #94a3b8); font-size: 0.8rem; margin-left: 8px; }
.fp-entity { position: relative; }
.fp-entity-status { margin: 6px 0 0; font-size: 0.8rem; color: var(--text-muted, #94a3b8); }
.fp-entity-results { margin-top: 6px; max-height: 240px; overflow: auto; position: relative; z-index: 6; background: var(--surface, #0f172a); border-radius: 12px; }
.fp-entity-item {
  display: block;
  width: 100%;
  text-align: left;
  min-height: 48px;
  margin: 0 0 6px;
  padding: 10px 12px;
  border-radius: 12px;
}
.fp-editor-grid { display: grid; gap: 12px; }
.fp-editor-q {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 12px;
}
.fp-diff-row { font-family: ui-monospace, monospace; font-size: 0.8rem; }

.fp-q-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.fp-derived-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 16px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
}
.fp-derived-meta p { margin: 0; font-size: 0.85rem; }
.fp-struct-editor {
  display: grid;
  grid-template-columns: 240px minmax(320px, 1fr) 320px;
  gap: 12px;
  min-height: 560px;
}
.fp-struct-col, .fp-struct-main, .fp-struct-props {
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface, transparent);
}
.fp-struct-list { list-style: none; margin: 0; padding: 0; }
.fp-struct-list li {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.fp-struct-list li.is-active button { font-weight: 700; }
.fp-struct-list li.is-hidden { opacity: 0.55; }
.fp-struct-list button { text-align: left; }
.fp-protected, .fp-ref-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 0.78rem;
}
.fp-protected { background: rgba(239, 68, 68, 0.15); }
.fp-ref-badge { background: rgba(59, 130, 246, 0.15); }
.fp-rule-sentence, .fp-opt-list { font-size: 0.85rem; }
.fp-opt-list { list-style: none; padding: 0; }
.fp-opt-list li { display: grid; grid-template-columns: 1fr auto auto auto auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.fp-rule-form { display: grid; gap: 8px; margin-top: 8px; }
.fp-preview-banner {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  background: rgba(245, 158, 11, 0.18);
}
.fp-preview-viewports { display: flex; gap: 8px; margin-bottom: 10px; }
.fp-preview-frame { border: 1px solid rgba(148, 163, 184, 0.3); border-radius: 12px; padding: 12px; margin: 0 auto; }
.fp-preview-frame.is-desktop { max-width: 100%; }
.fp-preview-frame.is-tablet { max-width: 820px; }
.fp-preview-frame.is-phone { max-width: 420px; }
.fp-diff-human { padding-left: 18px; }

@media (max-width: 1100px) {
  .fp-struct-editor { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .fp-choice-grid { grid-template-columns: 1fr; }
  .fp-stepper { display: none; }
  .fp-mobile-section {
    display: block;
    width: 100%;
    min-height: 48px;
    margin-bottom: 10px;
  }
  .fp-parent-row { grid-template-columns: 1fr; }
  .fp-logo { width: 56px; }
}

@media (min-width: 721px) {
  .fp-mobile-section { display: none; }
}

@media (max-width: 480px) {
  .fp-nav {
    flex-wrap: wrap;
  }
  .fp-nav button { min-width: calc(50% - 8px); }
}
