/* Flexi Form Builder - Frontend UI (Light & Minimal) */

.ffb-form {
  --ffb-form-max-width: var(--flexi-form-max-width, 640px);
  --ffb-form-radius: var(--flexi-form-radius, 14px);
  --ffb-form-border-color: var(--flexi-form-border-color, #e5e7eb);
  --ffb-form-bg: var(--flexi-form-bg, #ffffff);
  --ffb-form-padding: var(--flexi-form-padding, 20px);
  --ffb-shadow: var(--flexi-form-shadow, 0 10px 30px rgba(15,23,42,0.06));
  --ffb-gap: var(--flexi-form-gap, 14px);

  max-width: var(--ffb-form-max-width);
  margin: 0 auto 24px;
  border-radius: var(--ffb-form-radius);
  border: 1px solid var(--ffb-form-border-color);
  padding: var(--ffb-form-padding);
  background: var(--ffb-form-bg);
  box-shadow: var(--ffb-shadow);
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  color: #111827;
}

.ffb-form .ffb-fields {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--ffb-gap);
}

/* Field layout */
.ffb-field {
  grid-column: span 12 / span 12;
}

.ffb-span-12 { grid-column: span 12 / span 12; }
.ffb-span-9  { grid-column: span 12 / span 12; }
.ffb-span-8  { grid-column: span 12 / span 12; }
.ffb-span-6  { grid-column: span 12 / span 12; }
.ffb-span-4  { grid-column: span 12 / span 12; }
.ffb-span-3  { grid-column: span 12 / span 12; }

@media (min-width: 640px) {
  .ffb-span-9  { grid-column: span 9 / span 9; }
  .ffb-span-8  { grid-column: span 8 / span 8; }
  .ffb-span-6  { grid-column: span 6 / span 6; }
  .ffb-span-4  { grid-column: span 4 / span 4; }
  .ffb-span-3  { grid-column: span 3 / span 3; }
}

/* Labels */
.ffb-field label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  margin-bottom: 4px;
}

.ffb-req {
  color: #dc2626;
  font-weight: 600;
}

/* Text inputs */
.ffb-form input[type="text"],
.ffb-form input[type="email"],
.ffb-form input[type="tel"],
.ffb-form input[type="number"],
.ffb-form input[type="url"],
.ffb-form input[type="password"],
.ffb-form select,
.ffb-form textarea {
  width: 100%;
  font-size: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  background-color: #f9fafb;
  box-shadow: inset 0 0 0 1px transparent;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background-color 0.16s ease;
  box-sizing: border-box;
}

.ffb-form textarea {
  min-height: 96px;
  resize: vertical;
}

.ffb-form input::placeholder,
.ffb-form textarea::placeholder {
  color: #9ca3af;
}

.ffb-form input:focus,
.ffb-form select:focus,
.ffb-form textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px #2563eb1a;
  background-color: #ffffff;
}

/* Radios & checkboxes */
.ffb-radio,
.ffb-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #374151;
}

.ffb-radio + .ffb-radio {
  margin-top: 4px;
}

.ffb-radio input,
.ffb-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Submit button */
.ffb-submit {
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 999px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
  transition:
    background-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.08s ease;
}

.ffb-submit:hover {
  background: #1d4ed8;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
  transform: translateY(-0.5px);
}

.ffb-submit:active {
  background: #1e40af;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.35);
  transform: translateY(0);
}

.ffb-form.ffb-loading {
  opacity: .7;
  pointer-events: none;
}

/* Messages */
.ffb-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.4;
  display: none;
}

.ffb-message.ok {
  display: block;
  background: #ecfdf3;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.ffb-message.error {
  display: block;
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* Small helpers */
.ffb-form small {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: #6b7280;
}