/* ===================================================================
   JD's Vegan Dives — Apple-Style Global Form System
   Covers: native inputs, CF7, WooCommerce, Stripe, creator forms
   Enqueued globally after global.css.
   =================================================================== */


/* ── 1. Native field base ─────────────────────────────────────────── */

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: var(--jdvd-form-field-height);
  box-sizing: border-box;
  border: 1px solid var(--jdvd-form-field-border);
  border-radius: var(--jdvd-form-field-radius);
  background: var(--jdvd-form-field-bg);
  color: var(--jdvd-form-field-text);
  font-family: var(--jdvd-form-font);
  font-size: 17px;
  line-height: 1.24;
  font-weight: 400;
  letter-spacing: -0.022em;
  padding: 14px 16px;
  box-shadow: none;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

/* iOS zoom guard — never below 16px on small screens */
@media (max-width: 734px) {
  input[type="text"],
  input[type="email"],
  input[type="url"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
  }
}


/* ── 2. Hover state ───────────────────────────────────────────────── */

input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="tel"]:hover,
input[type="number"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
input[type="date"]:hover,
select:hover,
textarea:hover {
  border-color: var(--jdvd-form-field-border-hover);
  background: var(--jdvd-form-field-bg-hover);
}


/* ── 3. Focus state ───────────────────────────────────────────────── */

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="password"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
  border-color: var(--jdvd-form-field-border-focus);
  background: var(--jdvd-form-field-bg-focus);
  box-shadow: var(--jdvd-form-shadow-focus);
  outline: none;
}


/* ── 4. Placeholder ───────────────────────────────────────────────── */

::placeholder {
  color: var(--jdvd-form-field-placeholder);
  opacity: 1;
}


/* ── 5. Labels ────────────────────────────────────────────────────── */

label {
  display: block;
  color: var(--jdvd-form-label);
  font-family: var(--jdvd-form-font);
  font-size: 13px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 7px;
}


/* ── 6. Textarea ──────────────────────────────────────────────────── */

textarea {
  min-height: 144px;
  resize: vertical;
  line-height: 1.5;
}


/* ── 7. Select — custom arrow ─────────────────────────────────────── */

