/* ==========================================================================
   1. DESIGN TOKENS
   ========================================================================== */

:root {
  --bg: #0b1220;

  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --secondary: #60a5fa;

  --text: #f8fafc;
  --text-muted: #94a3b8;

  --glass: rgba(255, 255, 255, 0.07);
  --glass-border: rgba(255, 255, 255, 0.12);

  --field-bg: rgba(255, 255, 255, 0.05);
  --field-bg-focus: rgba(255, 255, 255, 0.08);

  --danger: #f87171;
  --success: #34d399;

  --radius-card: 24px;
  --radius-field: 12px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --speed: 200ms;
}

/* ==========================================================================
   2. RESET / BASE
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;

  min-height: 100vh;
  min-height: 100dvh;

  display: flex;
  flex-direction: column;

  background: var(--bg);

  color: var(--text);

  font-family: "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;

  font-size: 15px;
  line-height: 1.7;

  direction: rtl;

  overflow-x: hidden;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;

  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: rgba(59, 130, 246, 0.35);
}

button,
input {
  font: inherit;
  color: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

/* ==========================================================================
   3. AMBIENT BACKGROUND
   ========================================================================== */

.ambient {
  position: fixed;
  inset: 0;

  z-index: 0;

  overflow: hidden;

  pointer-events: none;
}

.blob {
  position: absolute;

  border-radius: 50%;

  filter: blur(110px);

  will-change: transform;
}

.blob--one {
  width: min(560px, 80vw);
  aspect-ratio: 1;

  top: -12%;
  inset-inline-start: -8%;

  background: #3b82f6;

  opacity: 0.24;

  animation: drift-a 26s ease-in-out infinite alternate;
}

.blob--two {
  width: min(620px, 90vw);
  aspect-ratio: 1;

  bottom: -18%;
  inset-inline-end: -10%;

  background: #1d4ed8;

  opacity: 0.3;

  animation: drift-b 32s ease-in-out infinite alternate;
}

.blob--three {
  width: min(360px, 60vw);
  aspect-ratio: 1;

  top: 40%;
  inset-inline-end: 28%;

  background: #6366f1;

  opacity: 0.14;

  animation: drift-c 22s ease-in-out infinite alternate;
}

@keyframes drift-a {
  to {
    transform: translate3d(7vw, 9vh, 0) scale(1.12);
  }
}

@keyframes drift-b {
  to {
    transform: translate3d(-8vw, -7vh, 0) scale(1.1);
  }
}

@keyframes drift-c {
  to {
    transform: translate3d(-12vw, 7vh, 0) scale(1.25);
  }
}

/* ==========================================================================
   4. DOT PATTERN
   ========================================================================== */

.pattern {
  position: absolute;

  inset: 0;

  overflow: hidden;

  -webkit-mask-image: radial-gradient(
    ellipse 70% 65% at 50% 50%,
    #000 15%,
    transparent 78%
  );

  mask-image: radial-gradient(
    ellipse 70% 65% at 50% 50%,
    #000 15%,
    transparent 78%
  );
}

.pattern__dots {
  position: absolute;

  inset: -28px;

  background-image: radial-gradient(
    circle,
    rgba(148, 163, 184, 0.35) 1px,
    transparent 1.6px
  );

  background-size: 28px 28px;

  animation: dots-pan 40s linear infinite;
}

@keyframes dots-pan {
  to {
    transform: translate3d(28px, 28px, 0);
  }
}

/* ==========================================================================
   5. PAGE LAYOUT
   ========================================================================== */

.stage {
  position: relative;

  z-index: 1;

  flex: 1;

  display: flex;
  flex-direction: column;

  min-height: 100vh;
  min-height: 100dvh;
}

.page {
  position: relative;

  flex: 1;

  display: grid;
  place-items: center;

  padding: 32px 16px 16px;
}

/* ==========================================================================
   6. AUTHENTICATION
   ========================================================================== */

