/* NIDAL Auth Modernization
   Visual-only layer aligned with the modern homepage.
   Existing routes, form names, validation and JS behavior remain unchanged. */

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

:root {
  --auth-bg: #020607;
  --auth-bg-2: #050b0e;
  --auth-panel: rgba(5, 12, 16, .92);
  --auth-panel-strong: rgba(4, 10, 13, .975);
  --auth-panel-soft: rgba(7, 15, 19, .80);
  --auth-orange: #ff7a12;
  --auth-orange-2: #ff9b2b;
  --auth-orange-soft: rgba(255, 122, 18, .14);
  --auth-teal: #20dfc0;
  --auth-red: #ff5c48;
  --auth-text: #f5f7f8;
  --auth-muted: #a7b0b6;
  --auth-muted-2: #76858d;
  --auth-line: rgba(151, 171, 184, .18);
  --auth-line-strong: rgba(151, 171, 184, .27);
  --auth-shadow: 0 28px 80px rgba(0, 0, 0, .46);
}

html {
  min-height: 100%;
  background: var(--auth-bg);
}

body {
  position: relative !important;
  display: block !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 78% 18%, rgba(10, 85, 105, .09), transparent 26%),
    radial-gradient(circle at 58% 82%, rgba(255, 122, 18, .055), transparent 24%),
    linear-gradient(180deg, #020607 0%, #020709 55%, #010405 100%) !important;
  color: var(--auth-text) !important;
  font-family: 'Inter', Arial, sans-serif !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html[dir="rtl"] body {
  font-family: 'Tajawal', 'Inter', Arial, sans-serif !important;
}

/* Desktop visual half. It intentionally reuses the already-approved homepage hero. */
body::before {
  content: "";
  position: fixed;
  z-index: 0;
  inset: 0 auto 0 0;
  width: 46%;
  background:
    linear-gradient(90deg, rgba(2,6,7,.10), rgba(2,6,7,.24) 58%, #020607 100%),
    linear-gradient(180deg, rgba(2,6,7,.08), rgba(2,6,7,.28)),
    url('/static/img/homepage_hero.png') 63% center / cover no-repeat;
  border-right: 1px solid rgba(151, 171, 184, .11);
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  z-index: 0;
  left: calc(46% - 1px);
  top: 12%;
  bottom: 12%;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255,122,18,.58), transparent);
  box-shadow: 0 0 24px rgba(255,122,18,.12);
  pointer-events: none;
}

html[dir="rtl"] body::before {
  left: auto;
  right: 0;
  background:
    linear-gradient(270deg, rgba(2,6,7,.10), rgba(2,6,7,.24) 58%, #020607 100%),
    linear-gradient(180deg, rgba(2,6,7,.08), rgba(2,6,7,.28)),
    url('/static/img/homepage_hero_ar.png') 37% center / cover no-repeat;
  border-right: 0;
  border-left: 1px solid rgba(151, 171, 184, .11);
}

html[dir="rtl"] body::after {
  left: auto;
  right: calc(46% - 1px);
}

.logo {
  position: fixed !important;
  z-index: 4 !important;
  top: 28px !important;
  left: 30px !important;
  right: auto !important;
  margin: 0 !important;
  width: 178px;
  height: auto;
}

html[dir="rtl"] .logo {
  left: auto !important;
  right: 30px !important;
}

.logo a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  outline: none;
}

.logo img {
  display: block !important;
  width: 178px !important;
  height: auto !important;
  max-width: 100% !important;
  margin: 0 !important;
  object-fit: contain !important;
  filter: drop-shadow(0 8px 22px rgba(0,0,0,.32));
}

.container {
  position: relative !important;
  z-index: 2 !important;
  width: 54% !important;
  max-width: none !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  margin: 0 0 0 46% !important;
  padding: 76px clamp(32px, 5vw, 78px) 54px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  align-items: center !important;
}

