/**
 * ARLaang Technologies — Unified Form Design System
 * 
 * Standardized, accessible, responsive form tokens, layouts and controls.
 * Preserves the ARLaang comic-book aesthetic: 2px ink borders, offset shadows,
 * Bangers display headings, Instrument Sans body, and high-contrast focus rings.
 */

/* ==========================================================================
   1. Form Layout Architecture
   ========================================================================== */

.f-grid,
form.f-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  box-sizing: border-box;
}

.f-row,
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  width: 100%;
  box-sizing: border-box;
}

.f-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  width: 100%;
  box-sizing: border-box;
}

.f-group,
.form-group,
.f-field,
.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  box-sizing: border-box;
}

.f-col-full,
.f-wide,
.form-wide {
  grid-column: 1 / -1;
  width: 100%;
}

/* ==========================================================================
   2. Labels & Help Typography
   ========================================================================== */

.f-label,
.form-label,
.f-group > label,
form.comic-form > label {
  display: block;
  font-family: var(--body, 'Instrument Sans', sans-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--ink, #1B0F3A);
  line-height: 1.35;
  margin: 0;
  cursor: pointer;
}

.f-label .req,
.form-label .req,
.req,
.required-star {
  color: #E02424;
  font-weight: 800;
  margin-left: 2px;
}

.f-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  width: 100%;
  gap: 12px;
}

.f-help,
.form-help,
.help-text {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--mut, #5E5680);
  line-height: 1.4;
  margin-top: 2px;
}

.f-error,
.form-error,
.error-feedback {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #E02424;
  line-height: 1.4;
  margin-top: 2px;
}

/* ==========================================================================
   3. Base Inputs, Selects & Textareas
   ========================================================================== */

