/* ============================================================
   طبت — Authentication screens (pre-auth · no shell)
   Builds on tokens.css. Single file hosts 7 screens + logout modal,
   switched by [data-screen] on .auth-stage. Brand-only palette.
   Variants: data-variant="basic" | "split" (side illustration).
   Lang: dir flips ar/en. Density: comfy | compact.
   ============================================================ */

html, body { height: 100%; }
body { background: var(--paper); overflow: hidden; }

/* ─── stage / background ─────────────────────────────────── */
.auth-stage {
  position: relative;
  min-height: 100vh; width: 100%;
  display: grid; place-items: center;
  padding: 32px;
  overflow: hidden;
}
.auth-stage::before {
  content: ""; position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(1100px 620px at 82% -8%, var(--tebt-blue-50) 0%, rgba(241,244,251,0) 60%),
    radial-gradient(900px 560px at 10% 108%, var(--tebt-teal-50) 0%, rgba(230,250,248,0) 58%),
    var(--paper-2);
}
/* subtle medical cross lattice (toggleable) */
.auth-stage::after {
  content: ""; position: absolute; inset: 0; z-index: 0; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64' viewBox='0 0 64 64'%3E%3Cg fill='none' stroke='%230038B2' stroke-width='1' stroke-opacity='0.05'%3E%3Cpath d='M30 14h4v6h6v4h-6v6h-4v-6h-6v-4h6z'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 64px 64px;
}
.app.no-bg .auth-stage::after { display: none; }
.app.no-bg .auth-stage::before { background: var(--paper-2); }

/* ─── card ───────────────────────────────────────────────── */
.auth-shell {
  position: relative; z-index: 1;
  width: 100%; max-width: 440px;
  display: flex; flex-direction: column; align-items: stretch;
}
.app[data-variant="split"] .auth-shell {
  max-width: 920px;
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-4);
  overflow: hidden;
}

/* brandmark */
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 26px; }
.auth-logo {
  width: 56px; height: 56px; border-radius: var(--r-lg);
  background: var(--tebt-logo-bg); color: var(--tebt-logo-fg);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; box-shadow: var(--shadow-3);
}
.auth-brand .name { font-size: 22px; font-weight: 700; color: var(--text-primary); letter-spacing: -0.02em; }
.auth-brand .tagline { font-size: 12.5px; color: var(--text-muted); margin-top: -8px; }

/* card body */
.auth-card {
  background: var(--white);
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-2xl);
  box-shadow: var(--shadow-3);
  padding: 32px;
}
.app[data-variant="split"] .auth-card {
  border: 0; border-radius: 0; box-shadow: none; padding: 40px 38px;
  display: flex; flex-direction: column; justify-content: center;
}
.app[data-variant="split"] .auth-brand { align-items: flex-start; margin-bottom: 22px; }
.app[data-density="compact"] .auth-card { padding: 24px; }

.auth-head { text-align: center; margin-bottom: 24px; }
.app[data-variant="split"] .auth-head { text-align: start; }
.auth-head h1 { font-size: 21px; font-weight: 600; color: var(--text-primary); letter-spacing: -0.01em; margin: 0; }
.auth-head p { font-size: 13.5px; color: var(--text-secondary); margin: 8px 0 0; line-height: 1.6; }
.auth-head .mono { font-family: var(--font-en); font-weight: 600; color: var(--text-primary); direction: ltr; unicode-bidi: isolate; }

/* ─── fields ─────────────────────────────────────────────── */
.auth-field { margin-bottom: 16px; }
.auth-field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 7px; }
.auth-input-wrap { position: relative; display: flex; align-items: center; }
.auth-input-wrap > .lead {
  position: absolute; inset-inline-start: 12px; width: 18px; height: 18px;
  color: var(--text-muted); pointer-events: none;
}
.auth-input {
  width: 100%; height: 46px; padding-inline: 40px 14px;
  border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--white); font-family: inherit; font-size: 14px; color: var(--text-primary);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.auth-input:focus { outline: none; border-color: var(--tebt-blue); box-shadow: 0 0 0 3px var(--tebt-blue-50); }
