/* ==========================================================================
   Al Afifah — Authentication pages (login / register / forgot / reset)
   --------------------------------------------------------------------------
   Deliberately self-contained. These pages do NOT reuse the template's
   `.contact-form` wrapper, because style.css sets
   `.contact-form input { color: white }` which renders typed text invisible
   on a light background. Every rule here is namespaced under `auth-`.
   ========================================================================== */

:root {
  --auth-navy: #263866;
  --auth-navy-dark: #1b2a4e;
  --auth-navy-soft: #eef1f8;
  --auth-accent: #ffd500;
  --auth-text: #1a2233;
  --auth-muted: #6b7793;
  --auth-line: #d8dfec;
  --auth-danger: #d64545;
  --auth-danger-bg: #fdf2f2;
  --auth-success: #1e8e5a;
  --auth-success-bg: #eefaf4;
  --auth-info: #2b6cb0;
  --auth-info-bg: #eef5fd;
  --auth-radius: 16px;
  --auth-radius-sm: 10px;
  --auth-shadow: 0 18px 50px -22px rgba(20, 32, 66, 0.45);
}

/* --------------------------------------------------------------- Layout -- */

.auth-page {
  background:
    radial-gradient(1100px 520px at 12% -10%, #33477d 0%, transparent 60%),
    radial-gradient(900px 480px at 100% 0%, #1d2c55 0%, transparent 55%),
    linear-gradient(160deg, #263866 0%, #1b2a4e 100%);
  min-height: 78vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 64px 16px 72px;
  position: relative;
  overflow: hidden;
}

/* Subtle diagonal texture so the panel does not read as a flat block. */
.auth-page::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(
    115deg,
    rgba(255, 255, 255, 0.05) 0 1px,
    transparent 1px 14px
  );
  pointer-events: none;
}

.auth-shell {
  width: 100%;
  max-width: 470px;
  position: relative;
  z-index: 1;
}

/* Register needs two columns on desktop, so it gets a roomier shell. */
.auth-shell--wide {
  max-width: 620px;
}

.auth-card {
  background: #fff;
  border-radius: var(--auth-radius);
  box-shadow: var(--auth-shadow);
  padding: 40px 40px 32px;
}

/* ----------------------------------------------------------------- Head -- */

.auth-head {
  text-align: center;
  margin-bottom: 28px;
}

.auth-logo {
  display: inline-block;
  margin-bottom: 20px;
}

.auth-logo img {
  height: 46px;
  width: auto;
}

.auth-title {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--auth-navy);
  margin: 0 0 8px;
}

.auth-subtitle {
  font-size: 15px;
  line-height: 1.55;
  color: var(--auth-muted);
  margin: 0;
}

/* --------------------------------------------------------------- Alerts -- */

.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-radius: var(--auth-radius-sm);
  padding: 14px 16px;
  margin-bottom: 22px;
  font-size: 14.5px;
  line-height: 1.5;
  border: 1px solid transparent;
  animation: authAlertIn 0.28s ease-out both;
}

.auth-alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 1px;
}

.auth-alert__body {
  flex: 1;
  min-width: 0;
}

.auth-alert__title {
  font-weight: 600;
  display: block;
  margin-bottom: 2px;
}

.auth-alert--error {
  background: var(--auth-danger-bg);
  border-color: #f5c6c6;
  color: #8f2b2b;
}
.auth-alert--error .auth-alert__icon { color: var(--auth-danger); }

.auth-alert--success {
  background: var(--auth-success-bg);
  border-color: #b7e6cf;
  color: #14603c;
}
.auth-alert--success .auth-alert__icon { color: var(--auth-success); }

.auth-alert--info {
  background: var(--auth-info-bg);
  border-color: #c3dcf7;
  color: #1f4f80;
}
.auth-alert--info .auth-alert__icon { color: var(--auth-info); }

@keyframes authAlertIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- Fields -- */

.auth-form {
  margin: 0;
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 18px;
}

.auth-field--full {
  grid-column: 1 / -1;
}

.auth-field {
  margin-bottom: 18px;
  min-width: 0;
}

.auth-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--auth-navy);
  margin-bottom: 7px;
}

