/* RealRacer.ai v2 form components.
 *
 * Shared defaults for inputs, selects, textareas, checkboxes, chips,
 * drop-zones, and primary/secondary buttons. Assumes /static/tokens.css
 * is loaded — uses v2 palette + type tokens.
 *
 * Load order: AFTER tokens.css (for var() resolution) but BEFORE any
 * per-page <style> block so pages can override when they need to.
 * Pages that need to opt out a specific control should give it a class
 * the rules below don't match (rules are scoped to bare element
 * selectors only — adding `.chrome-x` to a select wins).
 *
 * What this DOESN'T provide:
 *   - File <input type="file"> (browser-default chrome is fine)
 *   - Range / color / time inputs (rare; per-page when used)
 *   - Validation states (red error rings etc — add when there's a
 *     concrete use, not speculative)
 */

/* ── Text-style inputs + select + textarea ─────────────────────── */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
  background: var(--surface-2, #14141c);
  border: 1px solid var(--border, #1c1c28);
  color: var(--text, #f4f4f8);
  font-family: var(--body, 'Inter', 'Barlow', sans-serif);
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 6px;
  outline: none;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  min-height: 38px;
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
select:focus,
textarea:focus {
  border-color: var(--orange, #FF8000);
  background: var(--surface, #0d0d14);
  box-shadow: 0 0 0 1px var(--orange, #FF8000);
}

input::placeholder,
textarea::placeholder {
  color: var(--faint, #5e5e72);
}

input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Numbers — kill the spinner; almost always undesired with custom UI. */
input[type="number"] {
  font-variant-numeric: tabular-nums slashed-zero;
  font-family: var(--mono, 'JetBrains Mono', monospace);
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] { -moz-appearance: textfield; }

/* Select arrow — replace the browser-default with a v2 caret. */
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none'><path d='M1 1l5 5 5-5' stroke='%23a8a8b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 10px;
  padding-right: 32px;
}

/* ── Labels ─────────────────────────────────────────────────────── */
.form-label {
  display: block;
  font-family: var(--mono, monospace);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted, #a8a8b8);
  margin-bottom: 6px;
}

/* ── Checkbox + radio — keep native control, restyle the surround
       with a slight accent-color hint. accent-color is widely supported
       and avoids the hidden-input + sibling-pseudo dance. ───────── */
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--orange, #FF8000);
  width: 16px;
  height: 16px;
  vertical-align: middle;
  cursor: pointer;
}

.form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text, #f4f4f8);
  cursor: pointer;
  user-select: none;
}
.form-check input { margin: 0; }

/* ── Buttons ─────────────────────────────────────────────────────
 * Canonical definitions live in app.css (.btn-v2 + .btn-primary aliases).
 * Keep thin mirrors here for pages that historically only loaded form.css;
 * --accent so lane / circuit theme retints without a second fork. */
.btn-v2 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--body, 'Barlow', sans-serif);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s, border-color 0.15s;
  min-height: 38px;
  text-decoration: none;
}
.btn-v2:disabled {
  opacity: 0.55;
  cursor: wait;
}
.btn-v2.is-primary {
  background: var(--accent, var(--orange, #FF8000));
  color: #0a0a0f;
  border-color: var(--accent, var(--orange, #FF8000));
}
.btn-v2.is-primary:hover:not(:disabled) { filter: brightness(1.1); }
.btn-v2.is-secondary {
  background: transparent;
  color: var(--text, #f4f4f8);
  border-color: var(--border, #1c1c28);
}
.btn-v2.is-secondary:hover:not(:disabled) {
  border-color: var(--muted, #a8a8b8);
  background: var(--surface-2, #14141c);
}
.btn-v2.is-ghost {
  background: var(--surface-2, #14141c);
  color: var(--muted, #a8a8b8);
  border-color: var(--border, #1c1c28);
}
.btn-v2.is-ghost:hover:not(:disabled) {
  color: var(--text, #f4f4f8);
  border-color: var(--muted, #a8a8b8);
}
.btn-v2.is-danger {
  background: transparent;
  color: var(--red, #ff5b5b);
  border-color: var(--red, #ff5b5b);
}
.btn-v2.is-danger:hover:not(:disabled) {
  background: rgba(255, 91, 91, 0.08);
}

/* ── Chip / filter toggle — soft mono (Sessions grammar); solid = .is-solid.
 * app.css is the logged-in source of truth; this mirrors for form-only pages. */
.chip-v2 {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted, #a8a8b8);
  font-family: 'JetBrains Mono', 'DM Mono', monospace;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.chip-v2:hover { color: var(--text, #f4f4f8); border-color: rgba(255, 255, 255, 0.22); }
.chip-v2.is-active,
.chip-v2.active {
  background: rgba(var(--accent-rgb, 255, 128, 0), 0.14);
  border-color: rgba(var(--accent-rgb, 255, 128, 0), 0.45);
  color: var(--accent, var(--orange, #FF8000));
}
.chip-v2.is-solid.is-active,
.chip-v2.is-solid.active {
  background: var(--accent, var(--orange, #FF8000));
  border-color: var(--accent, var(--orange, #FF8000));
  color: #0a0a0f;
}

/* ── Drop-zone ─────────────────────────────────────────────────── */
.drop-zone {
  border: 1.5px dashed var(--border, #1c1c28);
  border-radius: 10px;
  padding: 28px 20px;
  text-align: center;
  color: var(--muted, #a8a8b8);
  background: var(--surface, #0d0d14);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  cursor: pointer;
}
.drop-zone:hover,
.drop-zone.is-dragover {
  border-color: var(--orange, #FF8000);
  background: rgba(255, 128, 0, 0.04);
  color: var(--text, #f4f4f8);
}
.drop-zone .drop-zone-icon {
  width: 32px; height: 32px;
  margin: 0 auto 12px;
  color: var(--faint, #5e5e72);
}
.drop-zone:hover .drop-zone-icon,
.drop-zone.is-dragover .drop-zone-icon {
  color: var(--orange, #FF8000);
}