html[dir="rtl"] .container {
  margin: 0 46% 0 0 !important;
}

.container > h1,
.card > h1 {
  width: min(100%, 560px);
  margin: 0 0 9px !important;
  color: var(--auth-text) !important;
  font-size: clamp(30px, 3.1vw, 44px) !important;
  line-height: 1.08 !important;
  font-weight: 850 !important;
  letter-spacing: -1.15px !important;
  text-align: left !important;
  text-shadow: none !important;
}

html[dir="rtl"] .container > h1,
html[dir="rtl"] .card > h1 {
  text-align: right !important;
  letter-spacing: 0 !important;
}

.container > h1::before,
.card > h1::before {
  content: "";
  display: block;
  width: 42px;
  height: 3px;
  margin-bottom: 15px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--auth-orange), var(--auth-orange-2));
  box-shadow: 0 0 16px rgba(255,122,18,.22);
}

html[dir="rtl"] .container > h1::before,
html[dir="rtl"] .card > h1::before {
  margin-right: 0;
  margin-left: auto;
}

.container > form,
.container > .card,
.container > .flash,
.container > .error-message {
  width: min(100%, 560px) !important;
}

form,
.card {
  position: relative;
  overflow: hidden;
  max-width: 560px !important;
  width: 100% !important;
  margin: 18px 0 0 !important;
  padding: 30px 32px !important;
  background:
    linear-gradient(180deg, rgba(9,19,24,.94), rgba(4,10,13,.97)) !important;
  border: 1px solid var(--auth-line) !important;
  border-radius: 18px !important;
  box-shadow: var(--auth-shadow) !important;
  backdrop-filter: blur(18px);
}

form::before,
.card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,122,18,.86), transparent);
  opacity: .86;
}

.card > h1 {
  width: 100%;
  font-size: clamp(27px, 2.4vw, 36px) !important;
}

.card > p,
.container > p,
.help,
.hint,
.session-note {
  color: var(--auth-muted) !important;
  text-shadow: none !important;
}

.card > p {
  margin: 7px 0 4px !important;
  line-height: 1.65 !important;
}

label {
  display: block !important;
  margin: 18px 0 7px !important;
  color: #dce2e5 !important;
  font-size: 13px !important;
  line-height: 1.4 !important;
  font-weight: 700 !important;
  letter-spacing: .05px !important;
  text-shadow: none !important;
}

input,
select,
.secret-input {
  width: 100% !important;
  min-height: 46px !important;
  margin-top: 0 !important;
  padding: 11px 13px !important;
  border: 1px solid var(--auth-line-strong) !important;
  border-radius: 10px !important;
  outline: none !important;
  background: rgba(2, 7, 9, .84) !important;
  color: var(--auth-text) !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 1.35 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.015) !important;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease !important;
}

input:hover,
select:hover,
.secret-input:hover {
  border-color: rgba(151,171,184,.38) !important;
}

input:focus,
select:focus,
.secret-input:focus {
  border-color: rgba(255,122,18,.72) !important;
  background: rgba(3,9,12,.96) !important;
  box-shadow: 0 0 0 3px rgba(255,122,18,.09) !important;
}

input::placeholder { color: #65727a !important; }

html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="password"],
html[dir="rtl"] input[name="otp"],
html[dir="rtl"] input[name="totp"],
html[dir="rtl"] input[name="verification_code"],
html[dir="rtl"] input[name="email_code"],
html[dir="rtl"] #manual_key {
  direction: ltr !important;
  text-align: left !important;
  unicode-bidi: isolate !important;
}

button,
button[type="submit"],
.login-button,
.small-btn {
  min-height: 44px !important;
  border: 1px solid rgba(255,122,18,.58) !important;
  border-radius: 10px !important;
  font-family: inherit !important;
  font-size: 13px !important;
  font-weight: 800 !important;
  cursor: pointer !important;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease !important;
}