.auth-wrap {
  position: relative;

  width: 100%;
  max-width: 440px;
}

/* ==========================================================================
   7. DECORATIVE SHAPES
   ========================================================================== */

.shape {
  position: absolute;

  pointer-events: none;

  z-index: 0;
}

.shape--orb {
  width: clamp(110px, 15vw, 170px);
  aspect-ratio: 1;

  top: calc(50% - min(310px, 36vh));

  left: min(calc(100% - 80px), calc(50% + 130px));

  border-radius: 50%;

  background: radial-gradient(
    circle at 30% 26%,
    #bfdbfe 0%,
    #3b82f6 42%,
    #1e3a8a 100%
  );

  filter: blur(1px);

  opacity: 0.55;
}

.shape--ring {
  width: clamp(150px, 18vw, 210px);
  aspect-ratio: 1;

  top: calc(50% + min(120px, 14vh));

  left: max(-50px, calc(50% - 330px));

  border-radius: 50%;

  padding: 26px;

  background: linear-gradient(135deg, #93c5fd, #1d4ed8);

  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);

  -webkit-mask-composite: xor;

  mask:
    linear-gradient(#000 0 0) content-box exclude,
    linear-gradient(#000 0 0);

  filter: blur(0.5px);

  opacity: 0.5;
}

.shape--tile {
  width: clamp(64px, 8vw, 88px);
  aspect-ratio: 1;

  top: calc(50% + min(190px, 22vh));

  left: min(calc(100% - 50px), calc(50% + 175px));

  border-radius: 22px;

  background: linear-gradient(
    140deg,
    rgba(191, 219, 254, 0.6),
    rgba(37, 99, 235, 0.22)
  );

  border: 1px solid rgba(255, 255, 255, 0.28);

  opacity: 0.85;

  transform: rotate(18deg);
}

/* ==========================================================================
   8. AUTH CARD
   ========================================================================== */

.auth-card {
  position: relative;

  z-index: 1;

  width: 100%;

  padding: 36px 32px 56px;

  background: linear-gradient(
    145deg,
    rgba(255, 255, 255, 0.11),
    var(--glass) 55%
  );

  -webkit-backdrop-filter: blur(28px) saturate(150%);

  backdrop-filter: blur(28px) saturate(150%);

  border: 1px solid var(--glass-border);

  border-radius: var(--radius-card);

  box-shadow:
    0 24px 60px -24px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);

  animation: card-in 350ms var(--ease) both;
}

@keyframes card-in {
  from {
    opacity: 0;

    transform: translateY(12px);
  }

  to {
    opacity: 1;

    transform: translateY(0);
  }
}

/* ==========================================================================
   9. BRAND
   ========================================================================== */

.brand {
  width: 44px;
  height: 44px;

  display: grid;
  place-items: center;

  margin: 0 auto 20px;

  color: var(--secondary);

  background: rgba(59, 130, 246, 0.12);

  border: 1px solid rgba(96, 165, 250, 0.25);

  border-radius: 12px;

  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.brand svg {
  width: 22px;
  height: 22px;
}

/* ==========================================================================
   10. CARD HEADER
   ========================================================================== */

.view-header {
  margin-bottom: 26px;

  text-align: center;
}

.view-title {
  margin: 0 0 6px;

  font-size: 26px;
  font-weight: 700;

  line-height: 1.4;

  letter-spacing: -0.01em;
}

.view-subtitle {
  margin: 0;

  color: var(--text-muted);

  font-size: 14.5px;

  line-height: 1.8;
}

/* ==========================================================================
   11. FORM
   ========================================================================== */

.form {
  display: flex;
  flex-direction: column;

  gap: 16px;
}

.field {
  width: 100%;
}

.field-label {
  display: block;

  margin-bottom: 8px;

  color: rgba(248, 250, 252, 0.85);

  font-size: 13.5px;
  font-weight: 500;
}

.control {
  position: relative;

  width: 100%;

  height: 48px;
}

/* ==========================================================================
   12. INPUT
   ========================================================================== */

.input {
  display: block;

  width: 100%;
  height: 48px;

  /*
   * سمت راست: آیکون فیلد
   * سمت چپ: برای فیلد رمز، دکمه چشم
   */
  padding-top: 0;
  padding-bottom: 0;

  padding-right: 42px;
  padding-left: 14px;

  background: var(--field-bg);

  border: 1px solid var(--glass-border);

  border-radius: var(--radius-field);

  color: var(--text);

  font-size: 15px;

  direction: rtl;
  text-align: right;

  outline: none;

  transition:
    border-color var(--speed) var(--ease),
    background-color var(--speed) var(--ease),
    box-shadow var(--speed) var(--ease);
}

/*
 * فیلد رمز عبور:
 * سمت راست = آیکون قفل
 * سمت چپ = دکمه نمایش رمز
 */
.input--password {
  padding-right: 42px;
  padding-left: 48px;
}

.input::placeholder {
  color: rgba(148, 163, 184, 0.62);
}

.input:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.input:focus {
  background: var(--field-bg-focus);

  border-color: rgba(96, 165, 250, 0.75);

  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
}

.input[aria-invalid="true"] {
  border-color: rgba(248, 113, 113, 0.7);
}

.input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.16);
}