.auth-input::placeholder { color: var(--text-muted); }
.auth-input.is-error { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.app[data-density="compact"] .auth-input { height: 42px; }
/* email/number fields read LTR even in RTL */
.auth-input.ltr { direction: ltr; text-align: start; padding-inline: 40px 44px; }
.auth-pw-toggle {
  position: absolute; inset-inline-end: 8px; width: 32px; height: 32px;
  border: 0; background: transparent; color: var(--text-muted);
  display: flex; align-items: center; justify-content: center; border-radius: var(--r-sm);
}
.auth-pw-toggle:hover { background: var(--bg-page); color: var(--text-secondary); }
.auth-pw-toggle svg { width: 18px; height: 18px; }
.auth-field-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.auth-field-err { display: none; font-size: 11.5px; color: var(--danger); margin-top: 6px; align-items: center; gap: 5px; }
.auth-field.has-error .auth-field-err { display: flex; }

/* row: remember + forgot */
.auth-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; gap: 12px; }
.auth-check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-secondary); user-select: none; }
.auth-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.auth-check .box {
  width: 18px; height: 18px; border-radius: var(--r-sm); border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 120ms ease;
}
.auth-check .box svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.auth-check input:checked + .box { background: var(--tebt-blue); border-color: var(--tebt-blue); }
.auth-check input:checked + .box svg { opacity: 1; }
.auth-check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--tebt-blue-50); }
.auth-link { font-size: 13px; font-weight: 600; color: var(--tebt-blue); text-decoration: none; cursor: pointer; background: none; border: 0; padding: 0; font-family: inherit; }
.auth-link:hover { color: var(--tebt-blue-700); text-decoration: underline; }

/* ─── buttons ────────────────────────────────────────────── */
.auth-btn {
  width: 100%; height: 48px; border: 0; border-radius: var(--r-md);
  background: var(--tebt-blue); color: #fff; font-family: inherit; font-size: 14.5px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  transition: background 130ms ease, transform 80ms ease;
}
.auth-btn:hover { background: var(--tebt-blue-700); }
.auth-btn:active { transform: translateY(1px); }
.auth-btn svg { width: 18px; height: 18px; }
.auth-btn.ghost { background: var(--white); color: var(--text-primary); border: 1px solid var(--border-strong); }
.auth-btn.ghost:hover { background: var(--bg-page); }
.auth-btn:disabled { opacity: 0.55; cursor: default; }
.app[data-density="compact"] .auth-btn { height: 44px; }
.auth-back { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 18px; }

/* ─── divider + sso ──────────────────────────────────────── */
.auth-div { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--text-muted); font-size: 11.5px; font-weight: 600; line-height: 1.6; white-space: nowrap; }
.auth-div::before, .auth-div::after { content: ""; height: 1px; background: var(--border-subtle); flex: 1 1 auto; min-width: 20px; }
.auth-sso { display: flex; gap: 10px; }
.auth-sso button {
  flex: 1; height: 44px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--white); font-family: inherit; font-size: 13px; font-weight: 600; color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.auth-sso button:hover { background: var(--bg-page); border-color: var(--mist); }
.auth-sso svg { width: 17px; height: 17px; }

/* ─── footer ─────────────────────────────────────────────── */
.auth-foot { text-align: center; margin-top: 24px; font-size: 11.5px; color: var(--text-muted); position: relative; z-index: 1; }
.auth-foot a { color: var(--text-muted); text-decoration: none; }
.auth-foot a:hover { color: var(--text-secondary); text-decoration: underline; }
.auth-foot .sep { margin: 0 7px; color: var(--mist); }

/* ─── screens router ─────────────────────────────────────── */
.auth-screen { display: none; }
.auth-stage[data-screen="login"]   .s-login,
.auth-stage[data-screen="forgot"]  .s-forgot,
.auth-stage[data-screen="reset"]   .s-reset,
.auth-stage[data-screen="otp"]     .s-otp,
.auth-stage[data-screen="verify"]  .s-verify { display: block; }

