/*
 * D5: brand styling for the existing Fluent Forms, on redesign pages only.
 * Mirrors src/app/register/RegistrationForm.tsx and src/app/contact/ContactForm.tsx:
 * - inputs:  w-full px-5 py-4 bg-white border border-dark/10 rounded-lg
 *            font-light text-sm text-dark placeholder:text-muted/50,
 *            focus border-pink + ring-1 ring-pink/20  (52px tall)
 * - error:   border-red-400 (focus red-500 / ring red-200), message
 *            text-red-500 text-xs font-light mt-1.5 ml-1
 * - section: font-display text-lg md:text-xl uppercase tracking-wider + 40x2 bar
 *            (gradient on the first section, purple on later ones), space-y-10
 * - submit:  gradient pill px-10 py-4, font-display text-sm uppercase
 *            tracking-widest, hover shadow-lg shadow-pink/25
 * - success: centered, gradient check circle, font-display text-xl uppercase
 * Forms: #3 "Записване (new site)" (Register 13580; a duplicate of the live
 * form #1 with the location checkboxes replaced by a required select:
 * visible labels, section breaks, name fields, select, flatpickr date,
 * hCaptcha) and #2 "Контакти" (Contact 13581: hidden labels + placeholders,
 * 2 columns). Form #1 stays on the live /forma-za-zapisvane/ page.
 *
 * Labels (v0.2.7, A11): the source hides its labels (sr-only + placeholders).
 * Form 1 has visible labels and no placeholders, so hiding them would leave
 * empty boxes. They are kept visible but quiet: text-xs, uppercase, wide
 * tracking, muted, pink asterisk. Fields set to "hide label" in FF (form 2)
 * stay sr-only like the source.
 * Checkbox groups (e.g. form 1's location list) are styled as selectable cards (2 columns on
 * desktop): custom box, gradient when checked, pink border on the card.
 *
 * Every rule is under body.td-new .fluentform (or body.td-new for the
 * flatpickr popup / FF messages outside the form), so the live form pages
 * (/forma-za-zapisvane/, /kontakt/) are untouched. Specificity is raised with
 * .ff-el-group / .ff_submit_btn_wrapper to beat the Elementor kit
 * (.elementor-kit-N input:not(..):not(..)) and FF's per-form inline
 * button colour (form.fluent_form_N .ff-btn-submit:not(..)) without
 * !important. inc/fluent-forms.php enqueues it only on singular pages that
 * are td-new or embed a form.
 */

body.td-new .fluentform {
  font-family: var(--font-sans);
  font-weight: 300;
  color: var(--dark);
}

/* ---------- Layout and spacing (space-y-5 / grid gap-5) ---------- */

body.td-new .fluentform .ff-el-group {
  margin-bottom: 1.25rem;
}

body.td-new .fluentform .ff-t-container {
  display: flex;
  gap: 1.25rem;
}

body.td-new .fluentform .ff-t-container .ff-t-cell {
  flex: 1 1 0;
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
}

/* Below md: one column, like grid-cols-1 in the source. */
@media (max-width: 767px) {
  body.td-new .fluentform .ff-t-container {
    display: block;
  }
}

/* ---------- Labels ---------- */

body.td-new .fluentform .ff-el-group .ff-el-input--label {
  display: block;
  margin-bottom: 0.5rem;
  padding: 0;
  line-height: 1rem;
}

