/**
 * ArgenTous — Forms Stylesheet (05-forms.css)
 * Extends main.css with form-specific components.
 *
 * Includes:
 *  - agt-form: base form layout
 *  - agt-field: labeled field wrapper with error states
 *  - agt-input: text/tel/email/select inputs
 *  - agt-input--otp: large 6-digit OTP field
 *  - agt-input-group: icon prefix / toggle suffix
 *  - agt-select: styled native select
 *  - agt-password-strength: bar meter
 *  - agt-otp-timer: countdown display
 *  - agt-otp-resend: resend button block
 *  - agt-info-text: helper paragraph
 *
 * Mobile-first, desktop is source of truth.
 *
 * @package ArgenTous
 * @version 2.0.0
 */

/* ── Form layout ─────────────────────────────────────────────────────────── */
.agt-form {
  display: flex;
  flex-direction: column;
  gap: var(--agt-space-5);
}

.agt-form__footer {
  text-align: center;
  font-size: var(--agt-text-sm);
  color: var(--agt-gray-500);
  margin: 0;
}

/* ── Field wrapper ───────────────────────────────────────────────────────── */
.agt-field {
  display: flex;
  flex-direction: column;
  gap: var(--agt-space-1);
}

.agt-field--error .agt-input,
.agt-field--error .agt-select {
  border-color: var(--agt-danger);
  background-color: var(--agt-danger-light);
}

.agt-field--error .agt-input:focus,
.agt-field--error .agt-select:focus {
  box-shadow: 0 0 0 3px rgba(220, 38, 38, .15);
}

/* OTP field centre-aligns its input */
.agt-field--otp {
  align-items: center;
}
.agt-field--otp .agt-label { width: 100%; text-align: center; }
.agt-field--otp .agt-field__hint { text-align: center; }

/* ── Label ────────────────────────────────────────────────────────────────── */
.agt-label {
  font-size: var(--agt-text-sm);
  font-weight: 600;
  color: var(--agt-gray-700);
  line-height: 1.4;
}

.agt-required {
  color: var(--agt-danger);
  margin-left: 2px;
}

/* ── Base input / select ─────────────────────────────────────────────────── */
.agt-input,
.agt-select {
  width: 100%;
  padding: 11px 14px;
  font-size: var(--agt-text-base);
  font-family: var(--agt-font-sans);
  color: var(--agt-gray-900);
  background: var(--agt-white);
  border: 1.5px solid var(--agt-gray-300);
  border-radius: var(--agt-radius-sm);
  transition: border-color var(--agt-transition), box-shadow var(--agt-transition);
  -webkit-appearance: none;
  appearance: none;
  line-height: 1.4;
}

.agt-input::placeholder { color: var(--agt-gray-400); }

.agt-input:focus,
.agt-select:focus {
  outline: none;
  border-color: var(--Agtcla-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}

/* Select arrow */
.agt-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

/* ── OTP input ───────────────────────────────────────────────────────────── */
.agt-input--otp {
  width: 100%;
  max-width: 240px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  font-family: var(--agt-font-mono);
  letter-spacing: 0.35em;
  padding: 16px 12px;
  border: 2px solid var(--agt-gray-300);
  border-radius: var(--agt-radius-md);
  color: var(--agt-gray-900);
  background: var(--agt-white);
  transition: border-color var(--agt-transition), box-shadow var(--agt-transition);
  caret-color: var(--Agtcla-primary);
}

.agt-input--otp:focus {
  outline: none;
  border-color: var(--Agtcla-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .18);
}

.agt-input--otp::placeholder {
  color: var(--agt-gray-300);
  letter-spacing: 0.2em;
}

/* Highlight when filled */
.agt-input--otp:valid:not(:placeholder-shown) {
  border-color: var(--Agtcla-secondary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .15);
}

/* Mobile: slightly smaller OTP font */
@media (max-width: 360px) {
  .agt-input--otp {
    font-size: 24px;
    letter-spacing: 0.25em;
    max-width: 200px;
  }
}

/* ── Input group (icon prefix + toggle suffix) ───────────────────────────── */
.agt-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.agt-input-group .agt-input {
  padding-left: 40px;
}

.agt-input-group__icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  user-select: none;
}