/* ─── OTP boxes ──────────────────────────────────────────── */
.otp-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 8px; direction: ltr; }
.otp-box {
  width: 50px; height: 58px; border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--white); text-align: center; font-family: var(--font-en); font-size: 24px; font-weight: 600;
  color: var(--text-primary); transition: border-color 120ms ease, box-shadow 120ms ease;
}
.otp-box:focus { outline: none; border-color: var(--tebt-blue); box-shadow: 0 0 0 3px var(--tebt-blue-50); }
.otp-box.filled { border-color: var(--tebt-blue); background: var(--tebt-blue-50); }
.app[data-density="compact"] .otp-box { width: 44px; height: 52px; font-size: 21px; }
.otp-resend { text-align: center; font-size: 12.5px; color: var(--text-muted); margin: 16px 0 22px; }
.otp-resend .timer { font-family: var(--font-en); font-weight: 600; color: var(--text-secondary); }

/* ─── password strength ──────────────────────────────────── */
.pw-meter { margin: 4px 0 16px; }
.pw-bars { display: flex; gap: 5px; margin-bottom: 12px; }
.pw-bars span { flex: 1; height: 5px; border-radius: var(--r-full); background: var(--cloud); transition: background 200ms ease; }
.pw-bars[data-score="1"] span:nth-child(-n+1) { background: var(--danger); }
.pw-bars[data-score="2"] span:nth-child(-n+2) { background: #C97A24; }
.pw-bars[data-score="3"] span:nth-child(-n+3) { background: #C9A91F; }
.pw-bars[data-score="4"] span { background: var(--success); }
.pw-reqs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.pw-req { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-muted); transition: color 150ms ease; }
.pw-req .tick {
  width: 16px; height: 16px; border-radius: var(--r-full); background: var(--cloud);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 150ms ease;
}
.pw-req .tick svg { width: 10px; height: 10px; color: var(--white); opacity: 0; }
.pw-req.met { color: var(--success); }
.pw-req.met .tick { background: var(--success); }
.pw-req.met .tick svg { opacity: 1; }

/* ─── verify (email) illustration ────────────────────────── */
.auth-illus { display: flex; justify-content: center; margin-bottom: 22px; }
.auth-illus .disc {
  width: 84px; height: 84px; border-radius: var(--r-full);
  background: var(--tebt-blue-50); color: var(--tebt-blue);
  display: flex; align-items: center; justify-content: center;
}
.auth-illus .disc svg { width: 38px; height: 38px; }

/* ─── inline alert (error states) ────────────────────────── */
.auth-alert {
  display: none; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--r-md); margin-bottom: 20px;
  font-size: 12.5px; line-height: 1.55;
}
.auth-alert.show { display: flex; }
.auth-alert svg { width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px; }
.auth-alert .a-t { font-weight: 700; }
.auth-alert.err { background: var(--danger-bg); color: var(--danger); }
.auth-alert.warn { background: var(--warning-bg); color: var(--warning); }
.auth-alert.info { background: var(--tebt-blue-50); color: var(--tebt-blue); }

