/* ── Design Tokens — Dark Corporate / Government-grade ──
   Prefixed --auth-* to avoid colliding with the generic --bg/--text/
   --text-muted/--border aliases branding-theme.php defines on :root for
   the dashboard theme — that stylesheet loads after this one, so an
   unprefixed same-named custom property here would silently lose. ── */
:root {
  --auth-bg:      #0D0F0F;
  --card:         #151616;
  --input-bg:     #1A1B1B;
  --otp-bg:       #111212;
  --auth-text:       #F2F0EC;
  --auth-text-muted: #96928C;
  --gold:         #B58A55;
  --gold-dark:    #8C673E;
  --auth-border:  rgba(181,138,85,0.30);
  --border-soft:  rgba(255,255,255,0.10);
  --danger-bg:    rgba(125,32,32,0.18);
  --danger-border:rgba(190,60,60,0.45);
  --danger-text:  #E7B4B4;
  --shadow-lg:    0 20px 50px rgba(0,0,0,0.28);
  --radius-xl:    18px;
  --font:         'Cairo', system-ui, sans-serif;
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--auth-text);
  -webkit-font-smoothing: antialiased;
}

/* ── Background ──
   Grid (content row + footer row) instead of flex+justify-center: pins
   the footer to a fixed spot at the bottom instead of only appearing
   after the centered block scrolls into view — nothing here hides
   overflow, the row sizes are just smaller now (see .auth-card etc.
   below) so the real content fits inside a normal viewport. ── */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: var(--auth-bg);
}

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 16px;
}

.auth-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.auth-bg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  pointer-events: none;
  z-index: 0;
}

.auth-shell > .auth-main,
.auth-shell > .auth-footer { position: relative; z-index: 1; }

.d-none { display: none !important; }

/* ── Brand row ── */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  margin-bottom: 10px;
}
.auth-brand-logo {
  width: 175px;
  max-width: 60vw;
  height: auto;
  display: block;
}
.auth-brand-tagline {
  font-size: 15px;
  font-weight: 600;
  color: var(--auth-text-muted);
}

.auth-card {
  width: min(540px, calc(100% - 32px));
  max-width: 540px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--auth-border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

/* ── Header ── */
.auth-head {
  padding: 34px 32px 0;
  text-align: center;
}

.auth-icon-box {
  width: 46px; height: 46px;
  border-radius: 11px;
  background: var(--input-bg);
  border: 1px solid var(--auth-border);
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  color: var(--gold);
}

.auth-head h1 {
  margin: 0 0 4px;
  font-size: 27px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--auth-text);
}

.auth-head p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--auth-text-muted);
}

/* ── Body ── */
.auth-body { padding: 0 32px 32px; }

/* ── Field label ── */
.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--auth-text-muted);
  margin-bottom: 5px;
}

/* ── Input field ── */
.field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 47px;
  background: var(--input-bg);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  font-size: 15px;
  color: var(--auth-text);
  transition: border-color .15s ease, box-shadow .15s ease;
  margin-bottom: 11px;
}

/* Kill Chrome/Edge's blue-on-white autofill background — the browser
   paints it straight into the input's own layer, so a plain background
   rule can't override it; the box-shadow inset trick is the only
   reliable fix (transition delays it past the tab's active lifetime). */
.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus,
.field input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--auth-text);
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg) inset;
  box-shadow: 0 0 0 1000px var(--input-bg) inset;
  caret-color: var(--auth-text);
  transition: background-color 600000s ease-in-out 0s;
}

.field:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(181,138,85,0.08);
}

.field .fi {
  color: var(--gold);
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  display: inline-flex;
}

.icon-svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
.icon-flip { transform: scaleX(-1); }

.auth-center { text-align: center; }

.auth-body-simple { padding-top: 20px; }

.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: inherit;
  font-size: 15px;
  font-family: inherit;
  min-width: 0;
  height: 100%;
}

.field input::placeholder { color: var(--auth-text-muted); }

.field-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border: none;
  background: transparent;
  color: var(--auth-text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: color .15s ease, background .15s ease;
}
.field-toggle:hover { color: var(--gold); background: rgba(255,255,255,0.04); }
.field-toggle:focus-visible { outline: 1.5px solid var(--gold); outline-offset: 1px; }

/* ── Row ── */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.field-label-row { margin-bottom: 8px; }
.field-label-row .field-label { margin-bottom: 0; }

/* ── Custom checkbox (remember me) ── */
.check-wrap {
  display: flex;
  align-items: center;
  min-height: 30px;
  gap: 9px;
  cursor: pointer;
  user-select: none;
  font-size: 14px;
  color: var(--auth-text-muted);
  margin: 4px 0 10px;
}
.check-box {
  width: 20px; height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.18);
  background: var(--input-bg);
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: background .15s ease, border-color .15s ease;
}
.check-box svg { opacity: 0; transition: opacity .12s ease; }
.check-box.on {
  background: var(--gold);
  border-color: var(--gold);
}
.check-box.on svg { opacity: 1; }

