@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Poppins:wght@400;500;600;700;800&display=swap');

:root {
  --auth-bg: #f2f6fd;
  --auth-bg-deep: #dbe9ff;
  --auth-card: #ffffff;
  --auth-primary: #2563eb;
  --auth-primary-dark: #1d4ed8;
  --auth-primary-soft: #dbeafe;
  --auth-navy: #0b1b33;
  --auth-text: #22355a;
  --auth-muted: #5b6b84;
  --auth-line: #728cb5;
  --auth-input: #eef3fa;
  --auth-danger: #dc2626;
  --auth-danger-bg: #fef2f2;
  --auth-success: #047857;
  --auth-success-bg: #ecfdf5;
  --auth-shadow: 0 24px 70px rgba(30, 64, 175, 0.16);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body.auth-page {
  margin: 0;
  min-height: 100dvh;
  overflow-x: hidden;
  color-scheme: light;
  background:
    radial-gradient(circle at 12% 8%, rgba(37, 99, 235, 0.14), transparent 32%),
    radial-gradient(circle at 88% 92%, rgba(96, 165, 250, 0.16), transparent 30%),
    linear-gradient(135deg, var(--auth-bg), var(--auth-bg-deep));
  color: var(--auth-navy);
  font-family: 'IBM Plex Sans Arabic', 'Poppins', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
a { color: var(--auth-primary); }

.auth-shell {
  width: min(1180px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.auth-topbar {
  width: min(920px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.auth-brand-mini {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--auth-navy);
  font-weight: 800;
  text-decoration: none;
}

.auth-brand-mini img {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  object-fit: cover;
}

.language-picker { position: relative; }

.language-button {
  min-height: 42px;
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--auth-text);
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(30, 64, 175, 0.08);
}

.language-menu {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 8px);
  z-index: 50;
  width: 210px;
  max-height: 330px;
  overflow: auto;
  padding: 7px;
  border: 1px solid var(--auth-line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 18px 46px rgba(11, 27, 51, 0.16);
}

.language-menu[hidden] { display: none; }

.language-option {
  width: 100%;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--auth-text);
  padding: 9px 11px;
  text-align: start;
}

.language-option:hover, .language-option.active { background: var(--auth-primary-soft); color: var(--auth-primary-dark); }

.auth-card {
  position: relative;
  width: min(920px, 100%);
  height: min(690px, calc(100dvh - 112px));
  min-height: 610px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  background: var(--auth-card);
  box-shadow: var(--auth-shadow);
}

.form-box {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  z-index: 1;
  width: 50%;
  padding: 34px 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  scrollbar-width: none;
  background: #fff;
  color: var(--auth-navy);
  transition: inset-inline-end 0.6s ease-in-out 1.05s, visibility 0s 1.05s, opacity 0.25s ease;
}

.form-box::-webkit-scrollbar { display: none; }
.auth-card.register .form-box { inset-inline-end: 50%; }

.form-box.view-login { visibility: visible; opacity: 1; }
.form-box.view-register, .form-box.view-flow { visibility: hidden; opacity: 0; pointer-events: none; }
.auth-card.register .form-box.view-login { visibility: hidden; opacity: 0; pointer-events: none; }
.auth-card.register .form-box.view-register { visibility: visible; opacity: 1; pointer-events: auto; }
.auth-card[data-view='otp'] .form-box.view-flow[data-flow='otp'],
.auth-card[data-view='reset'] .form-box.view-flow[data-flow='reset'] {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  z-index: 4;
}
.auth-card[data-view='otp'] .form-box.view-login,
.auth-card[data-view='otp'] .form-box.view-register,
.auth-card[data-view='reset'] .form-box.view-login,
.auth-card[data-view='reset'] .form-box.view-register {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.view-register .input-box { margin: 10px 0; }
.view-register .input-box input { min-height: 46px; padding-top: 10px; padding-bottom: 10px; }
.view-register .input-box > i { bottom: 13px; }
.view-register .divider { margin: 14px 0 9px; }
.view-register .telegram-links { margin-top: 7px; }

.otp-meta { min-height: 18px; margin: 2px 0 8px; color: var(--auth-muted); font-size: 12.5px; font-weight: 600; }

.auth-form { width: 100%; max-width: 380px; margin: auto; text-align: center; }
.auth-form h1 { margin: 0 0 8px; font-size: clamp(30px, 4vw, 38px); line-height: 1.15; letter-spacing: -0.02em; }
.auth-form .subtitle { margin: 0 auto 22px; max-width: 340px; color: var(--auth-muted); font-size: 14.5px; line-height: 1.75; }

.input-box { position: relative; margin: 15px 0; text-align: start; }
.input-box label { display: block; margin: 0 0 7px; color: var(--auth-text); font-size: 13px; font-weight: 700; }
.input-box input {
  width: 100%;
  min-height: 50px;
  border: 1px solid transparent;
  border-radius: 12px;
  outline: none;
  background: var(--auth-input);
  color: var(--auth-navy);
  padding: 13px 48px 13px 16px;
  font-size: 16px;
  font-weight: 500;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
[dir='rtl'] .input-box input { padding: 13px 16px 13px 48px; }
.input-box input:focus { border-color: rgba(37, 99, 235, 0.85); background: #fff; box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.11); }
.input-box input::placeholder { color: #5b6b84; font-weight: 400; }
.input-box > i {
  position: absolute;
  inset-inline-end: 17px;
  bottom: 15px;
  color: #7d92b2;
  font-size: 20px;
  pointer-events: none;
}
.input-box .ltr { direction: ltr; text-align: left; }
[dir='rtl'] .input-box .ltr { text-align: left; }

.forgot-row { margin: 4px 0 16px; text-align: end; }
.forgot-row button { border: 0; background: transparent; color: var(--auth-text); padding: 2px 0; font-size: 14px; }
.forgot-row button:hover { color: var(--auth-primary); }

.btn {
  position: relative;
  width: 100%;
  min-height: 50px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-dark));
  color: #fff;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
  font-size: 16px;
  font-weight: 700;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 16px 30px rgba(37, 99, 235, 0.27); }
.btn:disabled { cursor: wait; opacity: 0.62; }
.btn.secondary { background: #fff; color: var(--auth-primary); border: 1px solid var(--auth-line); box-shadow: none; }
.btn.ghost { width: auto; min-height: 42px; padding: 8px 18px; background: transparent; color: var(--auth-primary); box-shadow: none; }

.divider { display: flex; align-items: center; gap: 12px; margin: 21px 0 13px; color: var(--auth-muted); font-size: 12.5px; }
.divider::before, .divider::after { content: ''; height: 1px; flex: 1; background: var(--auth-line); }

.telegram-widget-wrap {
  height: 40px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  color-scheme: light;
}
.telegram-widget-wrap:empty { display: none; }
.telegram-widget-wrap iframe {
  display: block;
  border: 0;
  background: transparent;
  color-scheme: light;
}

.google-button-wrap {
  min-height: 44px;
  margin-top: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 12px;
  color-scheme: light;
}
.google-button-wrap:empty { display: none; }
.google-button-wrap iframe {
  display: block;
  border: 0;
  background: transparent;
  color-scheme: light;
}

.telegram-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.telegram-links a {
  min-height: 42px;
  border: 1px solid var(--auth-line);
  border-radius: 11px;
  background: #fff;
  color: #1677a8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}
.telegram-links a i { font-size: 19px; }
.telegram-links a:hover { border-color: #9ec9e8; background: #f2f9ff; }

.message {
  display: none;
  margin: 0 0 15px;
  border-radius: 12px;
  padding: 11px 13px;
  font-size: 13.5px;
  line-height: 1.65;
  text-align: start;
}
.message.show { display: block; }
.message.error { background: var(--auth-danger-bg); color: var(--auth-danger); border: 1px solid #fecaca; }
.message.success { background: var(--auth-success-bg); color: var(--auth-success); border: 1px solid #a7f3d0; }

.otp-boxes { direction: ltr; display: flex; justify-content: center; gap: 8px; margin: 20px 0 13px; }
.otp-boxes input {
  width: 49px;
  height: 57px;
  border: 1px solid var(--auth-line);
  border-radius: 13px;
  outline: none;
  background: #f7faff;
  color: var(--auth-navy);
  text-align: center;
  font-size: 23px;
  font-weight: 800;
}
.otp-boxes input:focus { border-color: var(--auth-primary); box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12); background: #fff; }
.otp-meta { color: var(--auth-muted); font-size: 13px; line-height: 1.8; }
.resend-button { border: 0; background: transparent; color: var(--auth-primary); font-weight: 700; padding: 5px; }
.resend-button:disabled { color: var(--auth-muted); cursor: wait; }
.flow-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 17px; }
.flow-actions .btn { width: auto; flex: 1; }
.back-button { border: 0; background: transparent; color: var(--auth-text); font-weight: 700; padding: 9px 4px; white-space: nowrap; }

.toggle-box { position: absolute; inset: 0; pointer-events: none; }
.toggle-box::before {
  content: '';
  position: absolute;
  inset-inline-start: -250%;
  z-index: 2;
  width: 300%;
  height: 100%;
  border-radius: 150px;
  background: linear-gradient(180deg, #3b82f6, var(--auth-primary-dark));
  box-shadow: inset -24px 0 50px rgba(255, 255, 255, 0.08);
  transition: inset-inline-start 1.55s ease-in-out;
}
.auth-card.register .toggle-box::before { inset-inline-start: 50%; }

.toggle-panel {
  position: absolute;
  top: 0;
  z-index: 3;
  width: 50%;
  height: 100%;
  padding: 42px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  transition: inset-inline-start 0.6s ease-in-out, inset-inline-end 0.6s ease-in-out, opacity 0.3s ease;
  pointer-events: none;
}
.toggle-panel .panel-logo {
  width: 126px;
  height: 126px;
  margin-bottom: 18px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 18px 36px rgba(2, 20, 54, 0.25);
}
.toggle-panel h2 { margin: 0; font-size: clamp(29px, 4vw, 38px); line-height: 1.2; }
.toggle-panel p { margin: 13px 0 20px; color: rgba(255, 255, 255, 0.86); font-size: 15px; line-height: 1.75; }
.toggle-panel .btn { width: 168px; min-height: 47px; border: 2px solid rgba(255, 255, 255, 0.9); background: transparent; box-shadow: none; pointer-events: auto; }
.toggle-panel.start { inset-inline-start: 0; transition-delay: 1.05s; }
.auth-card.register .toggle-panel.start { inset-inline-start: -50%; opacity: 0; transition-delay: 0.45s; }
.toggle-panel.end { inset-inline-end: -50%; opacity: 0; transition-delay: 0.45s; }
.auth-card.register .toggle-panel.end { inset-inline-end: 0; opacity: 1; transition-delay: 1.05s; }
.auth-card[data-view='otp'] .toggle-panel .btn,
.auth-card[data-view='reset'] .toggle-panel .btn { pointer-events: none; opacity: 0.45; }

.auth-toast {
  position: fixed;
  inset-inline: 0;
  bottom: 22px;
  z-index: 100;
  width: fit-content;
  max-width: min(520px, calc(100vw - 32px));
  margin: auto;
  border-radius: 999px;
  background: var(--auth-navy);
  color: #fff;
  padding: 11px 17px;
  box-shadow: 0 16px 38px rgba(11, 27, 51, 0.28);
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.auth-toast.show { opacity: 1; transform: translateY(0); }
.auth-toast.error { background: #991b1b; }
.auth-toast.success { background: #065f46; }

/* Link Telegram page */
.link-card {
  position: relative;
  width: min(920px, 100%);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 30px;
  background: #fff;
  box-shadow: var(--auth-shadow);
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
}
.link-visual {
  min-height: 560px;
  padding: 42px;
  background: linear-gradient(155deg, #1e40af, #1d4ed8 52%, #2563eb);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.link-visual img { width: 142px; height: 142px; border-radius: 50%; object-fit: cover; box-shadow: 0 20px 42px rgba(2, 20, 54, 0.28); }
.link-visual h1 { margin: 22px 0 10px; font-size: clamp(30px, 4vw, 40px); line-height: 1.2; }
.link-visual p { margin: 0; max-width: 330px; color: #eef4ff; line-height: 1.85; }
.link-content { padding: 42px; display: flex; align-items: center; }
.link-inner { width: 100%; max-width: 430px; margin: auto; }
.link-inner h2 { margin: 0 0 9px; font-size: 30px; }
.link-inner .subtitle { margin: 0 0 22px; color: var(--auth-muted); line-height: 1.8; }
.link-result { display: none; margin-top: 20px; border: 1px solid var(--auth-line); border-radius: 16px; padding: 15px; background: #f8fbff; }
.link-result.show { display: block; }
.deep-link-text { direction: ltr; display: block; margin: 10px 0 13px; color: var(--auth-primary-dark); font-size: 12.5px; overflow-wrap: anywhere; text-align: left; }
.link-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.link-actions .btn { min-height: 47px; }
.status-line { display: flex; align-items: center; gap: 9px; margin-top: 14px; color: var(--auth-muted); font-size: 14px; }
.status-dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 50%; background: #f59e0b; box-shadow: 0 0 0 5px rgba(245, 158, 11, 0.14); }
.status-line.success { color: var(--auth-success); }
.status-line.success .status-dot { background: var(--auth-success); box-shadow: 0 0 0 5px rgba(4, 120, 87, 0.13); }
.status-line.error { color: var(--auth-danger); }
.status-line.error .status-dot { background: var(--auth-danger); box-shadow: 0 0 0 5px rgba(220, 38, 38, 0.12); }
.secure-note { margin-top: 22px; border-inline-start: 3px solid var(--auth-primary); background: #f0f6ff; border-radius: 10px; padding: 12px 14px; color: var(--auth-text); font-size: 13px; line-height: 1.75; }
/* [LinkSkip 2026-11-20] The skip control sits directly on the card's own
   background — spacing and plain text only, no panel or backdrop. */
.link-skip { margin-top: 18px; }
.link-skip-hint { margin: 10px 0 0; color: var(--auth-muted); font-size: 13px; line-height: 1.8; text-align: center; }

@media screen and (max-width: 650px) {
  .auth-shell { padding: 12px; justify-content: flex-start; }
  .auth-topbar { padding: 2px 2px 0; }
  .auth-card { height: calc(100dvh - 92px); min-height: 570px; border-radius: 26px; }
  .form-box { inset-inline-end: 0; bottom: 0; top: auto; width: 100%; height: 71%; padding: 18px 22px; align-items: flex-start; transition: bottom 0.6s ease-in-out 1.05s, visibility 0s 1.05s, opacity 0.25s ease; }
  .auth-form .subtitle { margin-bottom: 15px; }
  .input-box { margin: 10px 0; }
  .input-box input { min-height: 47px; }
  .telegram-links a { min-height: 38px; }
  .view-register .subtitle { display: none; }
  .view-register .input-box { margin: 7px 0; }
  .view-register .input-box label { margin-bottom: 4px; font-size: 12px; }
  .view-register .input-box input { min-height: 44px; }
  .view-register .divider { margin: 10px 0 7px; }
  .auth-card.register .form-box { inset-inline-end: 0; bottom: 29%; }
  .auth-form { max-width: 430px; }
  .auth-form h1 { font-size: 30px; }
  .toggle-box::before { inset-inline-start: 0; top: -270%; width: 100%; height: 300%; border-radius: 50% / 30px; transition: top 1.45s ease-in-out; }
  .auth-card.register .toggle-box::before { inset-inline-start: 0; top: 71%; }
  .toggle-panel { width: 100%; height: 29%; padding: 14px 20px; }
  .toggle-panel .panel-logo { width: 54px; height: 54px; margin-bottom: 6px; border-radius: 50%; }
  .toggle-panel h2 { font-size: 25px; }
  .toggle-panel p { margin: 5px 0 9px; font-size: 13px; line-height: 1.5; }
  .toggle-panel .btn { width: 146px; min-height: 40px; font-size: 14px; }
  .toggle-panel.start { inset-inline-start: 0; top: 0; }
  .auth-card.register .toggle-panel.start { inset-inline-start: 0; top: -29%; }
  .toggle-panel.end { inset-inline-end: 0; bottom: -29%; top: auto; }
  .auth-card.register .toggle-panel.end { inset-inline-end: 0; bottom: 0; }
  .otp-boxes { gap: 6px; }
  .otp-boxes input { width: 44px; height: 52px; }
  .link-card { display: block; }
  .link-visual { min-height: 0; padding: 26px 22px; }
  .link-visual img { width: 76px; height: 76px; border-radius: 50%; }
  .link-visual h1 { margin-top: 13px; font-size: 29px; }
  .link-content { padding: 27px 22px 32px; }
}

@media screen and (max-width: 400px) {
  .form-box { padding: 20px 16px; }
  .telegram-links { gap: 5px; }
  .telegram-links a { font-size: 11.5px; }
  .otp-boxes input { width: 40px; height: 49px; font-size: 21px; }
  .link-actions { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; transition-delay: 0s !important; scroll-behavior: auto !important; }
}
