/* ============================================================================
   css/forms.css — Reusable Form System (v1)
   ----------------------------------------------------------------------------
   Shared baseline for every input / select / textarea / search field in the
   app: Login, Student form, Category form, Settings, and all modal forms.

   Goals:
     - 44px minimum touch target on all interactive form fields (mobile a11y)
     - Consistent spacing, borders, radius, and focus states everywhere
     - Works as a SAFETY NET: it styles bare <input>/<select>/<textarea>
       elements directly (by type), so even markup that forgot to add a
       class (e.g. inline-styled modal inputs) still gets correct sizing.

   Load order: include this file BEFORE css/app.css and css/login.css on
   every page. Page-specific stylesheets intentionally load after this one
   so their .form-control / .input-wrap branding can refine (not fight)
   this baseline.

   IMPORTANT: This file is purely presentational. It does not add, remove,
   or rename any element id/name/attribute used by validation or JS — no
   markup or script changes are required to benefit from it.
   ============================================================================ */

:root {
  --form-field-h:      44px;             /* minimum touch target, all fields */
  --form-radius:       10px;
  --form-border:       #ddd;
  --form-border-focus: var(--app-theme-color, #6C63FF);
  --form-bg:           #fafafa;
  --form-bg-focus:     #ffffff;
  --form-font:         14px;
  --form-gap:          14px;             /* vertical space between fields */
  --form-focus-ring:   rgba(108, 99, 255, .14);
}

/* ── Baseline sizing for every text-like field, select, and textarea ───────
   Covers both classed (.form-control) and un-classed/inline-styled inputs,
   so nothing in the app can fall under the 44px touch-target minimum. ── */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input:not([type]),
select,
textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: var(--form-field-h);
  font-family: inherit;
  font-size: var(--form-font);
  color: #333;
  background: var(--form-bg);
  border: 1.5px solid var(--form-border);
  border-radius: var(--form-radius);
  padding: 10px 14px;
  transition: border-color .18s, box-shadow .18s, background .18s;
}

/* ── One consistent focus state, app-wide ───────────────────────────────── */
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="number"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime-local"]:focus,
input:not([type]):focus,
select:focus,
textarea:focus {
  outline: none;
  background: var(--form-bg-focus);
  border-color: var(--form-border-focus);
  box-shadow: 0 0 0 3px var(--form-focus-ring);
}

/* ── Selects: normalize the native control + room for a custom arrow ──────
   (Skipped automatically wherever a page already supplies its own
   chevron/icon via a wrapping element — this just sets a safe default.) ── */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%23999' d='M3.5 5.5l4.5 4.5 4.5-4.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  cursor: pointer;
}

/* ── Textareas: mobile-friendly height, comfortable line spacing ─────────
   Use `.form-textarea` to opt a textarea into a taller default. ── */
textarea {
  min-height: 88px;
  line-height: 1.5;
  padding: 12px 14px;
  resize: vertical;
}
.form-textarea { min-height: 120px; }

/* ── Search inputs ──────────────────────────────────────────────────────
   `.form-search` lets non-[type=search] elements (e.g. a text input used
   as a search box) opt into the same treatment explicitly. ── */
input[type="search"],
.form-search {
  min-height: var(--form-field-h);
  border-radius: var(--form-radius);
}

/* ── Disabled / readonly state, consistent everywhere ─────────────────── */
input[readonly],
input:disabled,
select:disabled,
textarea:disabled {
  background: #f2f2f2;
  color: #888;
  cursor: not-allowed;
  opacity: 1; /* iOS Safari fades disabled fields by default — keep it readable */
}

/* ── Consistent vertical rhythm between fields ─────────────────────────
   `.form-group` is the Bootstrap-style wrapper used on Student/Category/
   Settings pages; `.field` is the wrapper used on the Login page. Both
   now share the same gap so spacing feels identical across the app. ── */
.form-group,
.field {
  margin-bottom: var(--form-gap);
}
.form-group:last-child,
.field:last-child {
  margin-bottom: 0;
}