select {
  padding-right: 44px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--jdvd-form-field-text) 50%),
    linear-gradient(135deg, var(--jdvd-form-field-text) 50%, transparent 50%);
  background-position:
    calc(100% - 21px) calc(50% + 1px),
    calc(100% - 15px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

/* Option items inherit dark bg */
select option {
  background: var(--jdvd-charcoal, #111216);
  color: var(--jdvd-form-field-text);
}


/* ── 8. Error / invalid states ────────────────────────────────────── */

input.is-invalid,
select.is-invalid,
textarea.is-invalid,
.wpcf7-not-valid,
.woocommerce-invalid input.input-text,
.woocommerce-invalid select {
  border-color: var(--jdvd-form-error-border) !important;
  background: var(--jdvd-form-error-bg) !important;
  box-shadow: 0 0 0 4px rgba(255, 104, 129, 0.14) !important;
}

.jdvd-form-error,
.wpcf7-not-valid-tip,
.woocommerce-invalid-required-field label::after,
.woocommerce form .form-row.woocommerce-invalid label em,
.woocommerce-error li,
.woocommerce-error {
  color: var(--jdvd-form-error);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 500;
}

.jdvd-form-success {
  color: var(--jdvd-success);
  font-size: 13px;
  font-weight: 500;
}


/* ── 9. Submit buttons ────────────────────────────────────────────── */

input[type="submit"],
button[type="submit"],
.wpcf7 input[type="submit"] {
  min-height: 52px;
  width: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 28px;
  border: none;
  border-radius: var(--jdvd-button-radius, 14px);
  background: linear-gradient(135deg, var(--jdvd-royal-purple, #5c4485), #7a5ac8);
  color: var(--jdvd-cream, #f6f2ea);
  font-family: var(--jdvd-form-font);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: none;
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
  -webkit-appearance: none;
  appearance: none;
}

input[type="submit"]:hover,
button[type="submit"]:hover,
.wpcf7 input[type="submit"]:hover {
  background: linear-gradient(135deg, #6a50a0, #8a6af0);
  transform: translateY(-1px);
  box-shadow: none;
}

input[type="submit"]:focus-visible,
button[type="submit"]:focus-visible {
  outline: 2px solid var(--jdvd-form-field-border-focus);
  outline-offset: 3px;
}

/* Full-width submit when it's the only action in a form */
.wpcf7 input[type="submit"] {
  width: 100%;
}


/* ── 10. Contact Form 7 — structural cleanup ──────────────────────── */

/* Form layout: stack fields with consistent gap */
.wpcf7 form,
.wpcf7-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Remove CF7's default paragraph margin */
.wpcf7 form p,
.wpcf7-form p {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

/* The control-wrap sits inside <p>, don't add extra spacing */
.wpcf7 .wpcf7-form-control-wrap {
  display: block;
  width: 100%;
}

/* CF7 fields — inherit base styles; add explicit sizing */
.wpcf7 input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.wpcf7 textarea,
.wpcf7 select {
  width: 100%;
  min-height: var(--jdvd-form-field-height);
  box-sizing: border-box;
  border: 1px solid var(--jdvd-form-field-border);
  border-radius: var(--jdvd-form-field-radius);
  background: var(--jdvd-form-field-bg);
  color: var(--jdvd-form-field-text);
  font-family: var(--jdvd-form-font);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: -0.022em;
  padding: 14px 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

@media (max-width: 734px) {
  .wpcf7 input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]),
  .wpcf7 textarea,
  .wpcf7 select {
    font-size: 16px;
  }
}

.wpcf7 input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):hover,
.wpcf7 textarea:hover,
.wpcf7 select:hover {
  border-color: var(--jdvd-form-field-border-hover);
  background: var(--jdvd-form-field-bg-hover);
}

.wpcf7 input:not([type="submit"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):focus,
.wpcf7 textarea:focus,
.wpcf7 select:focus {
  border-color: var(--jdvd-form-field-border-focus);
  background: var(--jdvd-form-field-bg-focus);
  box-shadow: var(--jdvd-form-shadow-focus);
  outline: none;
}

.wpcf7 textarea {
  min-height: 144px;
  resize: vertical;
  line-height: 1.5;
}

.wpcf7 select {
  padding-right: 44px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--jdvd-form-field-text) 50%),
    linear-gradient(135deg, var(--jdvd-form-field-text) 50%, transparent 50%);
  background-position:
    calc(100% - 21px) calc(50% + 1px),
    calc(100% - 15px) calc(50% + 1px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.wpcf7 select option {
  background: var(--jdvd-charcoal, #111216);
  color: var(--jdvd-form-field-text);
}

/* CF7 labels */
.wpcf7 label {
  color: var(--jdvd-form-label);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}

/* CF7 validation tip */
.wpcf7-not-valid-tip {
  display: block;
  margin-top: 5px;
  color: var(--jdvd-form-error);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
}

/* CF7 invalid field highlight */
.wpcf7-not-valid {
  border-color: var(--jdvd-form-error-border) !important;
  background: var(--jdvd-form-error-bg) !important;
  box-shadow: 0 0 0 4px rgba(255, 104, 129, 0.14) !important;
}

/* CF7 response output */
.wpcf7-response-output {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  border: none !important;
}

.wpcf7-mail-sent-ok {
  background: rgba(122, 214, 158, 0.12);
  color: var(--jdvd-success);
}

.wpcf7-mail-sent-ng,
.wpcf7-spam-blocked,
.wpcf7-validation-errors,
.wpcf7-acceptance-missing {
  background: var(--jdvd-form-error-bg);
  color: var(--jdvd-form-error);
}

/* CF7 spinner */
.wpcf7-spinner {
  margin-left: 10px;
}


/* ── 11. Request Line — premium card wrapper ──────────────────────── */

.jdvd-request__cf7 {
  max-width: var(--jdvd-form-width);
  padding: clamp(22px, 4vw, 36px);
  border: 0;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(246, 242, 234, 0.065), rgba(246, 242, 234, 0.025)),
    rgba(5, 5, 6, 0.20);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  box-shadow: var(--jdvd-form-card-shadow);
}

/* Remove the old flat container look from the request header */
.jdvd-request__header {
  max-width: var(--jdvd-form-width);
}

/* Widen the request page container a little */
.jdvd-page-request .jdvd-container {
  max-width: 900px;
}


/* ── 12. Stripe element wrappers (CSS layer only) ─────────────────── */
/* Note: checkout.css !important rules win on WC checkout page.       */
/* These apply on any non-checkout context or as a lower-specificity  */
/* baseline.                                                           */

.StripeElement,
.wc-stripe-elements-field,
.wc-stripe-iban-element-field {
  min-height: var(--jdvd-form-field-height);
  border: 1px solid var(--jdvd-form-field-border);
  border-radius: var(--jdvd-form-field-radius);
  background: var(--jdvd-form-field-bg);
  padding: 16px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.StripeElement--focus {
  border-color: var(--jdvd-form-field-border-focus) !important;
  box-shadow: var(--jdvd-form-shadow-focus) !important;
}

.StripeElement--invalid {
  border-color: var(--jdvd-form-error-border) !important;
  background: var(--jdvd-form-error-bg) !important;
}


/* ── 13. Checkboxes & radio ───────────────────────────────────────── */

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent-light);
  width: 18px;
  height: 18px;
  min-height: unset;
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--jdvd-form-field-border-focus);
  outline-offset: 2px;
}

/* CF7 / Woo checkbox rows */
.wpcf7 input[type="checkbox"],
.wpcf7 input[type="radio"],
.woocommerce form input[type="checkbox"],
.jdvd-checkboxes input[type="checkbox"] {
  width: 18px;
  height: 18px;
  min-height: unset;
  margin: 0 8px 0 0;
}

/* Creator dashboard checkbox grid — pill-like label rows */
.jdvd-checkboxes label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 14px 6px 10px;
  border: 0;
  border-radius: var(--radius-full);
  background: var(--jdvd-form-field-bg);
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.jdvd-checkboxes label:has(input:checked) {
  border-color: var(--accent-light);
  background: rgba(123, 94, 216, 0.12);
  color: var(--text-primary);
}

/* Woo terms checkbox label — keep normal inline */
.woocommerce-checkout .woocommerce-form__label-for-checkbox {
  display: inline-flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: normal;
  margin: 0;
}


/* ── 14. Field grid / rows ────────────────────────────────────────── */

.jdvd-form-grid {
  display: grid;
  gap: 16px;
}

.jdvd-field-row {
  display: grid;
  gap: 16px;
}

@media (min-width: 735px) {
  .jdvd-field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .jdvd-form-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}


/* ── 15. Creator dashboard form — unified fieldset system ─────────── */

.jdvd-fieldset {
  border: 0;
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 28px);
  background: var(--jdvd-form-field-bg);
}

.jdvd-fieldset legend {
  font-family: var(--jdvd-font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 0 10px;
  color: var(--accent-light);
}

/* Unify .jdvd-field label to form token */
.jdvd-field label {
  color: var(--jdvd-form-label);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0 0 6px;
}

/* Field inputs in the auth/creator context */
.jdvd-field input[type="text"],
.jdvd-field input[type="email"],
.jdvd-field input[type="password"],
.jdvd-field input[type="url"],
.jdvd-field input[type="number"],
.jdvd-field select,
.jdvd-field textarea {
  min-height: var(--jdvd-form-field-height);
  border-color: var(--jdvd-form-field-border);
  background: var(--jdvd-form-field-bg);
  font-size: 16px; /* iOS safe */
  padding: 14px 16px;
  border-radius: var(--jdvd-form-field-radius);
}

.jdvd-field input:focus,
.jdvd-field select:focus,
.jdvd-field textarea:focus {
  border-color: var(--jdvd-form-field-border-focus);
  box-shadow: var(--jdvd-form-shadow-focus);
}

/* Form actions row */
.jdvd-form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 0;
  flex-wrap: wrap;
}

/* Helper text below a field */
.jdvd-form-note,
.jdvd-field-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--jdvd-form-helper);
  margin-top: 5px;
}


/* ── 16. Form utility card classes ────────────────────────────────── */

.jdvd-form-card {
  padding: clamp(20px, 3.5vw, 32px);
  border: 0;
  border-radius: 24px;
  background: var(--jdvd-form-card-bg);
  backdrop-filter: blur(20px) saturate(150%);
  -webkit-backdrop-filter: blur(20px) saturate(150%);
  box-shadow: var(--jdvd-form-card-shadow);
}

.jdvd-form-section {
  margin-bottom: 28px;
}

.jdvd-form-section + .jdvd-form-section {
  padding-top: 24px;
  border-top: 0;
}


/* ── 17. WooCommerce — upgrade field height & focus ring ──────────── */

/* These supplement checkout.css (checkout.css loads after forms.css   */
/* and uses !important — so any overrides here need !important too).   */

.woocommerce form .form-row input.input-text,
.woocommerce form .form-row textarea,
.woocommerce-page form .form-row input.input-text {
  min-height: var(--jdvd-form-field-height) !important;
  font-size: 16px !important; /* iOS safe */
  border-radius: var(--jdvd-form-field-radius) !important;
}

.woocommerce form .form-row input.input-text:hover,
.woocommerce-page form .form-row input.input-text:hover {
  border-color: var(--jdvd-form-field-border-hover) !important;
  background: var(--jdvd-form-field-bg-hover) !important;
}

/* Fix focus ring from old green → correct purple */
.woocommerce form .form-row input.input-text:focus,
.woocommerce form .form-row select:focus,
.woocommerce-page form .form-row input.input-text:focus {
  border-color: var(--jdvd-form-field-border-focus) !important;
  box-shadow: var(--jdvd-form-shadow-focus) !important;
}

/* Labels — lighter, smaller, uppercase tracking */
.woocommerce form .form-row label,
.woocommerce-checkout form label {
  font-size: 12px !important;
  color: var(--jdvd-form-label) !important;
}

/* WooCommerce form row spacing */
.woocommerce-checkout .woocommerce form .form-row {
  margin-bottom: 16px !important;
}

/* WooCommerce checkout card sections — rounded */
.woocommerce-checkout #order_review,
.woocommerce-checkout #payment {
  border-radius: 24px !important;
}

