/* ==========================================================================
   Auth screens (sign in, forgot password, reset password)
   Self-contained: no Bootstrap / jQuery dependency.
   ========================================================================== */

:root {
  --auth-ink: #0f1b33;
  --auth-text: #4d637b;
  --auth-muted: #8592a6;
  --auth-brand: #1260eb;
  --auth-brand-ink: #0b4fcc;
  --auth-brand-soft: #e8f0fe;
  --auth-btn: #1a1a1a;
  --auth-btn-hover: #333333;
  --auth-bg: #ffffff;
  --auth-panel: #f6f8fc;
  --auth-field: #ffffff;
  --auth-border: #d9e0ea;
  --auth-border-strong: #b7c2d3;
  --auth-danger: #c62f3d;
  --auth-danger-soft: #fdecee;
  --auth-success: #127a46;
  --auth-success-soft: #e7f6ee;
  --auth-warning: #9a6200;
  --auth-radius: 12px;
  --auth-radius-sm: 8px;
  --auth-shadow: 0 1px 2px rgba(15, 27, 51, .06), 0 8px 24px rgba(15, 27, 51, .06);
  --auth-font: "Inter Tight", "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body.auth {
  margin: 0;
  background: var(--auth-bg);
  color: var(--auth-text);
  font-family: var(--auth-font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.auth [hidden] { display: none !important; }

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100vh;
}

@media (min-width: 992px) {
  .auth-shell { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
}

/* Single centered card (admin) */
.auth-shell.is-single { grid-template-columns: minmax(0, 1fr); background: var(--auth-panel); }
.auth-shell.is-single .auth-card {
  background: #fff;
  border: 1px solid var(--auth-border);
  border-radius: 16px;
  box-shadow: var(--auth-shadow);
  padding: 32px 24px;
}
@media (min-width: 576px) { .auth-shell.is-single .auth-card { padding: 40px; max-width: 440px; } }
.auth-brand-text { color: var(--auth-ink); font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

/* ----- Left: form column ------------------------------------------------ */

.auth-main {
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
}

@media (min-width: 576px) { .auth-main { padding: 32px 40px; } }

.auth-brand img { max-height: 44px; max-width: 200px; display: block; }

.auth-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
}

.auth-card { width: 100%; max-width: 400px; }

.auth-title {
  margin: 0 0 6px;
  color: var(--auth-ink);
  font-size: 28px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.01em;
}

.auth-sub { margin: 0 0 28px; color: var(--auth-text); }

.auth-icon-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 20px;
  border-radius: 12px;
  background: var(--auth-brand-soft);
  color: var(--auth-brand);
}

.auth-icon-badge svg { width: 24px; height: 24px; }

.auth-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--auth-muted);
}

.auth-secure { display: inline-flex; align-items: center; gap: 6px; }
.auth-secure svg { width: 14px; height: 14px; }

/* ----- Right: brand panel ---------------------------------------------- */

.auth-aside {
  display: none;
  position: relative;
  overflow: hidden;
  background: var(--auth-panel);
  align-items: flex-end;
  justify-content: center;
  padding: 48px 48px 0;
}

@media (min-width: 992px) { .auth-aside { display: flex; } }

.auth-aside img {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
  object-fit: contain;
}

/* ----- Form controls --------------------------------------------------- */

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

.auth-label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}

.auth-label {
  display: block;
  margin-bottom: 6px;
  color: var(--auth-ink);
  font-size: 14px;
  font-weight: 600;
}

.auth-label-row .auth-label { margin-bottom: 0; }

.auth-input-wrap { position: relative; }

.auth-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-sm);
  background: var(--auth-field);
  color: var(--auth-ink);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom */
  transition: border-color .15s, box-shadow .15s;
}

.auth-input::placeholder { color: #a7b1c0; }

.auth-input:hover { border-color: var(--auth-border-strong); }

.auth-input:focus {
  outline: none;
  border-color: var(--auth-brand);
  box-shadow: 0 0 0 3px rgba(18, 96, 235, .18);
}

.auth-input[aria-invalid="true"] { border-color: var(--auth-danger); }
.auth-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(198, 47, 61, .16); }

.auth-input.has-toggle { padding-right: 48px; }

.auth-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: var(--auth-muted);
  cursor: pointer;
  border-radius: 0 var(--auth-radius-sm) var(--auth-radius-sm) 0;
}

.auth-toggle:hover { color: var(--auth-ink); }
.auth-toggle:focus-visible { outline: 2px solid var(--auth-brand); outline-offset: -4px; }
.auth-toggle svg { width: 20px; height: 20px; }

.auth-hint { margin-top: 6px; font-size: 13px; color: var(--auth-muted); }
.auth-hint.is-warning { color: var(--auth-warning); }