.f-input,
.f-select,
.f-textarea,
.f-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.f-group select,
.f-group textarea,
.card form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.card form select,
.card form textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--body, 'Instrument Sans', sans-serif);
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink, #1B0F3A);
  background-color: var(--paper, #FBF9FF);
  border: 2px solid var(--ink, #1B0F3A);
  border-radius: 12px;
  box-shadow: 2px 2px 0 var(--ink, #1B0F3A);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, outline 0.15s ease, background-color 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.f-input,
.f-select,
.f-group input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.f-group select,
.card form input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="hidden"]),
.card form select {
  height: 48px;
  padding: 10px 16px;
  line-height: 1.5;
}

.f-input::placeholder,
.f-textarea::placeholder,
.f-group input::placeholder,
.f-group textarea::placeholder {
  color: var(--mut, #5E5680);
  opacity: 0.75;
}

/* Hover & Focus Interaction */
.f-input:hover,
.f-select:hover,
.f-textarea:hover,
.f-group input:hover,
.f-group select:hover,
.f-group textarea:hover {
  border-color: var(--ink, #1B0F3A);
  box-shadow: 3px 3px 0 var(--ink, #1B0F3A);
}

.f-input:focus,
.f-select:focus,
.f-textarea:focus,
.f-group input:focus,
.f-group select:focus,
.f-group textarea:focus {
  outline: 3px solid var(--v, #8C52FF);
  outline-offset: 2px;
  border-color: var(--v, #8C52FF);
  box-shadow: 3px 3px 0 var(--ink, #1B0F3A);
  background-color: #FFFFFF;
}

/* Disabled State */
.f-input:disabled,
.f-select:disabled,
.f-textarea:disabled {
  opacity: 0.6;
  background-color: var(--bg, #F7F4FF);
  cursor: not-allowed;
  box-shadow: none;
}

/* Textarea Specifics */
.f-textarea,
.f-group textarea,
.card form textarea {
  min-height: 130px;
  padding: 14px 16px;
  line-height: 1.6;
  resize: vertical;
}

/* Select Specifics with Custom Accessible Chevron */
.f-select,
.f-group select,
.card form select {
  padding-right: 42px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%231B0F3A' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px 16px;
}

/* ==========================================================================
   4. Validation & Error States
   ========================================================================== */

.f-input.has-error,
.f-select.has-error,
.f-textarea.has-error,
.f-input[aria-invalid="true"],
.f-select[aria-invalid="true"],
.f-textarea[aria-invalid="true"],
.has-error .f-input,
.has-error .f-select,
.has-error .f-textarea {
  border-color: #E02424 !important;
  box-shadow: 2px 2px 0 #E02424 !important;
  background-color: #FFF9F9;
}

.f-input.has-error:focus,
.f-select.has-error:focus,
.f-textarea.has-error:focus,
.f-input[aria-invalid="true"]:focus,
.f-select[aria-invalid="true"]:focus,
.f-textarea[aria-invalid="true"]:focus {
  outline-color: #E02424 !important;
  border-color: #E02424 !important;
}

/* ==========================================================================
   5. Checkboxes & Radios
   ========================================================================== */

.f-checkbox,
.f-radio,
.chk,
label.f-checkbox,
label.f-radio {
  display: inline-flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-family: var(--body, 'Instrument Sans', sans-serif);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink, #1B0F3A);
  line-height: 1.45;
  user-select: none;
}

.f-checkbox input[type="checkbox"],
.chk input[type="checkbox"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 2px;
  accent-color: var(--v, #8C52FF);
  border: 2px solid var(--ink, #1B0F3A);
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none;
}

.f-radio input[type="radio"] {
  width: 20px;
  height: 20px;
  min-width: 20px;
  margin-top: 2px;
  accent-color: var(--v, #8C52FF);
  cursor: pointer;
  box-shadow: none;
}

/* ==========================================================================
   6. File Upload Styling
   ========================================================================== */

.f-file,
.f-group input[type="file"],
.card form input[type="file"] {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font-family: var(--body, 'Instrument Sans', sans-serif);
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink, #1B0F3A);
  background: var(--tint, #E9DEFF);
  border: 2px dashed var(--ink, #1B0F3A);
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink, #1B0F3A);
  transition: all 0.15s ease;
}

.f-file:hover,
.f-group input[type="file"]:hover {
  background: #E0D0FF;
  border-color: var(--v, #8C52FF);
}

.f-file::file-selector-button,
.f-group input[type="file"]::file-selector-button {
  padding: 8px 16px;
  background: var(--ink, #1B0F3A);
  color: #FFFFFF;
  border: 2px solid var(--ink, #1B0F3A);
  border-radius: 8px;
  font-family: var(--body, 'Instrument Sans', sans-serif);
  font-weight: 700;
  font-size: 0.85rem;
  margin-right: 14px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.f-file::file-selector-button:hover,
.f-group input[type="file"]::file-selector-button:hover {
  background: var(--v, #8C52FF);
  border-color: var(--v, #8C52FF);
}

/* ==========================================================================
   7. Password Field with Visibility Toggle
   ========================================================================== */

.password-input-wrap {
  position: relative;
  width: 100%;
}

.password-input-wrap .f-input,
.password-input-wrap input {
  padding-right: 48px !important;
  width: 100%;
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--mut, #5E5680);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.password-toggle-btn:hover {
  color: var(--ink, #1B0F3A);
  background-color: rgba(27, 15, 58, 0.06);
}

/* ==========================================================================
   8. Form Actions & Button Layout
   ========================================================================== */

.f-actions,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  margin-top: 8px;
  width: 100%;
  box-sizing: border-box;
}

.f-actions.start {
  justify-content: flex-start;
}

.f-actions.between {
  justify-content: space-between;
}

.f-actions.full > * {
  width: 100%;
}

/* ==========================================================================
   9. Responsive Breakpoints
   ========================================================================== */

@media (max-width: 768px) {
  .f-row,
  .form-row,
  .f-row-3 {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .f-actions {
    flex-direction: column;
    width: 100%;
  }

  .f-actions > * {
    width: 100%;
    text-align: center;
  }
}