body.td-new .fluentform .ff-el-group .ff-el-input--label label {
  display: inline;
  margin: 0;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

body.td-new .fluentform .ff-el-input--label.ff-el-is-required.asterisk-right label::after {
  margin-left: 0.25rem;
  color: var(--pink);
}

body.td-new .fluentform .ff-el-input--label.ff-el-is-required.asterisk-left label::before {
  margin-right: 0.25rem;
  color: var(--pink);
}

/* Fields with "hide label" (the Contact form, like the source's sr-only labels) */
body.td-new .fluentform .ff-el-form-hide_label > .ff-el-input--label {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Inputs, selects, textareas ---------- */

body.td-new .fluentform .ff-el-group .ff-el-form-control {
  display: block;
  width: 100%;
  height: auto;
  min-height: 3.25rem;
  margin: 0;
  padding: 1rem 1.25rem;
  background-color: #fff;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 0.5rem;
  box-shadow: none;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 300;
  color: var(--dark);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

body.td-new .fluentform .ff-el-group .ff-el-form-control::placeholder {
  color: rgba(102, 102, 102, 0.5);
  opacity: 1;
}

body.td-new .fluentform .ff-el-group .ff-el-form-control:hover {
  border-color: rgba(17, 17, 17, 0.2);
}

body.td-new .fluentform .ff-el-group .ff-el-form-control:focus {
  outline: none;
  border-color: var(--pink);
  box-shadow: 0 0 0 1px rgba(232, 36, 124, 0.2);
}

body.td-new .fluentform .ff-el-group select.ff-el-form-control {
  padding-right: 3rem;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23666666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem 1rem;
}

body.td-new .fluentform .ff-el-group textarea.ff-el-form-control {
  min-height: 9.5rem;
  resize: none;
}

/* Date (flatpickr text input): calendar icon on the right, like the native date input. */
body.td-new .fluentform .ff-el-group .ff-el-form-control.ff-el-datepicker,
body.td-new .fluentform .ff-el-group .ff-el-form-control[data-type-datepicker] {
  padding-right: 3rem;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23666666' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='5' width='18' height='16' rx='2'/%3E%3Cpath d='M16 3v4M8 3v4M3 10h18'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1.125rem 1.125rem;
}

/* flatpickr popup (appended to <body>) in brand colours */
body.td-new .flatpickr-calendar {
  font-family: var(--font-sans);
  border-radius: 0.75rem;
  box-shadow: 0 10px 30px rgba(17, 17, 17, 0.12);
}

body.td-new .flatpickr-day.selected,
body.td-new .flatpickr-day.selected:hover,
body.td-new .flatpickr-day.selected:focus {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
}

body.td-new .flatpickr-day.today {
  border-color: var(--purple);
}

body.td-new .flatpickr-day:hover,
body.td-new .flatpickr-day:focus {
  background: rgba(232, 36, 124, 0.08);
  border-color: transparent;
}

/* ---------- Checkboxes and radios ---------- */

/* Default (single checkboxes, terms): pink accent, muted text. */
body.td-new .fluentform .ff-el-form-check-label {
  font-size: 0.875rem;
  line-height: 1.5rem;
  font-weight: 300;
  color: var(--muted);
}

body.td-new .fluentform .ff-el-form-check-input {
  accent-color: var(--pink);
}

body.td-new .fluentform .ff-el-form-check-label a,
body.td-new .fluentform .ff_tc_checkbox a,
body.td-new .fluentform .ff-el-tc a {
  color: var(--pink);
  text-decoration: underline;
  text-underline-offset: 4px;
}

/* Checkbox / radio groups ("Записвам се в:"): selectable cards, 2 columns from md. */
body.td-new .fluentform .ff-el-group .ff-el-input--content:has(> .ff-el-form-check) {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 768px) {
  body.td-new .fluentform .ff-el-group .ff-el-input--content:has(> .ff-el-form-check) {
    grid-template-columns: 1fr 1fr;
  }
}

body.td-new .fluentform .ff-el-group .ff-el-input--content > .ff-el-form-check {
  margin: 0;
  padding: 0;
}

body.td-new .fluentform .ff-el-group .ff-el-input--content > .ff-el-form-check > .ff-el-form-check-label {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  height: 100%;
  min-height: 3.25rem;
  margin: 0;
  padding: 0.875rem 1.25rem;
  background-color: #fff;
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 300;
  letter-spacing: 0;
  text-transform: none;
  color: var(--dark);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

body.td-new .fluentform .ff-el-group .ff-el-input--content > .ff-el-form-check > .ff-el-form-check-label:hover {
  border-color: rgba(232, 36, 124, 0.4);
}

body.td-new .fluentform .ff-el-group .ff-el-input--content > .ff-el-form-check > .ff-el-form-check-label:has(input:checked) {
  border-color: var(--pink);
  background-color: rgba(232, 36, 124, 0.04);
  box-shadow: 0 0 0 1px rgba(232, 36, 124, 0.2);
}

body.td-new .fluentform .ff-el-group .ff-el-input--content > .ff-el-form-check > .ff-el-form-check-label:has(input:focus-visible) {
  border-color: var(--pink);
  box-shadow: 0 0 0 3px rgba(232, 36, 124, 0.2);
}

body.td-new .fluentform .ff-el-group .ff-el-form-check-label .ff-el-form-check-input {
  -webkit-appearance: none;
  appearance: none;
  flex-shrink: 0;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0;
  border: 1.5px solid rgba(17, 17, 17, 0.25);
  border-radius: 0.3rem;
  background: #fff center / 0.8rem 0.8rem no-repeat;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

body.td-new .fluentform .ff-el-group .ff-el-form-check-label .ff-el-form-check-radio {
  border-radius: 9999px;
}

body.td-new .fluentform .ff-el-group .ff-el-form-check-label .ff-el-form-check-input:checked {
  border-color: transparent;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center / 0.8rem 0.8rem no-repeat,
    var(--grad);
}

body.td-new .fluentform .ff-el-group .ff-el-form-check-label .ff-el-form-check-input:focus {
  outline: none;
}

body.td-new .fluentform .ff-el-group .ff-el-input--content:has(> .ff-el-form-check) > .error {
  grid-column: 1 / -1;
}

/* ---------- Section breaks ---------- */

body.td-new .fluentform .ff-el-group.ff-el-section-break {
  margin: 2.5rem 0 1.25rem;
  padding: 0;
}

/* The first section opens the form. */
body.td-new .fluentform input[type="hidden"] + .ff-el-group.ff-el-section-break {
  margin-top: 0;
}

body.td-new .fluentform .ff-el-section-break .ff-el-section-title {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.75rem;
  font-weight: 400;
  font-style: normal;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dark);
}

body.td-new .fluentform .ff-el-section-break .ff-el-section-title::before {
  content: "";
  display: inline-block;
  flex-shrink: 0;
  width: 2.5rem;
  height: 2px;
  background: var(--grad);
}

/* Second and later sections: purple bar (RegistrationForm athlete legend). */
body.td-new .fluentform .ff-el-section-break ~ .ff-el-section-break .ff-el-section-title::before {
  background: var(--purple);
}

@media (min-width: 768px) {
  body.td-new .fluentform .ff-el-section-break .ff-el-section-title {
    font-size: 1.25rem;
  }
}

body.td-new .fluentform .ff-el-section-break hr {
  display: none;
}

body.td-new .fluentform .ff-section_break_desk:empty {
  display: none;
}

body.td-new .fluentform .ff-section_break_desk {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* ---------- Captcha (hCaptcha / Turnstile / reCAPTCHA): centered like the source Turnstile ---------- */

body.td-new .fluentform .ff-el-group:has(.h-captcha, .ff-el-turnstile, .ff-el-recaptcha) {
  margin-top: 2.5rem;
}

body.td-new .fluentform .ff-el-group:has(.h-captcha, .ff-el-turnstile, .ff-el-recaptcha) .ff-el-input--content > div {
  display: flex;
  justify-content: center;
}

/* ---------- Validation errors ---------- */

body.td-new .fluentform .ff-el-group.ff-el-is-error .ff-el-form-control,
body.td-new .fluentform .ff-el-group.ff-el-is-error .ff-el-form-check-label {
  border-color: #f87171;
}

body.td-new .fluentform .ff-el-group.ff-el-is-error .ff-el-form-control:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 1px #fecaca;
}

body.td-new .fluentform .ff-el-group.ff-el-is-error .ff-el-input--label label {
  color: #ef4444;
}

body.td-new .fluentform .ff-el-group .error.text-danger,
body.td-new .fluentform .ff-el-is-error .text-danger {
  margin: 0.375rem 0 0 0.25rem;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1rem;
  font-weight: 300;
  color: #ef4444;
}

body.td-new .ff-errors-in-stack {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 300;
  color: #ef4444;
}

body.td-new .ff-errors-in-stack .error {
  color: inherit;
}

/* ---------- Submit: gradient pill ---------- */

body.td-new .fluentform .ff-el-group.ff_submit_btn_wrapper {
  margin: 2.5rem 0 0;
  padding-top: 0.5rem;
  text-align: center;
}

body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 0;
  padding: 1rem 2.5rem;
  border: 0;
  border-radius: 9999px;
  background: var(--grad);
  color: #fff;
  font-family: var(--font-display);
  font-size: 0.875rem;
  line-height: 1.25rem;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: none;
  cursor: pointer;
  opacity: 1;
  transition: box-shadow 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
}

body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit:hover,
body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit:focus {
  background: var(--grad);
  color: #fff;
  opacity: 1;
  box-shadow: 0 10px 15px -3px rgba(232, 36, 124, 0.25), 0 4px 6px -4px rgba(232, 36, 124, 0.25);
}

body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit:hover {
  transform: translateY(-1px);
}

body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 4px;
}

body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit:disabled,
body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Success message: replaces the form, centered ---------- */

body.td-new .ff-message-success {
  margin: 0;
  padding: 4rem 1rem;
  border: 0;
  box-shadow: none;
  background: transparent;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.25rem;
  line-height: 1.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dark);
}

body.td-new .ff-message-success p {
  margin: 0;
  font: inherit;
  color: inherit;
}

body.td-new .ff-message-success::before {
  content: "";
  display: block;
  width: 4rem;
  height: 4rem;
  margin: 0 auto 1.5rem;
  border-radius: 9999px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 13l4 4L19 7'/%3E%3C/svg%3E") center / 2rem 2rem no-repeat,
    var(--grad);
}

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

  body.td-new .fluentform .ff_submit_btn_wrapper .ff-btn-submit:hover {
    transform: none;
  }
}