.input.is-valid {
  border-color: rgba(52, 211, 153, 0.45);
}

/* Autofill */

.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);

  caret-color: var(--text);

  transition: background-color 9999s ease-out 0s;

  box-shadow: inset 0 0 0 1000px #131c2e;
}

/* ==========================================================================
   13. FIELD ICON
   ========================================================================== */

/*
 * عمداً از right استفاده شده تا در RTL
 * آیکون دقیقاً سمت راست فیلد قرار بگیرد.
 */

.field-icon {
  position: absolute;

  top: 50%;
  right: 14px;

  width: 18px;
  height: 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  color: var(--text-muted);

  pointer-events: none;

  transform: translateY(-50%);

  z-index: 2;

  transition: color var(--speed) var(--ease);
}

.field-icon svg {
  display: block;

  width: 100%;
  height: 100%;
}

.input:focus + .field-icon {
  color: var(--secondary);
}

.input[aria-invalid="true"] + .field-icon {
  color: var(--danger);
}

.input.is-valid + .field-icon {
  color: var(--success);
}

/* ==========================================================================
   14. PASSWORD TOGGLE
   ========================================================================== */

/*
 * دکمه چشم عمداً سمت چپ فیلد است
 * تا با آیکون قفل تداخل نداشته باشد.
 */

.toggle-password {
  position: absolute;

  top: 50%;
  left: 8px;

  width: 32px;
  height: 32px;

  display: grid;
  place-items: center;

  padding: 0;

  background: transparent;

  border: 0;

  border-radius: 8px;

  color: var(--text-muted);

  cursor: pointer;

  transform: translateY(-50%);

  z-index: 3;

  transition:
    color var(--speed) var(--ease),
    background-color var(--speed) var(--ease);
}

.toggle-password:hover {
  color: var(--text);

  background: rgba(255, 255, 255, 0.08);
}

.toggle-password:active {
  transform: translateY(-50%) scale(0.94);
}

.toggle-password svg {
  grid-area: 1 / 1;

  width: 18px;
  height: 18px;

  transition: opacity var(--speed) var(--ease);
}

.toggle-password .icon-hide,
.toggle-password.is-visible .icon-show {
  opacity: 0;
}

.toggle-password.is-visible .icon-hide {
  opacity: 1;
}

/* ==========================================================================
   15. INLINE MESSAGES
   ========================================================================== */

