/* ==========================================================================
   FORM STYLES
   ========================================================================== */

/* Form Container */
.contact-form,
form {
  width: 100%;
  max-width: 100%;
}

/* Form Rows for Layout */
.form-row {
  display: flex;
  gap: 1rem;
  /* margin-bottom: 1rem; */
}

.form-row .form-field {
  flex: 1;
}

/* Form Fields */
.form-field {
  margin-bottom: 1rem;
}

.form-field:last-child {
  margin-bottom: 0;
}

/* Labels */
.form-field label,
.form-field legend {
  display: block;
  /* font-weight: 500; */
  margin-bottom: 0.25rem;
  color: var(--color-text);
  /* font-size: 0.875rem; */
  /* line-height: 1.25; */
}

.form-field legend {
  /* font-size: 1rem; */
  padding: 0;
  margin-bottom: 1rem;
}

/* Input Elements */
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="url"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="time"],
.form-field input[type="datetime-local"],
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--form-color-border);
  border-radius: 0.125rem;
  font-size: 1rem;
  line-height: 1.5;
  background-color: var(--form-color-bg);
  color: var(--form-color-text);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

/* Focus States */
.form-field input[type="text"]:focus,
.form-field input[type="email"]:focus,
.form-field input[type="tel"]:focus,
.form-field input[type="url"]:focus,
.form-field input[type="password"]:focus,
.form-field input[type="number"]:focus,
.form-field input[type="date"]:focus,
.form-field input[type="time"]:focus,
.form-field input[type="datetime-local"]:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--form-color-active-border);
  background-color: var(--form-color-active-bg);
  /* box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1); */
}

/* Textarea Specific */
.form-field textarea {
  resize: vertical;
  min-height: 6rem;
}

/* Select Specific */
.form-field select {
  background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 4 5"><path fill="%23666" d="M2 0L0 2h4zm0 5L0 3h4z"/></svg>');
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 0.65rem auto;
  padding-right: 2.5rem;
  appearance: none;
}

/* Fieldset and Checkbox Groups */
/* .form-field fieldset {
  border: 1px solid var(--color-border, #d1d5db);
  border-radius: 0.375rem;
  padding: 1rem;
  margin: 0;
} */

.form-field fieldset {
  border: none;
  padding: 0;
}

.form-field fieldset label {
  display: flex;
  align-items: center;
  margin-bottom: 0.25rem;
  font-weight: 400;
  cursor: pointer;
}

.form-field fieldset label:last-child {
  margin-bottom: 0;
}

/* Checkboxes and Radio Buttons */
.form-field input[type="checkbox"],
.form-field input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin-right: 0.5rem;
  margin-top: 0;
  flex-shrink: 0;
  cursor: pointer;
  
  /* Custom checkbox styling */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  
  background-color: var(--form-color-checkbox);
  border: 2px solid var(--form-color-checkbox-border);
  border-radius: 0.25rem;
  position: relative;
  transition: all 0.15s ease-in-out;
}

/* Radio buttons get rounded corners */
.form-field input[type="radio"] {
  border-radius: 50%;
}

/* Hover state */
.form-field input[type="checkbox"]:hover,
.form-field input[type="radio"]:hover {
  border-color: var(--form-color-hover-checkbox);
}

/* Focus state */
.form-field input[type="checkbox"]:focus,
.form-field input[type="radio"]:focus {
  outline: none;
  border-color: var(--form-color-hover-checkbox);
  /* box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1); */
}

/* Checked state */
.form-field input[type="checkbox"]:checked,
.form-field input[type="radio"]:checked {
  background-color: var(--form-color-active-checkbox);
  border-color: var(--form-color-active-checkbox);
}

/* Checkmark for checkboxes */
.form-field input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0.375rem;
  height: 0.625rem;
  border: 2px solid white;
  border-top: none;
  border-left: none;
  transform: translate(-50%, -60%) rotate(45deg);
}

/* Dot for radio buttons */
.form-field input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0.375rem;
  height: 0.375rem;
  background-color: white;
  border-radius: 50%;
}

/* Disabled state */
.form-field input[type="checkbox"]:disabled,
.form-field input[type="radio"]:disabled {
  background-color: var(--form-color-disabled-checkbox);
  border-color: var(--form-color-disabled-checkbox);
  cursor: not-allowed;
  opacity: 0.6;
}

