/* ==========================================================================
   WP-KORE CUBE CSS — KORE_FLUENTFORM (SSOT)
   Consolidated Single Source of Truth for element container, local tokens,
   and the entire FluentForms OKLCH theme layer (forms, conversational, modals).
   ========================================================================== */

:is(.fluent-form, .kore-fluentform, .fluentform-wrap) {
  --local-form-bg: transparent;
  --local-text: var(--local-color, var(--text-main));
  --local-text-muted: var(--text-muted);
  --local-border: var(--surface-border);
  --local-brand: var(--local-intent-color, var(--brand));
  --local-brand-on: var(--local-color, var(--brand-on));
  --local-brand-soft: var(--surface-subtle);
  --local-accent: var(--brand-accent);
  --local-accent-on: var(--brand-accent-on);
  --local-radius: var(--radius-brand, 0.5rem);
  --local-pad: 0;

  display: block;
  width: 100%;
  margin-block: 0;
  box-sizing: border-box;
  padding: var(--local-pad);
  background-color: var(--local-form-bg);
  border-radius: var(--local-radius);
  transition: var(--motion);
}

:is(.fluent-form, .kore-fluentform, .fluentform-wrap) .fluentform {
  background-color: transparent;
  color: var(--local-text);
  padding: 0;
  box-sizing: border-box;
}

/* ══════════════════════════════════════════════════════════════════
   WP-Kore Framework — Sovereign FluentForms OKLCH Theme Layer
   Governs all FluentForms native forms, shortcodes & elements with App-Grade HIG tokens
   Single Source of Truth (SSOT) for the entire FluentForms ecosystem.
   ══════════════════════════════════════════════════════════════════ */

/* 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);
}

/* 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 input[type="url"],
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: var(--font-size-body);
  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;
}

/* 5.1 International Phone / Mobile Input (intl-tel-input .iti OKLCH Layer) */
html body .fluentform .iti {
  display: block;
  width: 100%;
  position: relative;
}

html body .fluentform .iti input[type="tel"] {
  padding-left: calc(var(--space-xl) + var(--space-3xs));
}

html body .fluentform .iti__flag-container {
  padding: 0;
  border-radius: var(--radius-brand) 0 0 var(--radius-brand);
  overflow: visible;
}

html body .fluentform .iti__selected-flag {
  min-height: 2.75rem;
  padding: 0 var(--space-2xs) 0 var(--space-xs);
  border-radius: var(--radius-brand) 0 0 var(--radius-brand);
  background-color: transparent;
  transition: background-color var(--motion-fast) ease;
}

html body .fluentform .iti__selected-flag:hover {
  background-color: var(--surface-subtle);
}

html body .fluentform .iti__selected-dial-code {
  color: var(--text-main);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  margin-left: var(--space-3xs);
}

html body .fluentform .iti__arrow {
  border-top-color: var(--text-muted);
}

html body .fluentform .iti__arrow--up {
  border-bottom-color: var(--text-muted);
}

html body .fluentform .iti__country-list {
  background-color: var(--surface-elevated);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-brand);
  box-shadow: 0 10px 25px -5px oklch(0% 0 0 / 25%);
  max-height: 16rem;
  z-index: 100;
  padding: var(--space-3xs) 0;
  font-size: var(--font-size-sm);
}

html body .fluentform .iti__country {
  padding: var(--space-2xs) var(--space-xs);
  color: var(--text-main);
  outline: none;
  transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
}

html body .fluentform .iti__country.iti__highlight {
  background-color: var(--surface-subtle);
  color: var(--brand);
}

html body .fluentform .iti__country-name,
html body .fluentform .iti__dial-code {
  color: inherit;
}

html body .fluentform .iti__dial-code {
  color: var(--text-muted);
}

html body .fluentform .iti__divider {
  border-bottom: 1px solid var(--surface-border);
  margin-block: var(--space-3xs);
}

html body .fluentform .iti__search-input {
  width: calc(100% - var(--space-xs) * 2);
  margin: var(--space-3xs) var(--space-xs) var(--space-2xs);
  padding: var(--space-3xs) var(--space-2xs);
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-brand);
  font-size: var(--font-size-sm);
  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;
}

html body .fluentform input:focus,
html body .fluentform select:focus,
html body .fluentform textarea:focus,
html body .fluentform .ff-el-form-control:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
  background-color: var(--surface);
}

/* 6. Checkboxes & Radios (Touch Target Accessibility) */
html body .fluentform .ff-el-form-check {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  gap: var(--space-2xs);
  margin-bottom: var(--space-3xs);
  cursor: pointer;
}

/* Terms & Conditions Inline Compact Layout (Zero Dead Gap) */
html body .fluentform .ff-el-group:has(.ff-el-tc) {
  margin-block: var(--space-2xs) var(--space-xs);
}

html body .fluentform .ff-el-tc {
  min-height: auto !important;
  margin-block: 0;
  gap: var(--space-xs);
  align-items: flex-start;
}

html body .fluentform .ff-el-tc .ff-el-form-check-label,
html body .fluentform .ff-el-tc .ff_tc_label {
  display: flex !important;
  align-items: flex-start;
  gap: var(--space-xs);
  margin-bottom: 0;
  font-size: var(--font-size-xs);
  line-height: 1.4;
  color: var(--text-muted);
}