/* Order review backdrop */
.woocommerce-checkout #order_review {
  background:
    linear-gradient(145deg, rgba(246, 242, 234, 0.045), rgba(246, 242, 234, 0.018)) !important;
  backdrop-filter: blur(20px) saturate(150%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(150%) !important;
}


/* ── 18. Accessibility ────────────────────────────────────────────── */

/* Keyboard focus ring on any interactive element not already styled */
:focus-visible {
  outline: 2px solid var(--jdvd-form-field-border-focus);
  outline-offset: 3px;
}

/* Remove focus ring from mouse users (only show for keyboard) */
:focus:not(:focus-visible) {
  outline: none;
}


/* ── 19. Mobile overflow guard ────────────────────────────────────── */

@media (max-width: 390px) {
  .jdvd-request__cf7 {
    padding: 18px;
    border-radius: 20px;
  }

  .jdvd-form-card {
    padding: 18px;
    border-radius: 18px;
  }

  .wpcf7 form,
  .wpcf7-form {
    gap: 14px;
  }
}

/* Button system correction: real actions are rounded rectangles. */
input[type="submit"],
button[type="submit"],
.wpcf7 input[type="submit"],
.jdvd-request__cf7 input[type="submit"] {
  min-height: var(--jdvd-button-height-md);
  border-radius: var(--jdvd-button-radius) !important;
  box-shadow: none !important;
}

input[type="submit"]:hover,
button[type="submit"]:hover,
.wpcf7 input[type="submit"]:hover,
.jdvd-request__cf7 input[type="submit"]:hover {
  box-shadow: none !important;
}

/* Checkbox labels render as filled chips, not bordered pills. */
.jdvd-checkboxes label {
  border: 0 !important;
  box-shadow: none !important;
}