.form-field input[type="checkbox"]:disabled:checked,
.form-field input[type="radio"]:disabled:checked {
  background-color: var(--form-color-disabled-checkbox);
}

/* Error States */
.form-field.error input,
.form-field.error select,
.form-field.error textarea {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-field .error-message {
  background-color: var(--form-color-message-error-bg);
  color: var(--form-color-message-error-text);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Success States */
.form-field.success input,
.form-field.success select,
.form-field.success textarea {
  border-color: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Disabled States */
.form-field input:disabled,
.form-field select:disabled,
.form-field textarea:disabled {
  background-color: var(--form-color-disabled-bg);
  color: var(--form-color-disabled-bg);
  cursor: not-allowed;
  opacity: 0.6;
}

/* Form Actions */
.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2rem;
}

/* Buttons */
.form-actions button[type="submit"],
.form-actions .submit-button,
button.submit {
  background-color: var(--form-color-button-bg);
  color: var(--form-color-button-text);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.125rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
}

.form-actions button[type="submit"]:hover,
.form-actions .submit-button:hover,
button.submit:hover {
  background-color: var(--form-color-button-hover-bg);
  color: var(--form-color-button-hover-text);
  transform: translateY(-1px);
}

.form-actions button[type="submit"]:active,
.form-actions .submit-button:active,
button.submit:active {
  transform: translateY(0);
}

.form-actions button:disabled,
button.submit:disabled {
  background-color: var(--form-color-button-disabled);
  cursor: not-allowed;
  transform: none;
}

/* Secondary Buttons */
.form-actions .secondary-button,
button.secondary {
  background-color: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border, #d1d5db);
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
}

.form-actions .secondary-button:hover,
button.secondary:hover {
  background-color: var(--color-hover-bg, #f9fafb);
  border-color: var(--color-primary, #7c3aed);
}

/* Loading Spinner */
.spinner {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.spinner-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background-color: var(--color-primary, #7c3aed);
  animation: spinner-bounce 1.4s ease-in-out infinite both;
}

.spinner-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.spinner-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes spinner-bounce {
  0%, 80%, 100% {
    transform: scale(0);
  }
  40% {
    transform: scale(1);
  }
}

/* Form Messages */
.form-message {
  padding: 1rem;
  border-radius: 0.375rem;
  margin: 1rem 0;
  font-weight: 500;
}

.form-message.success {
  background-color: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.form-message.error {
  background-color: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.form-message.info {
  background-color: #dbeafe;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

/* Utility Classes */
.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }
  
  .form-row .form-field {
    margin-bottom: 1.5rem;
  }
  
  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  
  .form-actions button,
  .form-actions .submit-button,
  .form-actions .secondary-button {
    width: 100%;
    justify-content: center;
  }
}

/* Dark Mode Support */
/* :global([data-theme="dark"]) .form-field input,
:global([data-theme="dark"]) .form-field select,
:global([data-theme="dark"]) .form-field textarea {
  background-color: var(--color-input-bg-dark, #374151);
  color: var(--color-input-text-dark, #f9fafb);
  border-color: var(--color-border-dark, #4b5563);
}

:global([data-theme="dark"]) .form-field fieldset {
  border-color: var(--color-border-dark, #4b5563);
}

:global([data-theme="dark"]) .form-message.success {
  background-color: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

:global([data-theme="dark"]) .form-message.error {
  background-color: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

:global([data-theme="dark"]) .form-message.info {
  background-color: rgba(59, 130, 246, 0.1);
  color: #3b82f6;
  border-color: rgba(59, 130, 246, 0.3);
} */

/* Form Validation Enhancement */
/* .form-field input:valid {
  border-color: var(--color-success, #10b981);
} */

/* .form-field input:invalid:not(:focus):not(:placeholder-shown) {
  border-color: var(--color-error, #ef4444);
} */

/* Placeholder Styling */
.form-field input::placeholder,
.form-field textarea::placeholder {
  color: var(--color-placeholder, #9ca3af);
  opacity: 1;
}

:global([data-theme="dark"]) .form-field input::placeholder,
:global([data-theme="dark"]) .form-field textarea::placeholder {
  color: var(--color-placeholder-dark, #6b7280);
}