/* ── Login page ─────────────────────────────────────────────── */

body.login-page {
  background: #0c0b14;
  color: #e8e6f0;
  /* Fixed height + auto overflow makes the BODY itself the scroll container,
     overriding the app-wide `html,body{overflow:hidden}` scroll-lock in
     shared.css (which otherwise traps the taller account login off-screen). */
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;      /* Firefox: hide scrollbar, keep scrolling */
  -ms-overflow-style: none;   /* legacy Edge */
  display: flex;
  /* center when the card fits, but stay scrollable when it's taller than the
     screen — align-items:center clips the top and kills scrolling */
  align-items: flex-start;
  justify-content: center;
}

/* Hide the scrollbar visually on the login page (scrolling still works) */
body.login-page::-webkit-scrollbar { width: 0; height: 0; display: none; }

/* Ambient background glow */
.login-backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 110% 65% at 50% -5%, rgba(74,63,168,0.22) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 80% 90%, rgba(201,123,90,0.07) 0%, transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* Neutral splash gate: keeps the form invisible until the page's script has
   checked the session/pairing state, so logged-in users never see a flash of
   the login or onboarding UI before being redirected. */
body.auth-gate-wait .login-outer {
  visibility: hidden;
}

.login-outer {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: auto;          /* vertically centers when short; scroll-safe when tall */
  padding: 32px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ── Card ───────────────────────────────────────────────────── */
.login-card {
  width: 100%;
  background: rgba(18,16,28,0.82);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 28px;
  padding: 36px 28px 32px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04) inset,
    0 32px 64px rgba(0,0,0,0.5),
    0 0 80px rgba(74,63,168,0.08);
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ── Brand ──────────────────────────────────────────────────── */
.login-brand {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.login-title-latin {
  display: block;
  font-size: 38px;
  font-weight: 200;
  letter-spacing: 0.18em;
  color: #f0eeff;
  line-height: 1;
}

.login-title-arabic {
  display: block;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: rgba(160,154,224,0.55);
  font-weight: 300;
  line-height: 1;
  direction: rtl;
}

.login-tagline {
  font-size: 12px;
  color: rgba(255,255,255,0.28);
  letter-spacing: 0.07em;
  margin-top: 2px;
}

.login-welcome {
  font-size: 14px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.03em;
  font-style: italic;
}

/* ── Divider ────────────────────────────────────────────────── */
.login-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08) 30%, rgba(255,255,255,0.08) 70%, transparent);
  margin: -4px 0;
}

/* ── Locale selector ────────────────────────────────────────── */
.locale-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}
.locale-btn {
  flex: 1;
  padding: 9px 4px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
  background: transparent;
  color: rgba(255,255,255,0.35);
  font-size: 12px;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.locale-btn:hover {
  border-color: rgba(255,255,255,0.16);
  color: rgba(255,255,255,0.6);
}
.locale-btn.active {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.07);
  color: #e8e6f0;
  font-weight: 500;
}
.locale-select {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  color: #e8e6f0;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  text-align: center;
}
.locale-select:focus { outline: none; border-color: rgba(160,154,224,0.55); }
.locale-select option { background: #14121f; color: #e8e6f0; }

/* ── Login button ───────────────────────────────────────────── */
.login-btn {
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, #4a3fa8 0%, #6b5fd4 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: opacity 0.18s, transform 0.1s, background 0.25s;
  box-shadow: 0 4px 20px rgba(74,63,168,0.4);
  -webkit-tap-highlight-color: transparent;
}
.login-btn:hover { opacity: 0.92; }
.login-btn:active:not(:disabled) { transform: scale(0.985); }
.login-btn:disabled { opacity: 0.35; cursor: default; }
.login-btn.loading { opacity: 0.6; }

.login-error {
  font-size: 13px;
  color: #e87a7a;
  text-align: center;
  padding: 2px 0;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Footer (outside card) ──────────────────────────────────── */
.login-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.api-status {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: rgba(255,255,255,0.3);
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
  transition: background 0.4s, box-shadow 0.4s;
}
.status-dot.online {
  background: #5ecb8a;
  box-shadow: 0 0 7px rgba(94,203,138,0.6);
}
.status-dot.offline  { background: #e87a7a; }
.status-dot.connecting {
  background: rgba(255,200,100,0.7);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%     { opacity: 0.4; }
}

.login-legal {
  font-size: 11px;
  letter-spacing: 0.04em;
  color: rgba(255,255,255,0.3);
  text-align: center;
}
.login-legal a { color: rgba(160,154,224,0.7); text-decoration: none; }
.login-legal a:hover { text-decoration: underline; }

/* ── Mobile tweaks ──────────────────────────────────────────── */
@media (max-width: 400px) {
  .login-card { padding: 30px 20px 28px; border-radius: 22px; }
  .login-title-latin { font-size: 32px; }
}

/* ── Account auth: inputs, Google, switch (v27) ─────────────── */
.auth-fields { display: flex; flex-direction: column; gap: 14px; }
.auth-field  { display: flex; flex-direction: column; gap: 7px; }

.auth-label {
  font-size: 11px;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,0.3);
  text-transform: lowercase;
}
.auth-input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #f0eeff;
  font-size: 16px;
  letter-spacing: 0.02em;
  padding: 14px 16px;
  transition: border-color 0.18s, background 0.18s;
  -webkit-appearance: none;
  appearance: none;
}
.auth-input::placeholder { color: rgba(255,255,255,0.22); font-size: 14px; }
.auth-input:focus {
  outline: none;
  border-color: rgba(74,63,168,0.55);
  background: rgba(74,63,168,0.07);
}
.auth-hint {
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: rgba(255,255,255,0.28);
  min-height: 13px;
}
.auth-hint.error { color: #e87a7a; }
.auth-hint.ok    { color: #5ecb8a; }

/* Google button */
.google-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 13px 16px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.82);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.google-btn:hover  { background: rgba(255,255,255,0.1); border-color: rgba(255,255,255,0.2); }
.google-btn:active { transform: scale(0.985); }
.google-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* "or" divider */
.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.25);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.auth-or::before, .auth-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
}

/* Switch link (sign in / create one) */
.auth-switch {
  text-align: center;
  font-size: 13px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.02em;
}
.auth-switch a {
  color: #a09ae0;
  text-decoration: none;
  font-weight: 500;
  margin-left: 4px;
}
.auth-switch a:hover { text-decoration: underline; }

.auth-recovery {
  text-align: center;
  font-size: 12.5px;
  margin: -4px 0 4px;
}
.auth-recovery a { color: rgba(160,154,224,0.7); text-decoration: none; }
.auth-recovery a:hover { text-decoration: underline; }

.auth-consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.auth-consent input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: #6b5fd4;
  cursor: pointer;
}
.auth-consent a { color: #a09ae0; text-decoration: none; font-weight: 500; }
.auth-consent a:hover { text-decoration: underline; }

/* ── RTL support ────────────────────────────────────────────── */
html[dir="rtl"] .role-btn { flex-direction: row-reverse; text-align: right; }
html[dir="rtl"] .locale-row { flex-direction: row-reverse; }
html[dir="rtl"] .login-card { direction: rtl; }
html[dir="rtl"] .auth-switch a { margin-left: 0; margin-right: 4px; }
