/* ══════════════════════════════════════════════════════════════════
   WP-Kore Framework — Sovereign FluentForms OKLCH Theme Layer
   Governs all FluentForms native forms, shortcodes & elements with App-Grade HIG tokens
   ══════════════════════════════════════════════════════════════════ */

/* 1. Global Container & Layout Setup */
html body .fluentform,
html body .frm-fluent-form,
html body form.fluentform,
html body form.ff-form-stacked {
  --fluentform-primary: var(--brand);
  --fluentform-secondary: var(--text-muted);
  --fluentform-danger: 25;
  --fluentform-border-color: var(--surface-border);
  --fluentform-border-radius: var(--radius-brand);
  color: var(--text-main);
  width: 100%;
}

/* 2. Honeypot Anti-Spam Trap (Hidden from UI) */
html body .fluentform .ff_el_secret,
html body .fluentform .ff-el-group.ff_el_secret,
html body .fluentform input[name="_kore_website_trap"],
html body .fluentform ._kore_website_trap {
  display: none !important;
  visibility: hidden !important;
  height: 0;
  width: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

/* 3. Form Group & Field Container */
html body .fluentform .ff-el-group {
  margin-bottom: var(--space-sm);
  position: relative;
}

html body .fluentform .ff-el-group:empty,
html body .fluentform .ff-el-group:has(.ff-el-input--content:empty) {
  display: none !important;
}

html body .fluentform .ff-t-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

html body .fluentform .ff-t-container .ff-t-cell {
  flex: 1 1 0%;
  min-width: 11.25rem;
}

html body .fluentform .ff-t-container .ff-el-group {
  margin-bottom: 0;
}

@media (min-width: 58rem) {
  html body .fluentform .ff-t-container {
    flex-wrap: nowrap;
  }
  html body .fluentform .ff-t-container .ff-t-cell {
    min-width: 0;
  }
}

/* 4. Labels & Field Headers */
html body .fluentform label,
html body .fluentform .ff-el-input--label,
html body .fluentform .ff-el-input-label,
html body .fluentform .ff-el-form-check-label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.015em;
  color: var(--text-main);
  margin-bottom: var(--space-3xs);
  line-height: 1.35;
}

/* Dark Context Adaptations for Labels (WCAG 2.2 AA Compliance) */
html body .bg-dark .fluentform:not(.modal *):not(.modal-dialog *) label,
html body .bg-dark .fluentform:not(.modal *):not(.modal-dialog *) .ff-el-input--label,
html body .bg-dark .fluentform:not(.modal *):not(.modal-dialog *) .ff-el-input-label,
html body .bg-dark .fluentform:not(.modal *):not(.modal-dialog *) .ff-el-form-check-label {
  color: var(--text-main);
}

/* Dedicated Light Modal Context for FluentForm */
html body :is(.modal, .modal-dialog) .fluentform label,
html body :is(.modal, .modal-dialog) .fluentform .ff-el-input--label,
html body :is(.modal, .modal-dialog) .fluentform .ff-el-input-label,
html body :is(.modal, .modal-dialog) .fluentform .ff-el-form-check-label {
  color: var(--text-main);
  font-weight: var(--font-weight-semibold);
  font-size: 0.8125rem;
  margin-bottom: var(--space-3xs);
}

html body .fluentform .ff-el-input--label {
  display: flex;
  align-items: center;
  gap: var(--space-3xs);
}

html body .fluentform .ff-el-tooltip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  color: var(--text-muted);
  opacity: 0.75;
  cursor: help;
  transition: opacity var(--motion) ease, color var(--motion) ease;
}

html body .fluentform .ff-el-tooltip:hover {
  opacity: 1;
  color: var(--brand);
}

html body .fluentform .ff-el-tooltip svg {
  width: 0.875rem;
  height: 0.875rem;
  fill: currentColor;
}

/* 5. Inputs, Selects & Textareas (App-Grade 44pt Touch Target Floor) */
html body .fluentform input[type="text"],
html body .fluentform input[type="email"],
html body .fluentform input[type="number"],
html body .fluentform input[type="tel"],
html body .fluentform input[type="password"],
html body .fluentform select,
html body .fluentform textarea,
html body .fluentform .ff-el-form-control {
  display: block;
  width: 100%;
  min-height: 2.75rem;
  padding: var(--space-2xs) var(--space-xs);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-brand);
  background-color: var(--surface);
  color: var(--text-main);
  font-size: 0.875rem;
  line-height: 1.4;
  box-shadow: inset 0 1px 2px oklch(0% 0 0 / 3%);
  transition: border-color var(--motion) ease, box-shadow var(--motion) ease, background-color var(--motion) ease;
  box-sizing: border-box;
}

html body :is(.bg-dark, .surface-dark, [data-intent="inverse"], .bg-dark):not(.modal):not(.modal-dialog) .fluentform :is(input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="password"], select, textarea, .ff-el-form-control) {
  background-color: var(--surface-elevated, var(--surface));
  color: var(--text-main);
  border-color: var(--surface-border);
}

html body :is(.modal, .modal-dialog) .fluentform :is(input[type="text"], input[type="email"], input[type="number"], input[type="tel"], input[type="password"], select, textarea, .ff-el-form-control) {
  background-color: var(--surface);
  color: var(--text-main);
  border-color: var(--surface-border);
  box-shadow: inset 0 1px 2px oklch(0% 0 0 / 3%);
}

html body :is(.modal, .modal-dialog) .fluentform ::placeholder {
  color: var(--text-muted);
  opacity: 0.65;
}

html body .fluentform textarea,
html body .fluentform textarea.ff-el-form-control {

  min-height: 6.25rem;
  resize: vertical;
}

