/*
 * Fluent Forms im AC4DC-Design (hell und dunkel über tokens.css).
 * Wird vom Theme nur geladen, wenn ein Fluent-Forms-Formular auf der Seite ist,
 * und zwar NACH den Plugin-Styles (siehe inc/fluent-forms.php).
 *
 * Grundlage: Markup von Fluent Forms 6.2 (.fluentform, .ff-el-group,
 * .ff-el-form-control, .ff-el-form-check …). Farben, Radius und Fehlerfarbe
 * werden zuerst über die Plugin-eigenen Variablen (--fluentform-*) gesetzt,
 * der Rest gezielt überschrieben.
 */

.fluentform {
  --fluentform-primary: var(--color-label);
  --fluentform-secondary: var(--color-text-muted);
  --fluentform-danger: var(--color-error);
  --fluentform-border-color: var(--color-icon-card-border);
  --fluentform-border-radius: var(--radius-s);
  --fluentform-input-select-height: 3rem;

  font-family: var(--font-sans);
  color: var(--color-text);
}

/* ------------------------------------------------------------ Abstände */
/* Fester Platz für Fehlermeldungen (siehe "Fehler"): Der Abstand zwischen den
   Feldern nimmt die Meldung auf, damit beim Erscheinen/Verschwinden nichts
   verrutscht. */
.fluentform .ff-el-group {
  position: relative;
  margin-bottom: var(--space-8);
}

.fluentform .ff-t-container {
  gap: var(--space-6);
}

/* ------------------------------------------------------------ Beschriftungen */
.fluentform .ff-el-input--label {
  margin-bottom: var(--space-2);
}

.fluentform .ff-el-input--label label {
  font-size: var(--font-size-s);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text);
}

.fluentform .ff-el-is-required.asterisk-right label::after {
  color: var(--color-error);
}

.fluentform .ff-el-tooltip svg {
  fill: var(--color-text-muted);
}

.fluentform .ff-el-help-message {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------ Eingabefelder */
.fluentform .ff-el-form-control {
  min-height: 3rem;
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--font-size-s);
  line-height: var(--line-height-body);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-icon-card-border);
  border-radius: var(--radius-s);
  box-shadow: none;
  backdrop-filter: blur(var(--blur-glass));
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.fluentform .ff-el-form-control::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.fluentform .ff-el-form-control:hover {
  border-color: var(--color-accent);
}

.fluentform .ff-el-form-control:focus {
  border-color: var(--color-label);
  outline: none;
  box-shadow: 0 0 0 3px rgb(55 138 221 / 30%);
}

.fluentform textarea.ff-el-form-control {
  min-height: 9rem;
  resize: vertical;
}

/* Auswahlliste: eigener Pfeil in Textfarbe (funktioniert hell und dunkel) */
.fluentform select.ff-el-form-control {
  appearance: none;
  padding-right: var(--space-12);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 1.375rem) 50%,
    calc(100% - 1rem) 50%;
  background-size: 0.375rem 0.375rem;
  background-repeat: no-repeat;
}

.fluentform select.ff-el-form-control option {
  color: var(--color-text);
  background-color: var(--color-menu-bg);
}

/* ------------------------------------------------------------ Checkbox / Radio */
.fluentform .ff-el-form-check {
  margin-bottom: var(--space-2);
}

.fluentform .ff-el-form-check-label {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--font-size-s);
  line-height: var(--line-height-body);
  color: var(--color-text);
  cursor: pointer;
}

.fluentform .ff-el-form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  margin: 0.0625rem 0 0;
  flex: 0 0 auto;
  accent-color: var(--color-label);
  cursor: pointer;
}

.fluentform .ff-el-form-check-input:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* Datenschutz-/AGB-Hinweis */
.fluentform .ff_t_c,
.fluentform .ff_tc_label {
  font-size: var(--font-size-xs);
  line-height: 1.5;
  color: var(--color-text-muted);
}

.fluentform .ff_t_c a {
  color: var(--color-link);
}

/* ------------------------------------------------------------ Fehler */
.fluentform .ff-el-is-error .ff-el-form-control {
  border-color: var(--color-error);
}

.fluentform .ff-el-is-error .ff-el-form-control:focus {
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-error) 30%, transparent);
}

.fluentform .ff-el-is-error .ff-el-form-check-label,
.fluentform .text-danger,
.fluentform .error,
.ff-errors-in-stack {
  color: var(--color-error);
}

/*
 * Fehlermeldung ohne Layout-Verschiebung: Fluent Forms fügt die Meldung beim
 * Prüfen ein und entfernt sie beim Verlassen des Feldes wieder. Im normalen
 * Fluss verschiebt das alles darunter – ein Klick auf das nächste Feld (z. B.
 * die Datenschutz-Checkbox) landet dann daneben. Deshalb liegt die Meldung im
 * reservierten Abstand unter dem Feld.
 */
.fluentform .ff-el-group .text-danger,
.fluentform .ff-el-group.ff-el-is-error .error {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  line-height: var(--line-height-tight);
}

/* ------------------------------------------------------------ Absenden */
.fluentform .ff_submit_btn_wrapper {
  margin-top: var(--space-8);
}

/* !important: Fluent Forms setzt die Button-Farbe als Inline-Style */
.fluentform .ff-btn-submit,
.fluentform .ff-btn-submit:hover,
.fluentform .ff-btn-submit:focus {
  background: var(--color-primary) !important;
  color: var(--color-on-primary) !important;
  border: 0 !important;
}

.fluentform .ff-btn-submit {
  padding: 1.125rem var(--space-8);
  font-family: var(--font-sans);
  font-size: var(--font-size-m);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  border-radius: var(--radius-s);
  box-shadow: none;
  opacity: 1;
  transition: filter 0.15s ease;
}

.fluentform .ff-btn-submit:hover {
  filter: brightness(1.1);
}

.fluentform .ff-btn-submit:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 3px;
}

.fluentform .ff-btn-submit:disabled,
.fluentform .ff-btn-submit.disabled {
  filter: grayscale(0.6);
  cursor: progress;
}

/* ------------------------------------------------------------ Erfolgsmeldung */
.ff-message-success {
  margin-top: var(--space-4);
  padding: var(--space-6);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-icon-card-border);
  border-left: 4px solid var(--color-success);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-card);
  font-size: var(--font-size-s);
  line-height: 1.5;
}

.ff-message-success p {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .fluentform .ff-el-form-control,
  .fluentform .ff-btn-submit {
    transition: none;
  }
}
