/* Global Form Styles - Bulletproof Input Styling */
/* Covers ALL input types with proper visibility on any background */

/* ============================================
   CSS Variables for Forms
   ============================================ */
:root {
  --input-border-width: 2px;
  --input-border-color: #cbd5e0;
  --input-border-focus: #4299e1;
  --input-bg: #ffffff;
  --input-shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.24);
  --input-shadow-focus: 0 0 0 3px rgba(66, 153, 225, 0.15);
  --input-radius: 0.375rem;
  --input-padding: 0.625rem 0.875rem;
  --input-font-size: 1rem;
  --input-line-height: 1.5;
  --input-transition: all 0.15s ease-in-out;
}

/* ============================================
   Base Input Styles - ALL TEXT-LIKE INPUTS
   ============================================ */

/* Comprehensive list of ALL text input types */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="week"],
input[type="time"],
input[type="color"],
input:not([type]), /* Catches inputs without type */
textarea,
select {
  /* Sizing */
  width: 100%;
  padding: var(--input-padding);
  line-height: var(--input-line-height);
  font-family: inherit;

  /* Visible shadow for contrast; border/radius/font-size and appearance are
     left to the browser's native rendering by design — looks better than a
     custom-styled border/radius across engines and avoids fighting native
     <select> chrome (arrow, height) entirely. */
  background-color: var(--input-bg);
  box-shadow: var(--input-shadow);

  /* Transitions */
  transition: var(--input-transition);

  /* Text color */
  color: #2d3748;
}

/* Placeholder styling */
input::placeholder,
textarea::placeholder {
  color: #a0aec0;
  opacity: 1; /* Firefox fix */
}

/* ============================================
   Focus States
   ============================================ */

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="time"]:focus,
input:not([type]):focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--input-border-focus);
  box-shadow: var(--input-shadow), var(--input-shadow-focus);
  background-color: var(--input-bg);
}

/* Focus-visible for keyboard navigation */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--input-border-focus);
  outline-offset: 2px;
}

/* ============================================
   Disabled State
   ============================================ */

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #f7fafc;
}

/* ============================================
   Validation States
   ============================================ */

/* Valid state */
input:valid:not(:placeholder-shown):not([type="checkbox"]):not([type="radio"]) {
  border-color: #48bb78;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2348bb78'%3E%3Cpath fill-rule='evenodd' d='M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* Invalid state */
input:invalid:not(:placeholder-shown):not([type="checkbox"]):not([type="radio"]) {
  border-color: #f56565;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23f56565'%3E%3Cpath fill-rule='evenodd' d='M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7 4a1 1 0 11-2 0 1 1 0 012 0zm-1-9a1 1 0 00-1 1v4a1 1 0 102 0V6a1 1 0 00-1-1z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
  padding-right: 2.5rem;
}

/* ============================================
   Textarea Specific
   ============================================ */

textarea {
  min-height: 100px;
  resize: vertical;
}

/* ============================================
   Select Specific
   ============================================ */

/* Native appearance kept — the browser draws its own dropdown arrow, so no
   custom background-image arrow is added here (that previously produced a
   double arrow once native appearance was restored). */
select {
  cursor: pointer;
}

/* ============================================
   Search Input Specific
   ============================================ */

input[type="search"] {
  padding-left: 2.5rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23a0aec0'%3E%3Cpath fill-rule='evenodd' d='M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center;
  background-size: 1.25rem;
}

/* Clear button in search */
input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

/* ============================================
   Number Input Specific
   ============================================ */

input[type="number"] {
  -moz-appearance: textfield; /* Firefox */
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* ============================================
   File Input
   ============================================ */

input[type="file"] {
  padding: 0.375rem;
  font-size: 0.875rem;
}

input[type="file"]::file-selector-button {
  padding: 0.375rem 0.75rem;
  margin-right: 0.75rem;
  background: #edf2f7;
  border: 1px solid #cbd5e0;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: var(--input-transition);
}

input[type="file"]::file-selector-button:hover {
  background: #e2e8f0;
}

/* ============================================
   Checkbox & Radio - SEPARATE STYLING
   ============================================ */

input[type="checkbox"],
input[type="radio"] {
  /* Reset width from global */
  width: auto;
  
  /* Custom appearance */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  
  /* Sizing */
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  
  /* Styling */
  border: 2px solid var(--input-border-color);
  background: var(--input-bg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  
  /* Positioning */
  display: inline-grid;
  place-content: center;
  margin: 0 0.5rem 0 0;
  vertical-align: middle;
  
  /* Transitions */
  transition: var(--input-transition);
  cursor: pointer;
}

/* Radio specific */
input[type="radio"] {
  border-radius: 50%;
}

/* Checkbox specific */
input[type="checkbox"] {
  border-radius: 0.25rem;
}

/* Checked state - Checkbox */
input[type="checkbox"]:checked {
  background-color: var(--input-border-focus);
  border-color: var(--input-border-focus);
}

input[type="checkbox"]:checked::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
  background: white;
}

/* Checked state - Radio */
input[type="radio"]:checked {
  background-color: var(--input-border-focus);
  border-color: var(--input-border-focus);
}

input[type="radio"]:checked::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: white;
}

/* Focus state for checkbox/radio */
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.15);
}

/* Label alignment for checkbox/radio */
label:has(input[type="checkbox"]),
label:has(input[type="radio"]) {
  display: flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

/* ============================================
   Range Input
   ============================================ */

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.5rem;
  background: #e2e8f0;
  border-radius: 0.25rem;
  outline: none;
  padding: 0;
  border: none;
  box-shadow: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--input-border-focus);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: var(--input-transition);
}

input[type="range"]::-moz-range-thumb {
  width: 1.5rem;
  height: 1.5rem;
  background: var(--input-border-focus);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: var(--input-transition);
  border: none;
}

input[type="range"]:hover::-webkit-slider-thumb {
  transform: scale(1.1);
}

input[type="range"]:hover::-moz-range-thumb {
  transform: scale(1.1);
}

/* ============================================
   Color Input
   ============================================ */

input[type="color"] {
  height: 2.5rem;
  padding: 0.25rem;
  cursor: pointer;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 0.25rem;
}

/* ============================================
   Form Groups & Labels
   ============================================ */

.form-group {
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: #4a5568;
}

/* Required indicator */
label.required::after {
  content: " *";
  color: #f56565;
}

/* Help text */
.form-help {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #718096;
}

/* Error message */
.form-error {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #f56565;
}

/* ============================================
   HubSpot Form Overrides
   ============================================ */

/* Ensure HubSpot forms use our styles */
.hs-form input[type="text"],
.hs-form input[type="email"],
.hs-form input[type="password"],
.hs-form input[type="tel"],
.hs-form input[type="url"],
.hs-form input[type="search"],
.hs-form input[type="number"],
.hs-form input[type="date"],
.hs-form textarea,
.hs-form select {
  border: var(--input-border-width) solid var(--input-border-color) !important;
  box-shadow: var(--input-shadow) !important;
  background-color: var(--input-bg) !important;
}

/* Dark mode for forms lives in css/dark.css (gated by the theme setting). */

/* ============================================
   Testing on Different Backgrounds
   ============================================ */

/* Ensure visibility on colored backgrounds */
.bg-primary input,
.bg-dark input,
.bg-gradient input {
  border-color: rgba(255, 255, 255, 0.5);
  background-color: rgba(255, 255, 255, 0.95);
}

.bg-primary input:focus,
.bg-dark input:focus,
.bg-gradient input:focus {
  background-color: #ffffff;
  border-color: #ffffff;
}