/**
 * ComplyX Demo Form Module - Enterprise Styling
 * Reusable, responsive, accessible, with dark/light mode support,
 * custom Google reCAPTCHA-style human check, uniform logos, and thank-you modal.
 */

:root {
  --cx-df-primary: #dc2626;
  --cx-df-primary-hover: #b91c1c;
  --cx-df-primary-rgb: 220, 38, 38;
  --cx-df-bg: #ffffff;
  --cx-df-text: #09090b;
  --cx-df-text-muted: #71717a;
  --cx-df-border: #e4e4e7;
  --cx-df-border-focus: #18181b;
  --cx-df-card-bg: #f8fafc;
  --cx-df-card-border: #e2e8f0;
  --cx-df-card-hover: #f1f5f9;
  --cx-df-error: #ef4444;
  --cx-df-success: #10b981;
  --cx-df-radius: 14px;
  --cx-df-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-mode="dark"] :root,
html[data-mode="dark"] {
  --cx-df-bg: #141414;
  --cx-df-text: #f4f4f5;
  --cx-df-text-muted: #a1a1aa;
  --cx-df-border: #27272a;
  --cx-df-border-focus: #ffffff;
  --cx-df-card-bg: #18181b;
  --cx-df-card-border: #27272a;
  --cx-df-card-hover: #222226;
}

/* Container */
.cx-df-wrapper {
  font-family: var(--cx-df-font);
  color: var(--cx-df-text);
  width: 100%;
  box-sizing: border-box;
}

.cx-df-wrapper *,
.cx-df-wrapper *::before,
.cx-df-wrapper *::after {
  box-sizing: border-box;
}

/* Products Section */
.cx-df-products-section {
  margin-bottom: 28px;
  text-align: center;
}

.cx-df-products-title {
  font-size: clamp(20px, 3.5vw, 26px);
  font-weight: 750;
  text-align: center;
  color: var(--cx-df-text);
  margin: 0 0 8px 0;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.cx-df-products-sub {
  font-size: 13.5px;
  color: var(--cx-df-text-muted);
  text-align: center;
  margin: 0 0 18px 0;
}

/* Uniform Products Grid */
.cx-df-products-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 560px) {
  .cx-df-products-grid {
    grid-template-columns: 1fr;
  }
}

.cx-df-product-card {
  position: relative;
  display: block;
  cursor: pointer;
  user-select: none;
}

.cx-df-product-card input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cx-df-product-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 98px;
  padding: 14px 14px 12px;
  background: var(--cx-df-card-bg);
  border: 1.5px solid var(--cx-df-card-border);
  border-radius: var(--cx-df-radius);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-align: center;
}

.cx-df-product-card:hover .cx-df-product-inner {
  border-color: rgba(var(--cx-df-primary-rgb), 0.5);
  background: var(--cx-df-card-hover);
  transform: translateY(-2px);
}

.cx-df-product-card input:checked+.cx-df-product-inner {
  border-color: var(--cx-df-primary);
  background: rgba(var(--cx-df-primary-rgb), 0.06);
  box-shadow: 0 4px 20px -6px rgba(var(--cx-df-primary-rgb), 0.35);
  transform: translateY(-2px);
}

/* Same logo sizes for all products */
.cx-df-logo-container {
  height: 38px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 6px;
}

.cx-df-logo-container img,
.cx-df-logo-container svg {
  height: 32px;
  max-width: 135px;
  width: auto;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.cx-df-product-card:hover .cx-df-logo-container img {
  transform: scale(1.04);
}

.cx-df-product-name {
  font-size: 11.5px;
  color: var(--cx-df-text-muted);
  line-height: 1.35;
  display: block;
}

.cx-df-product-tick {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--cx-df-card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--cx-df-bg);
  transition: all 0.2s ease;
  color: transparent;
}

.cx-df-product-tick svg {
  width: 12px;
  height: 12px;
  stroke-width: 3;
}

.cx-df-product-card input:checked+.cx-df-product-inner .cx-df-product-tick {
  background: var(--cx-df-primary);
  border-color: var(--cx-df-primary);
  color: #ffffff;
}

/* Form Fields Grid */
.cx-df-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.cx-df-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 600px) {
  .cx-df-row {
    grid-template-columns: 1fr;
  }
}

.cx-df-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.cx-df-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--cx-df-text);
  display: flex;
  align-items: center;
  gap: 4px;
}

.cx-df-req {
  color: var(--cx-df-primary);
  font-weight: bold;
}

.cx-df-opt {
  font-size: 11px;
  color: var(--cx-df-text-muted);
  font-weight: normal;
  margin-left: 4px;
}

.cx-df-input,
.cx-df-select,
.cx-df-textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--cx-df-border);
  border-radius: 10px;
  background: var(--cx-df-bg);
  color: var(--cx-df-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  outline: none;
}

.cx-df-input:hover,
.cx-df-select:hover,
.cx-df-textarea:hover {
  border-color: rgba(0, 0, 0, 0.3);
}

[data-mode="dark"] .cx-df-input:hover,
[data-mode="dark"] .cx-df-select:hover,
[data-mode="dark"] .cx-df-textarea:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

.cx-df-input:focus,
.cx-df-select:focus,
.cx-df-textarea:focus {
  border-color: var(--cx-df-primary);
  box-shadow: 0 0 0 3px rgba(var(--cx-df-primary-rgb), 0.15);
}