html body .fluentform .ff-el-tc .ff_tc_checkbox {
  flex-shrink: 0;
  margin-top: var(--space-3xs);
}

html body .fluentform .ff-el-tc .ff_t_c {
  color: var(--text-muted);
  font-size: var(--font-size-xs);
  display: inline-block;
}

html body .fluentform input[type="checkbox"],
html body .fluentform input[type="radio"] {
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--brand);
  cursor: pointer;
  flex-shrink: 0;
}

/* 7. Submit Buttons & Action Trigger */
html body .fluentform .ff-btn-submit,
html body .fluentform button[type="submit"],
html body .fluentform .ff_submit_btn_wrapper button,
html body .fluentform .ff-btn-primary,
.ff-default .ff-btn-primary:not(.ff_btn_no_style) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding-inline: var(--space-lg);
  padding-block: var(--space-xs);
  background-color: var(--brand) !important;
  border: 1px solid var(--brand) !important;
  color: var(--brand-on, oklch(100% 0 0)) !important;
  border-radius: var(--radius-brand);
  font-family: inherit;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform var(--motion-fast) cubic-bezier(0.2, 0, 0, 1), background-color var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}

html body .fluentform .ff-btn-submit:hover,
html body .fluentform button[type="submit"]:hover,
html body .fluentform .ff_submit_btn_wrapper button:hover,
html body .fluentform .ff-btn-primary:hover,
.ff-default .ff-btn-primary:not(.ff_btn_no_style):hover {
  background-color: var(--brand-hover) !important;
  border-color: var(--brand-hover) !important;
  color: var(--brand-on, oklch(100% 0 0)) !important;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

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.975);
}

html body .fluentform .ff-btn-submit:focus-visible,
html body .fluentform button[type="submit"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Soporte Canónico de Alineación y Ancho Completo para Botón de Enviar */
:is(.text-center, .form-centered, .items-center) .fluentform .ff_submit_btn_wrapper,
.fluentform.text-center .ff_submit_btn_wrapper {
  display: flex;
  justify-content: center;
  text-align: center;
}

:is(.btn-full, .form-btn-full, .card) .fluentform .ff-btn-submit,
:is(.btn-full, .form-btn-full, .card) .fluentform button[type="submit"],
:is(.btn-full, .form-btn-full, .card) .fluentform .ff_submit_btn_wrapper button {
  width: 100%;
}

/* 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(55% 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. Conversational Forms & Multi-Step Wizard */
html body .ffc_conv_wrapper,
html body .ff_conv_app {
  background-color: transparent !important;
  color: var(--text-main);
  width: 100%;
}

html body .ffc_conv_wrapper .fh2 .f-text,
html body .ffc_conv_wrapper .fh2 .stripe-inline-header {
  color: var(--text-main);
  font-family: inherit;
}

html body .ffc_conv_wrapper .fh2 .f-tagline,
html body .ffc_conv_wrapper .f-sub .f-help {
  color: var(--text-muted);
}

html body .ffc_conv_wrapper .ffc-counter-div span {
  color: var(--brand);
}

html body .ffc_conv_wrapper .ffc-counter-div .counter-icon-span svg {
  fill: var(--brand);
}

html body .vff-footer .f-progress-bar {
  background-color: var(--surface-subtle);
  border-radius: var(--radius-full);
}

html body .vff-footer .f-progress-bar-inner {
  background-color: var(--brand);
  border-radius: var(--radius-full);
}

html body .ffc_conv_wrapper .f-answer .f-radios-wrap ul li {
  background-color: var(--surface);
  border: var(--border-width) solid var(--surface-border);
  border-radius: var(--radius-control);
  transition: transform var(--motion-fast) ease, border-color var(--motion-fast) ease;
  min-height: 2.75rem;
  display: flex;
  align-items: center;
  padding: var(--space-2xs) var(--space-sm);
}

html body .ffc_conv_wrapper .f-answer .f-radios-wrap ul li:hover {
  background-color: var(--surface-elevated);
  border-color: var(--brand);
  transform: translateY(-1px);
}

html body .ffc_conv_wrapper .f-answer .f-radios-wrap ul li.f-selected {
  background-color: var(--surface-elevated);
  border-color: var(--brand);
}

html body .ffc_conv_wrapper .f-answer .f-radios-wrap ul li.f-selected .f-key {
  background-color: var(--brand);
  color: var(--brand-on);
}

html body .ffc_conv_wrapper .q-inner .o-btn-action,
html body .ffc_conv_wrapper .footer-inner-wrap .f-nav {
  background-color: var(--brand);
  color: var(--brand-on);
  border-radius: var(--radius-control);
  min-height: 2.75rem;
  padding: var(--space-xs) var(--space-md);
  cursor: pointer;
  transition: transform var(--motion-fast) ease, filter var(--motion-fast) ease;
}

html body .ffc_conv_wrapper .q-inner .o-btn-action:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

html body .ffc_conv_wrapper .q-inner .o-btn-action:active {
  transform: scale(0.975);
}

/* 11. Oxygen Widget 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%;
}