.message {
  display: grid;

  grid-template-rows: 0fr;

  opacity: 0;
  visibility: hidden;

  transition:
    grid-template-rows var(--speed) var(--ease),
    opacity var(--speed) var(--ease),
    visibility 0s linear var(--speed);
}

.message.is-visible {
  grid-template-rows: 1fr;

  opacity: 1;
  visibility: visible;

  transition-delay: 0s;
}

.message__inner {
  min-height: 0;

  overflow: hidden;
}

.message__text {
  display: flex;
  align-items: flex-start;

  gap: 6px;

  margin: 0;

  padding-top: 7px;

  font-size: 13px;

  line-height: 1.6;
}

.message__text svg {
  flex: none;

  width: 15px;
  height: 15px;

  margin-top: 3px;
}

.message--error {
  color: var(--danger);
}

.message--success {
  color: var(--success);
}

/* ==========================================================================
   16. TOP TOAST
   ========================================================================== */

.login-toast {
  position: fixed;

  top: 20px;
  left: 50%;

  z-index: 9999;

  width: min(calc(100% - 32px), 460px);

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 14px 14px 14px 16px;

  background: rgba(15, 23, 42, 0.94);

  border: 1px solid rgba(255, 255, 255, 0.12);

  border-radius: 14px;

  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);

  -webkit-backdrop-filter: blur(18px);

  backdrop-filter: blur(18px);

  opacity: 0;

  visibility: hidden;

  transform: translate(-50%, -24px);

  transition:
    opacity 250ms var(--ease),
    transform 250ms var(--ease),
    visibility 250ms;
}

.login-toast.is-visible {
  opacity: 1;

  visibility: visible;

  transform: translate(-50%, 0);
}

.login-toast--success {
  border-color: rgba(52, 211, 153, 0.28);
}

.login-toast--error {
  border-color: rgba(248, 113, 113, 0.28);
}

.login-toast__icon {
  flex: 0 0 38px;

  width: 38px;
  height: 38px;

  display: grid;
  place-items: center;

  border-radius: 10px;
}

.login-toast--success .login-toast__icon {
  color: var(--success);

  background: rgba(52, 211, 153, 0.12);
}

.login-toast--error .login-toast__icon {
  color: var(--danger);

  background: rgba(248, 113, 113, 0.12);
}

.login-toast__icon svg {
  width: 20px;
  height: 20px;
}

.login-toast__content {
  flex: 1;

  min-width: 0;
}

.login-toast__title {
  margin: 0 0 2px;

  color: var(--text);

  font-size: 14px;

  font-weight: 600;

  line-height: 1.5;
}

.login-toast__message {
  margin: 0;

  color: var(--text-muted);

  font-size: 13px;

  line-height: 1.6;

  word-break: break-word;
}

.login-toast__close {
  flex: 0 0 30px;

  width: 30px;
  height: 30px;

  display: grid;
  place-items: center;

  padding: 0;

  background: transparent;

  border: 0;

  border-radius: 8px;

  color: var(--text-muted);

  cursor: pointer;

  transition:
    color var(--speed) var(--ease),
    background-color var(--speed) var(--ease);
}

.login-toast__close:hover {
  color: var(--text);

  background: rgba(255, 255, 255, 0.08);
}

.login-toast__close svg {
  width: 17px;
  height: 17px;
}

/* ==========================================================================
   17. PRIMARY BUTTON
   ========================================================================== */

.btn-primary {
  width: 100%;
  height: 48px;

  margin-top: 8px;

  background: var(--primary-strong);

  border: 0;

  border-radius: var(--radius-field);

  color: #fff;

  font-size: 15px;
  font-weight: 600;

  cursor: pointer;

  box-shadow:
    0 10px 22px -10px rgba(37, 99, 235, 0.75),
    inset 0 1px 0 rgba(255, 255, 255, 0.16);

  transition:
    background-color var(--speed) var(--ease),
    transform 120ms var(--ease),
    box-shadow var(--speed) var(--ease),
    opacity var(--speed) var(--ease);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary);

  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0) scale(0.99);

  box-shadow: 0 4px 12px -6px rgba(37, 99, 235, 0.7);
}

