/**
 * Styled Form Component CSS
 *
 * Uses CSS variables from FormStyle model:
 * - --form-primary-color
 * - --form-background-color
 * - --form-text-color
 * - --form-font-family
 * - --form-border-radius
 */

.styled-form {
  background-color: var(--form-background-color, #ffffff);
  color: var(--form-text-color, #1a1a1a);
  font-family: var(--form-font-family, Inter), system-ui, sans-serif;
  padding: 1.5rem;
  border-bottom-left-radius: var(--form-border-radius, 4px);
  border-bottom-right-radius: var(--form-border-radius, 4px);
  border-top: none;
  border-bottom: 1px solid #e5e7eb;
  border-left: 1px solid #e5e7eb;
  border-right: 1px solid #e5e7eb;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
  max-width: 42rem;
  margin: 0 auto;
}

/* Remove borders and shadow when using Tailwind overrides (e.g., in preview) */
.styled-form.border-0 {
  border: none;
}

.styled-form.shadow-none {
  box-shadow: none;
}

/* Form header */
.styled-form-header h1 {
  color: var(--form-text-color, #1a1a1a);
}

.styled-form-header p {
  color: var(--form-text-color, #1a1a1a);
}

/* Input base styles */
.styled-form input:not([type="checkbox"]):not([type="radio"]),
.styled-form select,
.styled-form textarea {
  border-radius: var(--form-border-radius, 4px);
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5rem;
  color: var(--form-text-color, #1a1a1a);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Boxed input style (default) */
.styled-form[data-input-style="boxed"] input:not([type="checkbox"]):not([type="radio"]),
.styled-form[data-input-style="boxed"] select,
.styled-form[data-input-style="boxed"] textarea {
  border: 1px solid #9ca3af;
  background-color: #ffffff;
}

.styled-form[data-input-style="boxed"] input:not([type="checkbox"]):not([type="radio"]):hover,
.styled-form[data-input-style="boxed"] select:hover,
.styled-form[data-input-style="boxed"] textarea:hover {
  border-color: #6b7280;
}

/* Underlined input style */
.styled-form[data-input-style="underlined"] input:not([type="checkbox"]):not([type="radio"]),
.styled-form[data-input-style="underlined"] select,
.styled-form[data-input-style="underlined"] textarea {
  border: none;
  border-bottom: 1px solid #d1d5db;
  border-radius: 0;
  background-color: transparent;
  padding-left: 0;
  padding-right: 0;
}

.styled-form[data-input-style="underlined"] input:not([type="checkbox"]):not([type="radio"]):hover,
.styled-form[data-input-style="underlined"] select:hover,
.styled-form[data-input-style="underlined"] textarea:hover {
  border-bottom-color: #9ca3af;
}

/* Focus states with primary color */
.styled-form input:not([type="checkbox"]):not([type="radio"]):focus,
.styled-form select:focus,
.styled-form textarea:focus {
  outline: none;
  border-color: var(--form-primary-color, #0058ff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--form-primary-color, #0058ff) 20%, transparent);
}

.styled-form[data-input-style="underlined"] input:not([type="checkbox"]):not([type="radio"]):focus,
.styled-form[data-input-style="underlined"] select:focus,
.styled-form[data-input-style="underlined"] textarea:focus {
  box-shadow: none;
  border-bottom-color: var(--form-primary-color, #0058ff);
  border-bottom-width: 2px;
}

/* Phone input wrapper - unified styling for country code + phone number */
.styled-form .phone-input-wrapper {
  border: 1px solid #9ca3af;
  border-radius: var(--form-border-radius, 4px);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.styled-form .phone-input-wrapper:hover {
  border-color: #6b7280;
}

.styled-form .phone-input-wrapper:focus-within {
  border-color: var(--form-primary-color, #0058ff);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--form-primary-color, #0058ff) 20%, transparent);
}

/* Phone input field inside wrapper - remove default input styling */
.styled-form .phone-input-wrapper .phone-input-field {
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}

.styled-form .phone-input-wrapper .phone-input-field:focus {
  border: none !important;
  box-shadow: none !important;
}

/* Underlined style for phone input */
.styled-form[data-input-style="underlined"] .phone-input-wrapper {
  border: none;
  border-bottom: 1px solid #d1d5db;
  border-radius: 0;
}

.styled-form[data-input-style="underlined"] .phone-input-wrapper:hover {
  border-bottom-color: #9ca3af;
}

.styled-form[data-input-style="underlined"] .phone-input-wrapper:focus-within {
  box-shadow: none;
  border-bottom-color: var(--form-primary-color, #0058ff);
  border-bottom-width: 2px;
}

/* Checkbox and radio styling */
.styled-form input[type="checkbox"],
.styled-form input[type="radio"] {
  accent-color: var(--form-primary-color, #0058ff);
}

/* Labels */
.styled-form label {
  color: var(--form-text-color, #1a1a1a);
}

/* Submit button */
.styled-form-submit {
  background-color: var(--form-primary-color, #0058ff);
  color: #ffffff;
  padding: 0.75rem 2rem;
  border-radius: var(--form-border-radius, 4px);
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s ease-in-out, transform 0.1s ease-in-out;
}

.styled-form-submit:hover {
  opacity: 0.9;
}

.styled-form-submit:active {
  transform: scale(0.98);
}

.styled-form-submit:focus {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--form-primary-color, #0058ff) 30%, transparent);
}

.styled-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Error messages */
.styled-form-errors {
  color: #b91c1c;
}

/* Terms and conditions */
.styled-form-terms {
  background-color: color-mix(in srgb, var(--form-background-color, #ffffff) 95%, #000000);
  border-radius: var(--form-border-radius, 4px);
}

/* Banner */
.styled-form-banner {
  aspect-ratio: 1242 / 568;
  box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.styled-form-banner.shadow-none {
  box-shadow: none;
}

.styled-form-banner img {
  border-top-left-radius: var(--form-border-radius, 4px);
  border-top-right-radius: var(--form-border-radius, 4px);
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Hidden field (conditional visibility) */
.styled-form [data-hidden="true"] {
  display: none;
}

/* Preview mode - transparent background, non-interactive */
.styled-form--preview {
  background-color: transparent !important;
  box-shadow: none !important;
  pointer-events: none;
  user-select: none;
}