/* Custom Dropdown Chevron for Select */
html body .fluentform select,
html body .fluentform select.ff-el-form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  background-size: 1rem;
  padding-right: var(--space-lg);
  cursor: pointer;
}

/* Field Focus & Interactive Halo */
html body .fluentform input[type="text"]:focus,
html body .fluentform input[type="email"]:focus,
html body .fluentform input[type="number"]:focus,
html body .fluentform input[type="tel"]:focus,
html body .fluentform input[type="password"]:focus,
html body .fluentform select:focus,
html body .fluentform textarea:focus,
html body .fluentform .ff-el-form-control:focus {
  border-color: var(--brand);
  background-color: var(--surface-elevated);
  box-shadow: 0 0 0 3px var(--brand-glow), 0 1px 2px oklch(100% 0 0 / 60%);
  outline: none;
}

/* Placeholder Styling */
html body .fluentform ::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

/* 6. Checkboxes & Radio Buttons */
html body .fluentform .ff-el-form-check {
  display: inline-flex;
  align-items: flex-start;
  gap: var(--space-2xs);
  margin-top: var(--space-3xs);
  cursor: pointer;
}

html body .fluentform .ff-el-form-check-input {
  width: 1.125rem;
  height: 1.125rem;
  min-width: 1.125rem;
  margin-top: var(--space-3xs);
  accent-color: var(--brand);
  border-radius: calc(var(--radius-brand) * 0.5);
  border: 1px solid var(--surface-border);
  cursor: pointer;
}

html body .fluentform .ff-el-form-check-label {
  font-size: 0.8125rem;
  font-weight: var(--font-weight-regular);
  color: var(--text-main);
  line-height: 1.4;
  margin-bottom: 0;
  cursor: pointer;
}

/* 7. Submit Button Container & Button (App-Grade 48pt Touch Target) */
html body .fluentform .ff_submit_btn_wrapper {
  margin-top: var(--space-2xs);
}

html body .fluentform .ff-btn-submit,
html body .fluentform button[type="submit"],
html body .fluentform .ff_submit_btn_wrapper button,
html body .fluentform .ff_submit_btn_wrapper button.ff-btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  width: 100%;
  min-height: 3rem;
  padding: var(--space-2xs) var(--space-md);
  background-color: var(--brand);
  color: var(--brand-on);
  font-size: 0.875rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: 0.02em;
  border-radius: var(--radius-brand);
  border: 1px solid transparent;
  cursor: pointer;
  box-shadow: 0 0.125rem 0.375rem oklch(0% 0 0 / 12%), 0 0.0625rem 0.125rem oklch(100% 0 0 / 80%);
  transition: transform 120ms cubic-bezier(0.2, 0, 0, 1), background-color 140ms ease, box-shadow 140ms ease;
  text-decoration: none;
  line-height: 1;
}

html body .fluentform .ff-btn-submit:hover,
html body .fluentform button[type="submit"]:hover,
html body .fluentform .ff_submit_btn_wrapper button:hover {
  background-color: var(--brand-hover);
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.75rem oklch(0% 0 0 / 18%), 0 0.125rem 0.25rem var(--surface-border);
}

html body .fluentform .ff-btn-submit:active,
html body .fluentform button[type="submit"]:active,
html body .fluentform .ff_submit_btn_wrapper button:active {
  transform: scale(0.98);
}

/* 8. Validation Errors & Messages */
html body .fluentform .error,
html body .fluentform .ff-errors,
html body .fluentform .text-danger,
html body .fluentform .ff-el-is-error .ff-el-help-block {
  color: oklch(48% 0.22 25);
  font-size: 0.75rem;
  margin-top: var(--space-3xs);
  font-weight: var(--font-weight-semibold);
}

html body .fluentform .has-error input,
html body .fluentform .has-error select,
html body .fluentform .has-error textarea,
html body .fluentform .ff-el-is-error .ff-el-form-control {
  border-color: oklch(55% 0.22 25);
  box-shadow: 0 0 0 3px oklch(65% 0.22 25 / 0.25);
}

/* Tooltips, Help Icons & Required Asterisks */
html body .fluentform :is(.ff-help, .ff-el-tooltip, [data-tippy-content], .ff-tooltip) {
  color: var(--text-muted);
  cursor: help;
  transition: color var(--motion) ease;
}

html body .fluentform :is(.ff-help, .ff-el-tooltip, [data-tippy-content], .ff-tooltip):hover {
  color: var(--brand);
}

html body .fluentform :is(.ff-el-asterisk, .ff-required) {
  color: var(--brand);
  font-weight: var(--font-weight-bold);
  margin-left: var(--space-3xs);
}

/* 9. Success Confirmation Toast */
html body .fluentform .ff-message-success,
html body .fluentform .fluentform-step-success {
  background-color: var(--surface);
  color: var(--success);
  border: 1px solid var(--success);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-brand);
  font-size: 0.875rem;
  font-weight: var(--font-weight-medium);
  line-height: 1.5;
  margin-top: var(--space-xs);
}

/* 10. Oxygen Widget Wrapper Clean & HIG Enforcement Override */
html body .oxy-form-widget,
html body .ff-oxy-element {
  background-color: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  margin: 0;
  width: 100%;
}

.bg-dark html body .fluentform textarea,
.bg-dark html body .fluentform textarea.ff-el-form-control {
  width: 100%;
  min-width: 100%;
  max-width: 100%;
  min-height: 6.875rem;
  resize: vertical;
}

html body .fluentform .ff-el-form-control,
html body .fluentform input.ff-el-form-control,
html body .fluentform textarea.ff-el-form-control {
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-brand);
}

html body .fluentform label,
html body .fluentform .ff-el-input--label {
  color: var(--text-main);
  font-weight: var(--font-weight-semibold);
}