.auth-error-text { margin-top: 6px; font-size: 13px; color: var(--auth-danger); }

/* ----- Buttons & links ------------------------------------------------- */

.auth-btn {
  position: relative;
  width: 100%;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: var(--auth-radius-sm);
  background: var(--auth-btn);
  color: #fff;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, box-shadow .15s, opacity .15s;
}

.auth-btn:hover { background: var(--auth-btn-hover); color: #fff; }
.auth-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(26, 26, 26, .3); }
.auth-btn[disabled] { opacity: .65; cursor: not-allowed; }

.auth-btn-secondary {
  background: #fff;
  color: var(--auth-ink);
  border-color: var(--auth-border);
}

.auth-btn-secondary:hover { background: var(--auth-panel); color: var(--auth-ink); }

.auth-btn .auth-spinner { display: none; }
.auth-btn.is-loading .auth-spinner { display: inline-block; }
.auth-btn.is-loading .auth-btn-label { opacity: .85; }

.auth-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .7s linear infinite;
}

@keyframes auth-spin { to { transform: rotate(360deg); } }

.auth-link {
  color: var(--auth-brand);
  font-weight: 600;
  text-decoration: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

.auth-link:hover { text-decoration: underline; color: var(--auth-brand-ink); }
.auth-link:focus-visible { outline: 2px solid var(--auth-brand); outline-offset: 2px; border-radius: 4px; }
.auth-link[disabled] { color: var(--auth-muted); cursor: default; text-decoration: none; }

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
  font-size: 14px;
}

.auth-back svg { width: 16px; height: 16px; }

.auth-alt { margin-top: 24px; text-align: center; font-size: 14px; }

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

.auth-alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding: 12px 14px;
  border-radius: var(--auth-radius-sm);
  font-size: 14px;
  line-height: 1.45;
}

.auth-alert svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
.auth-alert-error { background: var(--auth-danger-soft); color: #8f1d29; }
.auth-alert-success { background: var(--auth-success-soft); color: #0d5a34; }
.auth-alert a { color: inherit; font-weight: 600; }

/* ----- Divider & social ------------------------------------------------ */

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--auth-muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--auth-border);
}

.auth-google { display: flex; justify-content: center; min-height: 44px; }

/* ----- Identity chip (shown after step 1) ------------------------------ */

.auth-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
  padding: 10px 12px;
  border: 1px solid var(--auth-border);
  border-radius: 999px;
  background: var(--auth-panel);
}

.auth-chip-avatar {
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--auth-brand);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-transform: uppercase;
}

.auth-chip-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--auth-ink);
  font-weight: 600;
}

/* ----- OTP boxes ------------------------------------------------------- */

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

.auth-otp input {
  width: 100%;
  height: 54px;
  padding: 0;
  border: 1px solid var(--auth-border);
  border-radius: var(--auth-radius-sm);
  background: var(--auth-field);
  color: var(--auth-ink);
  text-align: center;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  transition: border-color .15s, box-shadow .15s;
}

.auth-otp input:focus {
  outline: none;
  border-color: var(--auth-brand);
  box-shadow: 0 0 0 3px rgba(18, 96, 235, .18);
}

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

.auth-otp-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--auth-muted);
}

/* ----- Password strength ---------------------------------------------- */

.auth-meter {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 10px;
}

.auth-meter span {
  height: 4px;
  border-radius: 2px;
  background: var(--auth-border);
  transition: background-color .2s;
}

.auth-meter[data-score="1"] span:nth-child(-n+1) { background: var(--auth-danger); }
.auth-meter[data-score="2"] span:nth-child(-n+2) { background: #e08a00; }
.auth-meter[data-score="3"] span:nth-child(-n+3) { background: #2b8a3e; }
.auth-meter[data-score="4"] span { background: var(--auth-success); }

.auth-meter-label { margin-top: 6px; font-size: 13px; color: var(--auth-muted); }

.auth-rules {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 12px;
  font-size: 13px;
  color: var(--auth-muted);
}

.auth-rules li { display: flex; align-items: center; gap: 6px; }

.auth-rules li::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--auth-border-strong);
}

.auth-rules li.is-met { color: var(--auth-success); }

.auth-rules li.is-met::before {
  border-color: var(--auth-success);
  background: var(--auth-success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5'%3E%3Cpath d='M4 8.5l2.5 2.5L12 5.5'/%3E%3C/svg%3E") center / 10px no-repeat;
}

/* ----- Step transitions ------------------------------------------------ */

.auth-step { animation: auth-in .22s ease-out; }

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

@media (prefers-reduced-motion: reduce) {
  .auth-step, .auth-spinner { animation: none; }
  .auth-input, .auth-btn, .auth-otp input { transition: none; }
}

.auth-sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