.btn-primary:disabled {
  opacity: 0.65;

  cursor: wait;

  transform: none;
}

/* ==========================================================================
   18. ACCESSIBILITY
   ========================================================================== */

:is(button, input):focus-visible {
  outline: 2px solid var(--secondary);

  outline-offset: 2px;
}

.input:focus-visible {
  outline: none;
}

/* ==========================================================================
   19. FOOTER
   ========================================================================== */

.footer {
  position: relative;

  z-index: 1;

  padding: 16px 16px 24px;

  text-align: center;

  color: rgba(148, 163, 184, 0.55);

  font-size: 12.5px;
}

/* ==========================================================================
   20. MOBILE
   ========================================================================== */

@media (max-width: 480px) {
  .page {
    padding: 20px 14px 8px;
  }

  .auth-card {
    padding: 28px 20px 46px;

    border-radius: 20px;
  }

  .view-title {
    font-size: 23px;
  }

  .input {
    font-size: 16px;
  }

  .login-toast {
    top: 12px;

    width: calc(100% - 24px);

    padding: 12px;
  }
}

/* ==========================================================================
   21. SHORT VIEWPORT
   ========================================================================== */

@media (max-height: 720px) {
  .page {
    padding-block: 20px 8px;
  }

  .auth-card {
    padding-block: 28px 44px;
  }

  .brand {
    width: 40px;
    height: 40px;

    margin-bottom: 16px;
  }

  .view-header {
    margin-bottom: 20px;
  }

  .form {
    gap: 12px;
  }

  .control,
  .input {
    height: 44px;
  }

  .btn-primary {
    height: 44px;

    margin-top: 6px;
  }

  .footer {
    padding-block: 10px 16px;
  }
}

/* ==========================================================================
   22. VERY SHORT VIEWPORT
   ========================================================================== */

@media (max-height: 620px) {
  .page {
    padding-block: 14px 4px;
  }

  .auth-card {
    padding-block: 22px 36px;
  }

  .brand {
    width: 34px;
    height: 34px;

    margin-bottom: 10px;

    border-radius: 10px;
  }

  .brand svg {
    width: 18px;
    height: 18px;
  }

  .view-header {
    margin-bottom: 14px;
  }

  .view-title {
    margin-bottom: 2px;

    font-size: 22px;
  }

  .view-subtitle {
    font-size: 13.5px;
  }

  .form {
    gap: 10px;
  }

  .field-label {
    margin-bottom: 6px;
  }

  .control,
  .input {
    height: 42px;
  }

  .message__text {
    padding-top: 5px;

    font-size: 12.5px;
  }

  .footer {
    padding-block: 6px 12px;

    font-size: 12px;
  }
}

/* ==========================================================================
   23. EXTREMELY SHORT VIEWPORT
   ========================================================================== */

@media (max-height: 520px) {
  .auth-card {
    padding-block: 18px 28px;
  }

  .view-title {
    font-size: 20px;
  }

  .brand {
    width: 30px;
    height: 30px;

    margin-bottom: 8px;
  }

  .view-subtitle {
    font-size: 12.5px;

    line-height: 1.5;
  }

  .view-header {
    margin-bottom: 10px;
  }

  .form {
    gap: 8px;
  }

  .control,
  .input {
    height: 40px;
  }
}

/* ==========================================================================
   24. LARGE SCREENS
   ========================================================================== */

@media (min-width: 1600px) {
  body {
    font-size: 16px;
  }
}

/* ==========================================================================
   25. REDUCED MOTION
   ========================================================================== */

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

    animation-iteration-count: 1 !important;

    transition-duration: 0.01ms !important;

    scroll-behavior: auto !important;
  }

  .blob,
  .pattern__dots {
    animation: none !important;
  }
}