button[type="submit"],
.login-button {
  width: 100% !important;
  margin-top: 23px !important;
  padding: 11px 20px !important;
  color: #071011 !important;
  background: linear-gradient(135deg, var(--auth-orange), var(--auth-orange-2)) !important;
  box-shadow: 0 11px 26px rgba(255,122,18,.14) !important;
}

button:not([type="submit"]),
.small-btn {
  padding: 9px 15px !important;
  color: #eef2f3 !important;
  background: rgba(7, 15, 18, .96) !important;
  box-shadow: none !important;
}

button:hover:not(:disabled),
.login-button:hover:not(:disabled),
.small-btn:hover:not(:disabled) {
  transform: translateY(-1px) !important;
  border-color: rgba(255,145,54,.78) !important;
  box-shadow: 0 10px 24px rgba(255,122,18,.13) !important;
}

button:disabled {
  opacity: .55 !important;
  cursor: not-allowed !important;
  transform: none !important;
}

a {
  color: #ff9a3c !important;
  text-decoration: none !important;
  font-weight: 650;
}

a:hover { color: #ffb36f !important; }

.row-right,
.row-left {
  margin-top: 8px !important;
  font-size: 12px !important;
}

.row-right { text-align: right !important; }
.row-left { text-align: left !important; }
html[dir="rtl"] .row-left { text-align: left !important; }

.session-note {
  margin-top: 18px !important;
  padding-top: 15px !important;
  border-top: 1px solid rgba(151,171,184,.12) !important;
  font-size: 11px !important;
  line-height: 1.6 !important;
  text-align: center !important;
}

.container > p {
  width: min(100%, 560px);
  margin: 17px 0 0 !important;
  font-size: 13px !important;
  line-height: 1.55 !important;
  text-align: center !important;
}

.error-message,
.flash {
  margin: 14px 0 0 !important;
  padding: 12px 14px !important;
  border-radius: 10px !important;
  border: 1px solid rgba(255,92,72,.36) !important;
  background: rgba(84, 19, 19, .22) !important;
  color: #ff8a7b !important;
  font-size: 13px !important;
  font-weight: 650 !important;
  line-height: 1.5 !important;
  text-align: left !important;
  box-shadow: none !important;
}

html[dir="rtl"] .error-message,
html[dir="rtl"] .flash { text-align: right !important; }

/* Register country input */
.country-wrap { position: relative !important; }
.country-flag {
  position: absolute !important;
  top: 50% !important;
  right: 13px !important;
  transform: translateY(-50%) !important;
  font-size: 18px !important;
  line-height: 1 !important;
  pointer-events: none !important;
}
.country-wrap input { padding-right: 44px !important; }
html[dir="rtl"] .country-flag { right: auto !important; left: 13px !important; }
html[dir="rtl"] .country-wrap input { padding-right: 13px !important; padding-left: 44px !important; }

/* QR / Google Authenticator */
.container > .card { max-width: 650px !important; }

.setup-box {
  margin-top: 22px !important;
  padding: 20px !important;
  border: 1px solid rgba(151,171,184,.15) !important;
  border-radius: 14px !important;
  background: rgba(1,7,9,.58) !important;
  box-shadow: none !important;
}

img.qrcode {
  display: block !important;
  width: 190px !important;
  height: 190px !important;
  max-width: min(100%, 190px) !important;
  margin: 0 auto 16px !important;
  padding: 8px !important;
  border-radius: 14px !important;
  background: #fff !important;
  border: 1px solid rgba(255,122,18,.28) !important;
  box-shadow: 0 18px 42px rgba(0,0,0,.28) !important;
  object-fit: contain !important;
}

.manual-area {
  margin-top: 17px !important;
  padding: 16px !important;
  border-radius: 12px !important;
  border: 1px solid rgba(151,171,184,.13) !important;
  background: rgba(7,15,18,.72) !important;
}

.secret-row {
  display: flex !important;
  gap: 8px !important;
  margin-top: 9px !important;
}

.secret-row .small-btn { flex: 1 1 0 !important; }
.status { min-height: 18px; margin-top: 8px !important; color: var(--auth-teal) !important; font-size: 12px !important; }
.hint, .help { font-size: 12px !important; line-height: 1.55 !important; }

/* Small utility for localized verification pages */
.auth-kicker {
  width: min(100%, 560px);
  margin: 0 0 8px;
  color: var(--auth-orange);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2.4px;
  text-transform: uppercase;
}
html[dir="rtl"] .auth-kicker { letter-spacing: 0; text-transform: none; text-align: right; }

.auth-back {
  width: min(100%, 560px);
  margin-top: 16px;
  text-align: center;
  font-size: 13px;
}

/* Tablet / mobile: prioritize form usability and remove decorative competition. */
@media (max-width: 960px) {
  body::before {
    position: absolute;
    inset: 0 0 auto 0;
    width: 100%;
    height: 116px;
    border: 0;
    border-bottom: 1px solid rgba(151,171,184,.12);
    background:
      linear-gradient(180deg, rgba(2,6,7,.20), #020607 96%),
      url('/static/img/homepage_globo.png') center 40% / cover no-repeat;
    opacity: .86;
  }
  html[dir="rtl"] body::before {
    inset: 0 0 auto 0;
    width: 100%;
    height: 116px;
    border: 0;
    border-bottom: 1px solid rgba(151,171,184,.12);
    background:
      linear-gradient(180deg, rgba(2,6,7,.20), #020607 96%),
      url('/static/img/homepage_globo.png') center 40% / cover no-repeat;
  }
  body::after, html[dir="rtl"] body::after { display: none; }

  .logo,
  html[dir="rtl"] .logo {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 154px !important;
    margin: 0 auto !important;
    padding-top: 24px !important;
  }

  .logo img { width: 154px !important; }

  .container,
  html[dir="rtl"] .container {
    width: 100% !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 42px 18px 46px !important;
    justify-content: flex-start !important;
  }

  .container > h1,
  .card > h1 {
    font-size: clamp(28px, 7vw, 36px) !important;
  }

  form,
  .card {
    padding: 26px 24px !important;
    border-radius: 16px !important;
  }

}

@media (max-width: 560px) {
  .container,
  html[dir="rtl"] .container {
    padding: 34px 14px 40px !important;
  }

  .logo,
  html[dir="rtl"] .logo {
    width: 142px !important;
    padding-top: 22px !important;
  }
  .logo img { width: 142px !important; }

  form,
  .card {
    margin-top: 15px !important;
    padding: 22px 18px !important;
    border-radius: 15px !important;
  }

  label { margin-top: 16px !important; }
  input, select, .secret-input { min-height: 48px !important; font-size: 16px !important; }

  /* Login email-code row: keep it usable on narrow phones. */
  form > div[style*="display: flex"] {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    gap: 8px !important;
  }

  form > div[style*="display: flex"] button {
    min-width: 88px !important;
  }

  .secret-row { display: grid !important; grid-template-columns: 1fr 1fr !important; }
  img.qrcode { width: 172px !important; height: 172px !important; }
}

@media (max-width: 390px) {
  form > div[style*="display: flex"] { grid-template-columns: 1fr !important; }
  form > div[style*="display: flex"] button { width: 100% !important; }
  .secret-row { grid-template-columns: 1fr !important; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ==============================================================
   DESKTOP UNIFICATION V2
   Mirrors the approved mobile auth identity:
   globe header + NIDAL wordmark + centered compact auth content.
   Visual-only: no form, route, validation or JS behavior changes.
   ============================================================== */
@media (min-width: 961px) {
  body {
    padding: 0 !important;
  }

  /* Same visual header used on mobile; removes mascot/hero split. */
  body::before,
  html[dir="rtl"] body::before {
    position: absolute;
    inset: 0 0 auto 0;
    width: 100%;
    height: 150px;
    border: 0;
    border-bottom: 1px solid rgba(151, 171, 184, .12);
    background:
      linear-gradient(180deg, rgba(2, 6, 7, .14), rgba(2, 6, 7, .48) 72%, #020607 100%),
      url('/static/img/homepage_globo.png') center 40% / cover no-repeat;
    opacity: .92;
    pointer-events: none;
  }

  body::after,
  html[dir="rtl"] body::after {
    display: none;
  }

  .logo {
    position: relative !important;
    z-index: 4 !important;
    top: auto !important;
    left: auto !important;
    right: auto !important;
    width: 184px !important;
    margin: 0 auto 0 clamp(32px, 3.2vw, 52px) !important;
    padding-top: 31px !important;
  }

  html[dir="rtl"] .logo {
    left: auto !important;
    right: auto !important;
    margin: 0 clamp(32px, 3.2vw, 52px) 0 auto !important;
  }

  .logo img,
  html[dir="rtl"] .logo img {
    width: 184px !important;
    height: auto !important;
  }

  .container,
  html[dir="rtl"] .container {
    width: 100% !important;
    max-width: 100% !important;
    min-height: auto !important;
    margin: 0 !important;
    padding: 66px 24px 56px !important;
    justify-content: flex-start !important;
    align-items: center !important;
  }

  .container > h1,
  .card > h1 {
    width: min(100%, 500px);
    margin-bottom: 8px !important;
    font-size: clamp(31px, 2.35vw, 37px) !important;
    line-height: 1.08 !important;
    letter-spacing: -.8px !important;
  }

  html[dir="rtl"] .container > h1,
  html[dir="rtl"] .card > h1 {
    letter-spacing: 0 !important;
  }

  .container > h1::before,
  .card > h1::before {
    width: 38px;
    height: 3px;
    margin-bottom: 13px;
  }

  .container > form,
  .container > .flash,
  .container > .error-message,
  .container > p,
  .auth-kicker,
  .auth-back {
    width: min(100%, 500px) !important;
  }

  form {
    max-width: 500px !important;
    margin-top: 14px !important;
    padding: 24px 28px !important;
    border-radius: 16px !important;
  }

  /* Registration has more fields but should remain equally compact. */
  form#registerForm {
    max-width: 520px !important;
  }

  .container > .card {
    width: min(100%, 620px) !important;
    max-width: 620px !important;
  }

  .card {
    margin-top: 14px !important;
    padding: 26px 30px !important;
    border-radius: 16px !important;
  }

  label {
    margin-top: 15px !important;
    margin-bottom: 6px !important;
  }

  input,
  select,
  .secret-input {
    min-height: 44px !important;
    padding: 10px 12px !important;
  }

  button,
  button[type="submit"],
  .login-button,
  .small-btn {
    min-height: 42px !important;
  }

  button[type="submit"],
  .login-button {
    margin-top: 20px !important;
  }

  .session-note {
    margin-top: 16px !important;
    padding-top: 13px !important;
  }

  .container > p {
    margin-top: 15px !important;
  }
}

/* ==============================================================
   DESKTOP HEADER POLISH V4
   LTR (PT/EN): mirror globe artwork so the globe sits opposite the logo.
   RTL (AR): keep the original artwork orientation.
   Desktop only. Mobile/tablet remain unchanged.
   ============================================================== */
@media (min-width: 961px) {
  /* PT / EN: logo at left, globe visually balanced on the right. */
  html:not([dir="rtl"]) body::before {
    transform: scaleX(-1);
    transform-origin: center center;
  }

  /* Arabic: logo at right, globe remains on the left. */
  html[dir="rtl"] body::before {
    transform: none;
  }

  /* Remove the small orange title marker on desktop for a cleaner auth layout. */
  .container > h1::before,
  .card > h1::before,
  html[dir="rtl"] .container > h1::before,
  html[dir="rtl"] .card > h1::before {
    display: none !important;
  }
}