.cx-df-input.cx-df-has-error,
.cx-df-select.cx-df-has-error,
.cx-df-textarea.cx-df-has-error {
  border-color: var(--cx-df-error) !important;
  background-color: rgba(239, 68, 68, 0.02);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

.cx-df-error-text {
  font-size: 12px;
  color: var(--cx-df-error);
  line-height: 1.35;
  display: none;
  margin-top: 2px;
  font-weight: 500;
}

.cx-df-has-error~.cx-df-error-text,
.cx-df-field.is-invalid .cx-df-error-text {
  display: block;
}

.cx-df-textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.5;
}

/* Phone input with dynamic country indicator */
.cx-df-phone-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.cx-df-phone-prefix {
  position: absolute;
  left: 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--cx-df-text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  user-select: none;
}

.cx-df-phone-input {
  padding-left: 64px;
}

/* Google reCAPTCHA-style Widget ("Check if you are human") */
.cx-df-captcha-box {
  background: #f9f9f9;
  border: 1px solid #d3d3d3;
  border-radius: 4px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  user-select: none;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 4px;
}

[data-mode="dark"] .cx-df-captcha-box {
  background: #1e1e22;
  border-color: #3f3f46;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cx-df-captcha-box:hover {
  border-color: #b0b0b0;
}

.cx-df-captcha-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cx-df-captcha-checkbox {
  width: 26px;
  height: 26px;
  border: 2px solid #c1c1c1;
  border-radius: 3px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  position: relative;
  flex-shrink: 0;
}

[data-mode="dark"] .cx-df-captcha-checkbox {
  background: #27272a;
  border-color: #52525b;
}

.cx-df-captcha-box:hover .cx-df-captcha-checkbox {
  border-color: #888;
}

/* Spinning circle loader */
.cx-df-captcha-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid #e2e8f0;
  border-top-color: var(--cx-df-primary);
  border-radius: 50%;
  animation: cxDfSpin 0.75s linear infinite;
  display: none;
}

@keyframes cxDfSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Verified state */
.cx-df-captcha-box.is-verified .cx-df-captcha-checkbox {
  border-color: var(--cx-df-success);
  background: var(--cx-df-success);
}

.cx-df-captcha-tick {
  color: #fff;
  display: none;
}

.cx-df-captcha-tick svg {
  width: 16px;
  height: 16px;
  stroke-width: 3.5;
}

.cx-df-captcha-box.is-verified .cx-df-captcha-tick {
  display: block;
}

.cx-df-captcha-box.is-verifying .cx-df-captcha-spinner {
  display: block;
}

.cx-df-captcha-label {
  font-size: 13.5px;
  font-weight: 500;
  color: #1f2937;
  line-height: 1.2;
}

[data-mode="dark"] .cx-df-captcha-label {
  color: #e4e4e7;
}

.cx-df-captcha-right {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0.8;
  padding-left: 8px;
}

.cx-df-captcha-shield {
  width: 22px;
  height: 22px;
  color: #64748b;
}

.cx-df-captcha-brand {
  font-size: 9.5px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: -0.01em;
}

.cx-df-captcha-terms {
  font-size: 8px;
  color: #94a3b8;
  text-decoration: none;
}

/* Submit CTA Button */
.cx-df-btn-submit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 12px 24px;
  border-radius: 12px;
  background: var(--cx-df-primary);
  color: #ffffff;
  border: none;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 10px 24px -10px rgba(var(--cx-df-primary-rgb), 0.9);
}

.cx-df-btn-submit:hover:not(:disabled) {
  background: var(--cx-df-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -10px rgba(var(--cx-df-primary-rgb), 1);
}

.cx-df-btn-submit:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.cx-df-btn-submit svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.cx-df-btn-submit:hover svg {
  transform: translateX(3px);
}

.cx-df-note {
  font-size: 12px;
  color: var(--cx-df-text-muted);
  text-align: center;
  margin: 4px 0 0 0;
}

/* Thank You Popup Modal */
.cx-df-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cx-df-modal-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.cx-df-modal-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
  transform: scale(0.92);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

[data-mode="dark"] .cx-df-modal-card {
  background: #141414;
  border-color: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.cx-df-modal-backdrop.is-open .cx-df-modal-card {
  transform: scale(1);
}

.cx-df-modal-icon {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.12);
  color: var(--cx-df-success);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  position: relative;
}

.cx-df-modal-icon svg {
  width: 36px;
  height: 36px;
  stroke-width: 3;
}

.cx-df-modal-title {
  font-size: 24px;
  font-weight: 750;
  margin: 0 0 10px 0;
  letter-spacing: -0.02em;
}

.cx-df-modal-desc {
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--cx-df-text-muted);
  margin: 0 0 24px 0;
}

.cx-df-modal-details {
  background: var(--cx-df-card-bg);
  border: 1px solid var(--cx-df-border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 24px;
  text-align: left;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cx-df-modal-details-row {
  display: flex;
  justify-content: space-between;
}

.cx-df-modal-details-row span:first-child {
  color: var(--cx-df-text-muted);
}

.cx-df-modal-details-row span:last-child {
  font-weight: 600;
}

.cx-df-modal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 24px;
  border-radius: 12px;
  background: #09090b;
  color: #fff;
  border: none;
  font-size: 14.5px;
  font-weight: 650;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

[data-mode="dark"] .cx-df-modal-btn {
  background: #ffffff;
  color: #000000;
}

.cx-df-modal-btn:hover {
  opacity: 0.9;
}