/* ===================================
   FORMS - Base Form Element Styles
   ===================================
   
   Default styling for native HTML form elements.
   These are the defaults BEFORE atom classes are applied.
*/

/* Base input styling - Layer 4 (White surface) */
input, textarea, select {
  font-family: var(--font-family-sans);
  font-size: var(--text-sm);
  color: var(--text-body);                  /* Body text color */
  background-color: var(--bg-surface);      /* #ffffff - Top layer */
  border: var(--border-width-1) solid var(--border-default);
  border-radius: var(--border-radius-md);
  padding: var(--space-2) var(--space-3);
  transition: all var(--duration-200) var(--easing-out);
  width: 100%;
}

/* Focus state - consistent across all form elements */
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

/* Disabled state */
input:disabled, textarea:disabled, select:disabled {
  background-color: var(--bg-panel);        /* Panel color for disabled */
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.7;
}

/* Read-only state */
input:read-only, textarea:read-only {
  background-color: var(--bg-panel);        /* Panel color for readonly */
  cursor: default;
}

/* Placeholder styling */
input::placeholder, textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* Override browser autofill styling (blue/yellow background) */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-surface) inset;
  -webkit-text-fill-color: var(--text-body);
  transition: background-color 5000s ease-in-out 0s;
}

/* Base button styling */
button {
  font-family: var(--font-family-sans);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  transition: all var(--duration-200) var(--easing-out);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* Label styling */
label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  margin-bottom: 0;
}

/* Fieldset and legend */
fieldset {
  border: var(--border-width-1) solid var(--border-default);
  border-radius: var(--border-radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

legend {
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  padding: 0 var(--space-2);
}

/* Select dropdown arrow */
select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-2) center;
  background-size: var(--icon-size-sm);
  padding-right: var(--space-6);
  cursor: pointer;
}

/* Textarea specific */
textarea {
  resize: vertical;
  min-height: var(--space-20);
  line-height: var(--line-height-relaxed);
}

/* Checkbox and radio base */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  cursor: pointer;
  accent-color: var(--color-primary-600);
}

/* File input */
input[type="file"] {
  padding: var(--space-2);
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  padding: var(--space-1_5) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-primary);
  background-color: var(--bg-surface);
  border: var(--border-width-1) solid var(--border-default);
  border-radius: var(--border-radius-md);
  margin-right: var(--space-3);
  cursor: pointer;
  transition: all var(--duration-200) var(--easing-out);
}

input[type="file"]::file-selector-button:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-strong);
}

/* Range slider base */
input[type="range"] {
  padding: 0;
  height: var(--space-6);
  background: transparent;
  accent-color: var(--color-primary-600);
}

/* Color input */
input[type="color"] {
  padding: var(--space-1);
  height: var(--space-10);
  cursor: pointer;
}

/* Search inputs use type="text" (SearchInput atom) -- no browser search quirks to suppress */

/* Number input - hide spinners (will be custom in atom) */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

/* Form validation states - DISABLED
   Automatic :valid/:invalid borders were too aggressive.
   Validation styling should be applied explicitly via classes when needed.
*/

/* Focus ring - consistent across all interactive elements */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: var(--border-width-2) solid var(--border-focus);
  outline-offset: var(--border-width-2);
}