.auth-label .auth-req {
  color: var(--auth-danger);
  margin-left: 2px;
}

.auth-control {
  position: relative;
}

/* `color` is forced because style.css:4410 paints template inputs white.
   Without this the field looks empty while the user types. */
.auth-form .auth-input {
  width: 100%;
  display: block;
  height: 50px;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--auth-text) !important;
  background: #fbfcfe;
  border: 1.5px solid var(--auth-line);
  border-radius: var(--auth-radius-sm);
  outline: none;
  box-shadow: none;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

.auth-form .auth-input::placeholder {
  color: #a3adc2;
  opacity: 1;
}

.auth-form .auth-input:hover {
  border-color: #c0cadd;
}

.auth-form .auth-input:focus {
  border-color: var(--auth-navy);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(38, 56, 102, 0.12);
}

/* Chrome autofill also repaints text — pin it back to the readable colour. */
.auth-form .auth-input:-webkit-autofill,
.auth-form .auth-input:-webkit-autofill:hover,
.auth-form .auth-input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--auth-text);
  -webkit-box-shadow: 0 0 0 1000px #fbfcfe inset;
  caret-color: var(--auth-text);
}

/* Leave room for the show/hide button. */
.auth-control--password .auth-input {
  padding-right: 50px;
}

.auth-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--auth-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.auth-toggle:hover {
  color: var(--auth-navy);
  background: var(--auth-navy-soft);
}

.auth-toggle:focus-visible {
  outline: 2px solid var(--auth-navy);
  outline-offset: 1px;
}

.auth-toggle svg {
  width: 20px;
  height: 20px;
  display: block;
  pointer-events: none;
}

/* ------------------------------------------------------- Field messages -- */

.auth-error {
  display: none;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--auth-danger);
  margin: 7px 0 0;
}

.auth-error::before {
  content: "";
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--auth-danger);
  -webkit-mask: no-repeat center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
  mask: no-repeat center / 14px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2a10 10 0 100 20 10 10 0 000-20zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z'/%3E%3C/svg%3E");
}

.auth-field.is-invalid .auth-error {
  display: flex;
}

.auth-field.is-invalid .auth-input {
  border-color: var(--auth-danger);
  background: var(--auth-danger-bg);
}

.auth-field.is-invalid .auth-input:focus {
  box-shadow: 0 0 0 4px rgba(214, 69, 69, 0.14);
}

.auth-field.is-valid .auth-input {
  border-color: #9fd8bd;
}

/* ------------------------------------------------------ Password meter -- */

.auth-meter {
  display: none;
  margin-top: 10px;
}

.auth-meter.is-active {
  display: block;
}

.auth-meter__track {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.auth-meter__seg {
  height: 4px;
  border-radius: 3px;
  background: var(--auth-line);
  transition: background 0.25s;
}

.auth-meter__label {
  font-size: 12.5px;
  color: var(--auth-muted);
  margin: 7px 0 0;
}

.auth-meter[data-score="1"] .auth-meter__seg:nth-child(-n + 1) { background: #e05252; }
.auth-meter[data-score="2"] .auth-meter__seg:nth-child(-n + 2) { background: #e8a33d; }
.auth-meter[data-score="3"] .auth-meter__seg:nth-child(-n + 3) { background: #3fa06b; }
.auth-meter[data-score="4"] .auth-meter__seg { background: #1e8e5a; }

/* ---------------------------------------------------------- Row helpers -- */

.auth-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin: -4px 0 20px;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--auth-muted);
  cursor: pointer;
  user-select: none;
  margin: 0;
}

.auth-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--auth-navy);
  margin: 0;
  cursor: pointer;
}

.auth-link {
  color: var(--auth-navy);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
}

.auth-link:hover {
  color: var(--auth-navy-dark);
  text-decoration: underline;
}

/* -------------------------------------------------------------- Buttons -- */

/* Scoped to `.auth-card` on purpose. style.css:674 styles `button[type=submit]`
   with a blue background and `width:auto`; that selector has specificity
   (0,1,1), so a bare `.auth-btn` (0,1,0) would lose to it no matter what order
   the stylesheets load in. `.auth-card .auth-btn` is (0,2,0) and wins. */
.auth-card .auth-btn {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 24px;
  font-family: inherit;
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: #fff;
  background: var(--auth-navy);
  border: 1.5px solid var(--auth-navy);
  border-radius: var(--auth-radius-sm);
  cursor: pointer;
  transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
  -webkit-appearance: none;
  appearance: none;
}

.auth-card .auth-btn:hover {
  background: var(--auth-navy-dark);
  border-color: var(--auth-navy-dark);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(27, 42, 78, 0.9);
}

.auth-card .auth-btn:active {
  transform: translateY(1px);
}

.auth-card .auth-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.auth-card .auth-btn--ghost {
  color: var(--auth-navy);
  background: #fff;
  border-color: var(--auth-line);
}

.auth-card .auth-btn--ghost:hover {
  background: var(--auth-navy-soft);
  color: var(--auth-navy);
  border-color: #c0cadd;
  box-shadow: none;
}

/* Spinner shown while a form is submitting. */
.auth-btn__spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
}