/* error-state quick switcher (demo aid) */
.auth-demo-bar {
  position: fixed; inset-block-end: 16px; inset-inline-start: 16px; z-index: 50;
  display: flex; gap: 6px; flex-wrap: wrap; max-width: 320px;
  background: var(--white); border: 1px solid var(--border-subtle); border-radius: var(--r-lg);
  padding: 8px; box-shadow: var(--shadow-3);
}
.auth-demo-bar .lbl { font-family: var(--font-en); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); font-weight: 700; width: 100%; padding: 2px 4px 0; }
.auth-demo-bar button {
  font-family: inherit; font-size: 11px; font-weight: 600; color: var(--text-secondary);
  border: 1px solid var(--border-subtle); background: var(--white); border-radius: var(--r-sm);
  padding: 5px 9px; cursor: pointer;
}
.auth-demo-bar button:hover { background: var(--bg-page); border-color: var(--mist); }
.auth-demo-bar button.active { background: var(--tebt-blue); color: #fff; border-color: var(--tebt-blue); }

/* ─── split-variant illustration panel ──────────────────── */
.auth-aside { display: none; }
.app[data-variant="split"] .auth-aside {
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 40px 38px; color: #fff; position: relative; overflow: hidden;
  background:
    radial-gradient(520px 320px at 80% 0%, rgba(11,206,194,0.30) 0%, rgba(11,206,194,0) 60%),
    linear-gradient(155deg, var(--tebt-blue) 0%, var(--tebt-blue-700) 60%, var(--tebt-logo-bg) 100%);
}
.auth-aside .aside-lattice {
  position: absolute; inset: 0; opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%23ffffff' stroke-width='1' stroke-opacity='0.10'%3E%3Cpath d='M26 12h4v6h6v4h-6v6h-4v-6h-6v-4h6z'/%3E%3C/g%3E%3C/svg%3E");
}
.auth-aside .aside-top { position: relative; z-index: 1; }
.auth-aside .aside-logo {
  width: 46px; height: 46px; border-radius: var(--r-md); background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; backdrop-filter: blur(4px);
}
.auth-aside .aside-body { position: relative; z-index: 1; }
.auth-aside .aside-body h2 { font-size: 26px; font-weight: 600; line-height: 1.35; letter-spacing: -0.01em; margin: 0 0 14px; }
.auth-aside .aside-body p { font-size: 13.5px; line-height: 1.7; color: rgba(255,255,255,0.82); margin: 0; }
.auth-aside .aside-stats { display: flex; gap: 26px; position: relative; z-index: 1; }
.auth-aside .aside-stats .st .n { font-family: var(--font-en); font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.auth-aside .aside-stats .st .l { font-size: 11.5px; color: rgba(255,255,255,0.72); margin-top: 2px; }
@media (max-width: 760px) {
  .app[data-variant="split"] .auth-shell { grid-template-columns: 1fr; max-width: 440px; }
  .app[data-variant="split"] .auth-aside { display: none; }
  .app[data-variant="split"] .auth-card { padding: 32px; }
}

/* ─── modal (logout) ─────────────────────────────────────── */
.auth-modal-scrim {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(15, 21, 48, 0.42); backdrop-filter: blur(2px);
  place-items: center; padding: 24px;
}
.auth-modal-scrim.show { display: grid; }
.auth-modal {
  width: 100%; max-width: 380px; background: var(--white);
  border-radius: var(--r-2xl); box-shadow: var(--shadow-4); padding: 28px; text-align: center;
}
.auth-modal .m-ic {
  width: 56px; height: 56px; border-radius: var(--r-full); margin: 0 auto 16px;
  background: var(--danger-bg); color: var(--danger); display: flex; align-items: center; justify-content: center;
}
.auth-modal .m-ic svg { width: 26px; height: 26px; }
.auth-modal h3 { font-size: 18px; font-weight: 600; color: var(--text-primary); margin: 0 0 8px; }
.auth-modal p { font-size: 13px; color: var(--text-secondary); margin: 0 0 22px; line-height: 1.55; }
.auth-modal .m-actions { display: flex; gap: 10px; }
.auth-modal .m-actions .auth-btn { height: 44px; }
.auth-modal .m-actions .auth-btn.danger { background: var(--danger); }
.auth-modal .m-actions .auth-btn.danger:hover { background: #962929; }

/* trigger to open logout (demo) */
.auth-logout-trigger {
  position: fixed; inset-block-start: 16px; inset-inline-end: 16px; z-index: 50;
  display: flex; align-items: center; gap: 7px;
  background: var(--white); border: 1px solid var(--border-subtle); border-radius: var(--r-full);
  padding: 7px 14px; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-secondary);
  box-shadow: var(--shadow-2); cursor: pointer;
}
.auth-logout-trigger:hover { background: var(--bg-page); }
.auth-logout-trigger svg { width: 15px; height: 15px; }

#tweaks-root { position: fixed; z-index: 200; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