/* ── Switch toggle (remember device) ── */
.switch-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
  color: var(--auth-text-muted);
  margin-bottom: 14px;
}

.switch {
  position: relative;
  width: 38px; height: 22px;
  background: var(--input-bg);
  border-radius: 999px;
  flex-shrink: 0;
  transition: background .15s ease;
  border: 1px solid rgba(255,255,255,0.14);
  cursor: pointer;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 16px; height: 16px;
  background: #F2F0EC;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
  transition: transform .15s ease;
}

.switch.on { background: var(--gold); border-color: var(--gold); }
.switch.on::after { transform: translateX(16px); background: #101111; }
[dir="rtl"] .switch.on::after { transform: translateX(-16px); }

.switch input { display: none; }

/* ── Forgot link ── */
.forgot-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--gold);
  text-decoration: none;
  transition: color .15s ease;
}
.forgot-link:hover { color: #cfa878; text-decoration: underline; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 11px;
  border: 1px solid var(--border-soft);
  background: var(--input-bg);
  color: var(--auth-text);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, transform .08s ease;
  text-decoration: none;
}

.btn:hover { background: #202121; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #101111;
  font-weight: 700;
}
.btn-primary:hover { background: #a67c4c; border-color: #a67c4c; }

.btn-block { width: 100%; height: 49px; border-radius: 10px; font-size: 16px; margin-top: 4px; }

.btn-label { display: inline-flex; align-items: center; gap: 8px; }

.btn-spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(16,17,17,0.3);
  border-top-color: #101111;
  animation: btn-spin .7s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* ── Error alert ── */
.auth-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 13px;
  font-weight: 500;
}
.auth-error .icon-svg { color: #d98686; flex-shrink: 0; }

/* ── Help line ── */
.auth-help {
  text-align: center;
  margin-top: 8px;
  font-size: 13px;
  color: var(--auth-text-muted);
}
.auth-help a,
.auth-help-static { font-weight: 700; margin-inline-start: 4px; color: var(--gold); }
.auth-help-static { color: var(--auth-text); }

/* ── Divider ── */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
  color: var(--auth-text-muted);
  font-size: 12.5px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* ── Footer (page-level, not inside card) ──
   min-height ~40px keeps it a compact single row (~36-42px rendered);
   its own grid row on .auth-shell keeps it pinned at the bottom and
   always visible, never pushed off-screen by card content above it. ── */
.auth-footer {
  width: 100%;
  max-width: 900px;
  min-height: 40px;
  margin: 0 auto;
  border-top: 1px solid var(--border-soft);
  padding: 8px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 11.5px;
  color: var(--auth-text-muted);
}
.auth-footer-links { display: flex; align-items: center; gap: 14px; }
.auth-footer-links a { color: var(--auth-text-muted); text-decoration: none; }
.auth-footer-links a:hover { color: var(--gold); }
.auth-footer-copy { flex: 1; text-align: center; }
.auth-footer-brand { font-weight: 700; color: var(--gold); white-space: nowrap; }

/* Base sizing already targets a compact card, so 1366x768 and up fit
   with no scroll — .auth-shell's overflow-y: auto stays as the
   fallback for genuinely short viewports, not a mask. This block trims
   a bit further for short desktop/laptop windows (matches the
   1366x768-class breakpoint explicitly). */
@media (max-height: 800px) and (min-width: 769px) {
  .auth-main { padding: 4px 16px; }
  .auth-brand { margin-bottom: 8px; }
  .auth-brand-logo { width: 140px; }
  .auth-brand-tagline { font-size: 13px; }
  .auth-card { width: 520px; max-width: 520px; }
  .auth-head { padding: 18px 24px 0; }
  .auth-icon-box { width: 44px; height: 44px; margin-bottom: 8px; }
  .auth-head h1 { font-size: 25px; margin-bottom: 3px; }
  .auth-head p { margin-bottom: 12px; }
  .auth-body { padding: 0 24px 18px; }
  .field-label { margin-bottom: 4px; }
  .field { height: 44px; margin-bottom: 9px; }
  .check-wrap { min-height: 26px; margin: 2px 0 8px; }
  .btn-block { height: 46px; margin-top: 2px; }
  .auth-divider { margin: 8px 0; }
  .auth-help { margin-top: 6px; }
}
@media (max-height: 560px) {
  .auth-brand,
  .auth-footer { display: none; }
}

@media (max-width: 640px) {
  .auth-footer { justify-content: center; text-align: center; }
  .auth-footer-copy { order: 3; flex-basis: 100%; }
}
@media (max-width: 460px) {
  .auth-head { padding: 18px 20px 0; }
  .auth-body { padding: 0 20px 22px; }
}