.auth-btn.is-loading .auth-btn__spinner {
  display: block;
}

@keyframes authSpin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------- Foot -- */

.auth-foot {
  text-align: center;
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--auth-line);
  font-size: 14.5px;
  color: var(--auth-muted);
}

.auth-foot p {
  margin: 0 0 6px;
}

.auth-foot p:last-child {
  margin-bottom: 0;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  transition: color 0.15s;
}

.auth-back:hover {
  color: #fff;
}

/* Centred icon used by the "link sent" / "invalid token" states. */
.auth-state {
  text-align: center;
}

.auth-state__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
}

.auth-state__icon svg {
  width: 30px;
  height: 30px;
}

.auth-state__icon--success {
  background: var(--auth-success-bg);
  color: var(--auth-success);
}

.auth-state__icon--error {
  background: var(--auth-danger-bg);
  color: var(--auth-danger);
}

.auth-state__icon--info {
  background: var(--auth-info-bg);
  color: var(--auth-info);
}

.auth-hint {
  font-size: 13px;
  line-height: 1.5;
  color: var(--auth-muted);
  margin: 7px 0 0;
}

/* ---------------------------------------------------------- Responsive -- */

@media only screen and (max-width: 767px) {
  .auth-page {
    padding: 40px 14px 52px;
    min-height: 0;
  }

  .auth-card {
    padding: 30px 24px 26px;
  }

  .auth-title {
    font-size: 23px;
  }

  .auth-subtitle {
    font-size: 14.5px;
  }

  .auth-logo img {
    height: 40px;
  }
}

/* Single column below the small breakpoint — side-by-side fields become
   unusably narrow on phones. */
@media only screen and (max-width: 575px) {
  .auth-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-page {
    padding: 28px 12px 40px;
  }

  .auth-card {
    padding: 26px 18px 22px;
    border-radius: 14px;
  }

  .auth-title {
    font-size: 21px;
  }

  /* 16px keeps iOS Safari from zooming the viewport on focus. */
  .auth-form .auth-input {
    height: 48px;
    font-size: 16px;
  }

  .auth-card .auth-btn {
    height: 50px;
    font-size: 15px;
  }

  .auth-row-between {
    gap: 8px;
  }
}

@media only screen and (max-width: 360px) {
  .auth-card {
    padding: 22px 14px 20px;
  }

  .auth-row-between {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* Tall-but-narrow phones in landscape shouldn't force a full-height hero. */
@media only screen and (max-height: 620px) and (orientation: landscape) {
  .auth-page {
    min-height: 0;
    padding-top: 32px;
    padding-bottom: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-alert,
  .auth-btn__spinner {
    animation: none;
  }

  .auth-form .auth-input,
  .auth-btn,
  .auth-toggle {
    transition: none;
  }
}

/* --------------------------------------------------------------- Captcha -- */

.auth-captcha {
  display: flex;
  justify-content: center;
}

/* Google renders the checkbox in a fixed 304px iframe that cannot be made
   narrower. On the smallest phones that is wider than the card, so it is
   scaled down rather than left to push a horizontal scrollbar onto the
   whole page. */
@media (max-width: 359px) {
  .auth-captcha {
    transform: scale(0.85);
    transform-origin: center top;
  }
}