.agt-input-group__toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  color: var(--agt-gray-500);
  transition: color var(--agt-transition);
  line-height: 1;
}
.agt-input-group__toggle:hover { color: var(--agt-gray-800); }

/* ── Field messages ──────────────────────────────────────────────────────── */
.agt-field__error {
  font-size: var(--agt-text-xs);
  color: var(--agt-danger);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 4px;
}

.agt-field__hint {
  font-size: var(--agt-text-xs);
  color: var(--agt-gray-400);
  margin: 0;
  line-height: 1.4;
}

/* ── Password strength meter ─────────────────────────────────────────────── */
.agt-password-strength {
  height: 4px;
  background: var(--agt-gray-100);
  border-radius: var(--agt-radius-full);
  overflow: hidden;
  margin-top: var(--agt-space-1);
}

.agt-password-strength__bar {
  height: 100%;
  width: 0;
  background: var(--agt-danger);
  border-radius: var(--agt-radius-full);
  transition: width 0.3s ease, background-color 0.3s ease;
}

/* ── OTP countdown timer ─────────────────────────────────────────────────── */
.agt-otp-timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--agt-space-2);
  padding: var(--agt-space-3) var(--agt-space-4);
  background: var(--Agtcla-primary-light);
  border-radius: var(--agt-radius-sm);
  margin-bottom: var(--agt-space-5);
  font-size: var(--agt-text-sm);
  color: var(--Agtcla-primary);
}

.agt-otp-timer__label {
  font-weight: 500;
}

.agt-otp-timer__clock {
  font-family: var(--agt-font-mono);
  font-size: 20px;
  font-weight: 800;
  min-width: 52px;
  text-align: center;
  color: var(--Agtcla-primary);
  transition: color 0.3s ease;
}

.agt-otp-timer--warning .agt-otp-timer__clock { color: var(--agt-warning); }
.agt-otp-timer--expired { background: var(--agt-danger-light); }
.agt-otp-timer--expired .agt-otp-timer { color: var(--agt-danger); }

/* ── OTP resend section ──────────────────────────────────────────────────── */
.agt-otp-resend {
  margin-top: var(--agt-space-6);
  text-align: center;
  border-top: 1px solid var(--agt-gray-100);
  padding-top: var(--agt-space-5);
}

.agt-otp-resend__text {
  font-size: var(--agt-text-sm);
  color: var(--agt-gray-500);
  margin: 0 0 var(--agt-space-3);
}

.agt-otp-resend__feedback {
  margin-top: var(--agt-space-2);
  font-size: var(--agt-text-sm);
  min-height: 20px;
  font-weight: 600;
}

.agt-otp-resend__feedback.success { color: var(--agt-success); }
.agt-otp-resend__feedback.error   { color: var(--agt-danger); }

/* ── Info text ───────────────────────────────────────────────────────────── */
.agt-info-text {
  font-size: var(--agt-text-sm);
  color: var(--agt-gray-500);
  background: var(--agt-gray-50);
  border: 1px solid var(--agt-gray-200);
  border-radius: var(--agt-radius-sm);
  padding: var(--agt-space-3) var(--agt-space-4);
  margin: 0;
  line-height: 1.5;
}

/* ── Mobile responsiveness overrides ────────────────────────────────────── */
@media (max-width: 480px) {
  .agt-input,
  .agt-select {
    font-size: 16px; /* prevent iOS zoom on focus */
    padding: 12px;
  }

  .agt-btn {
    min-height: 44px; /* WCAG 2.5.5 touch-target minimum */
  }

  .agt-btn--full {
    padding: 14px;
    font-size: var(--agt-text-base);
  }

  /* Ghost/small buttons must still meet 44px touch target on mobile */
  .agt-btn--ghost,
  .agt-btn--sm {
    min-height: 44px;
    padding-left: var(--agt-space-4);
    padding-right: var(--agt-space-4);
  }

  .agt-otp-timer {
    flex-direction: column;
    gap: var(--agt-space-1);
    padding: var(--agt-space-2) var(--agt-space-3);
  }

  .agt-otp-timer__clock {
    font-size: 24px;
  }

  .agt-card {
    border-radius: var(--agt-radius-md);
  }
}

@media (max-width: 360px) {
  .agt-form { gap: var(--agt-space-4); }
}