/* Reusable field label, shared shape across both wrapper styles above */
.form-control-label,
.field > label {
  display: block;
  margin-bottom: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: #555;
  letter-spacing: .01em;
}

/* ── Checkboxes / radios: comfortably tappable, label included ────────── */
.form-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--form-field-h);
}
.form-check-row input[type="checkbox"],
.form-check-row input[type="radio"] {
  width: 20px;
  height: 20px;
  flex: none;
  min-height: 0;
}

/* ── Buttons that sit alongside form fields (Save/Cancel/Apply etc.) ──── */
.form-btn {
  min-height: var(--form-field-h);
  width: 100%;
  border: none;
  border-radius: var(--form-radius);
  font-weight: 700;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity .18s, transform .15s;
}
.form-btn:active { transform: scale(.98); opacity: .92; }

/* ── Bootstrap .form-control override (Student/Category/Settings forms) ──
   Bootstrap's own .form-control class is used directly in markup on the
   Bootstrap-driven pages (category.html, student.html, student-edit.html);
   the bare input[type] rules above don't match it by selector, so this
   keeps Bootstrap fields visually consistent with the rest of the form
   system. Originally duplicated verbatim in both forms.css and app.css —
   consolidated here as the single source of truth. ── */
.form-control {
  border-radius: var(--form-radius) !important;
  font-size: 14px;
  min-height: var(--form-field-h);
  transition: border-color .18s, box-shadow .18s;
}
.form-control:focus {
  border-color: var(--form-border-focus) !important;
  box-shadow: 0 0 0 2px var(--form-focus-ring) !important;
}

/* ══════════════════════════════════════════════
   LOGIN — field wrapper & icon input
   (moved from css/login.css — duplicate .field-label styling reconciled
   with .form-control-label above; .input-wrap is login's icon-prefixed
   input variant, layered on top of the baseline input styles above)
══════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; font-weight: 600; color: #666; letter-spacing: .01em; }

.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .ico {
  position: absolute; left: 12px;
  width: 16px; height: 16px;
  fill: #ccc; pointer-events: none;
}
.input-wrap input { padding-left: 36px; padding-right: 42px; }
.input-wrap input:focus { box-shadow: 0 0 0 3px rgba(108,99,255,.09); }

.remember-row {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12.5px; color: #666; margin-top: -4px;
}
.remember-row label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.remember-row input[type=checkbox] { accent-color: var(--accent, #6C63FF); width: 15px; height: 15px; }

.pw-strength-row { display: flex; gap: 4px; margin-top: 4px; }
.pw-seg { flex: 1; height: 3px; border-radius: 3px; background: #eee; transition: background .3s; }

/* ── Login/Change-Password modal field (moved from inline <style> in login.html) ── */
.modal-field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.modal-field label { font-size: 11.5px; font-weight: 600; color: #666; }
.modal-field input {
  width: 100%; padding: 10px 12px; border: 1.5px solid #ddd; border-radius: 10px;
  font-size: 14px; font-family: inherit; outline: none;
}
.modal-field input:focus { border-color: var(--accent, #6C63FF); box-shadow: 0 0 0 3px rgba(108,99,255,.09); }

/* ── Filter modal field label (moved from css/app.css) ── */
.filter-modal-label {
  font-weight: 600;
  font-size: 12.5px;
  color: #555;
  margin-bottom: 4px;
}

/* ══════════════════════════════════════════════
   SETTINGS — backend selector radio rows
   (moved from inline <style> in settings.html)
══════════════════════════════════════════════ */
.backend-option {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid #ddd; border-radius: 10px;
  padding: 12px 14px; margin-bottom: 10px; cursor: pointer;
}
.backend-option.selected { border-color: var(--app-theme-color); background: #f7f5fb; }
.backend-option input { accent-color: var(--app-theme-color); }
.backend-option .opt-label { font-weight: 600; font-size: 14px; }
.backend-option .opt-sub { font-size: 12px; color: #999; }
