/* ورود / ثبت‌نام — طرح split با پس‌زمینه آبی و تصویر ۳D */

html.auth-modern-page,
body.auth-modern-page {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
  font-family: "Vazirmatn", Tahoma, system-ui, sans-serif;
  background: transparent !important;
}

/* پس‌زمینه تمام‌صفحه آبی + موج */
.auth-v2 {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.auth-v2-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: linear-gradient(160deg, #5b9aff 0%, #4a8ef5 35%, #3d7fe8 70%, #3576e0 100%);
}

.auth-v2-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 900'%3E%3Cpath fill='rgba(255,255,255,0.07)' d='M0 400 C300 250 500 500 800 350 C1100 200 1200 450 1440 300 L1440 0 L0 0 Z'/%3E%3Cpath fill='rgba(255,255,255,0.05)' d='M0 600 C400 500 600 750 900 550 C1200 400 1300 650 1440 500 L1440 900 L0 900 Z'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
  pointer-events: none;
}

.auth-v2-inner {
  position: relative;
  z-index: 1;
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem);
  box-sizing: border-box;
}

/* ردیف اصلی: کارت (راست در RTL) + تصویر (چپ) */
.auth-v2-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(1.5rem, 4vw, 3rem);
  width: 100%;
  max-width: 100%;
  flex: 0 1 auto;
  box-sizing: border-box;
}

@media (min-width: 900px) {
  .auth-v2-main {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: clamp(2rem, 5vw, 5rem);
  }
}

@media (min-width: 1100px) {
  .auth-v2-main {
    justify-content: space-between;
    gap: 3rem 5rem;
  }
}

/* ستون فرم — در RTL سمت راست */
.auth-v2-form-col {
  width: 100%;
  max-width: 420px;
  flex: 0 0 auto;
  order: 1;
  box-sizing: border-box;
  min-width: 0;
}

@media (min-width: 900px) {
  .auth-v2-form-col {
    order: 1;
    max-width: min(420px, 42vw);
  }
}

/* ستون تصویر — فقط دسکتاپ */
.auth-v2-visual-col {
  display: none;
  flex: 0 0 auto;
  align-items: flex-end;
  justify-content: flex-end;
  order: 2;
  margin-inline-start: 0;
  padding: 0;
  background: none;
  min-width: 0;
}

@media (min-width: 900px) {
  .auth-v2-visual-col {
    display: flex;
    width: auto;
    max-width: min(400px, 40vw);
    margin-inline-start: clamp(1rem, 3vw, 2.5rem);
  }
}

.auth-v2-visual-col .auth-hero-img,
.auth-v2-visual-col img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: min(42vh, 380px);
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  user-select: none;
  background: transparent !important;
  border: none;
  box-shadow: none;
}

@media (min-width: 900px) {
  .auth-v2-visual-col .auth-hero-img,
  .auth-v2-visual-col img {
    max-height: min(50vh, 360px);
    object-position: left bottom;
  }
}

/* کارت سفید */
.auth-card-modern {
  background: #ffffff;
  border-radius: 24px;
  padding: 2rem 2rem 1.5rem;
  box-shadow: 0 20px 60px rgba(25, 55, 120, 0.18);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: anywhere;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.auth-logo-circles {
  display: flex;
  align-items: center;
}

.auth-logo-circles span {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  margin-right: -7px;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.auth-logo-circles span:nth-child(1) { background: #93c5fd; z-index: 1; }
.auth-logo-circles span:nth-child(2) { background: #60a5fa; z-index: 2; }
.auth-logo-circles span:nth-child(3) { background: #3b82f6; z-index: 3; }

.auth-logo-text {
  font-weight: 600;
  font-size: 0.95rem;
  color: #64748b;
}

.auth-card-modern h1 {
  margin: 0 0 0.65rem;
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
}

.auth-subtitle {
  margin: 0 0 1.25rem;
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.85;
  font-weight: 400;
}

.auth-field-error {
  display: none;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: #ef4444;
  margin-bottom: 0.65rem;
  font-weight: 500;
}

.auth-field-error.show {
  display: flex;
}

/* موبایل: آیکن راست، +98 چپ */
.auth-phone-group {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-phone-group:focus-within {
  border-color: #4a8ef5;
  box-shadow: 0 0 0 3px rgba(74, 142, 245, 0.2);
}

.auth-phone-group.invalid {
  border-color: #f87171;
}

.auth-phone-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  gap: 0.65rem;
  min-width: 0;
}

.auth-phone-input-wrap svg {
  flex-shrink: 0;
  color: #94a3b8;
  order: 2;
}

.auth-phone-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  padding: 1rem 0;
  font-size: 0.95rem;
  font-family: inherit;
  background: transparent;
  color: #0f172a;
  text-align: right;
  direction: ltr;
  order: 1;
}

.auth-phone-input-wrap input::placeholder {
  color: #94a3b8;
  text-align: right;
  direction: rtl;
}

.auth-phone-prefix {
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  color: #475569;
  font-size: 0.9rem;
  font-weight: 500;
  border-right: 1px solid #e2e8f0;
  direction: ltr;
}

.auth-input-modern {
  width: 100%;
  padding: 1rem 1rem;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  font-size: 0.95rem;
  font-family: inherit;
  margin-bottom: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
  color: #0f172a;
}

.auth-input-modern:focus {
  outline: none;
  border-color: #4a8ef5;
  box-shadow: 0 0 0 3px rgba(74, 142, 245, 0.2);
}

.auth-input-modern::placeholder {
  color: #94a3b8;
}

.auth-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin-bottom: 1.35rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
  user-select: none;
}

.auth-checkbox input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.auth-checkbox-box {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 2px solid #cbd5e1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  margin-top: 1px;
}

.auth-checkbox input:checked + .auth-checkbox-box {
  background: #4a8ef5;
  border-color: #4a8ef5;
}

.auth-checkbox input:checked + .auth-checkbox-box::after {
  content: "✓";
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.auth-btn-primary {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 14px;
  background: #4a8ef5;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(74, 142, 245, 0.45);
  transition: background 0.15s, transform 0.1s;
}

.auth-btn-primary:hover:not(:disabled) {
  background: #3b7bed;
  transform: translateY(-1px);
}

.auth-btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.auth-switch-link {
  text-align: center;
  margin: 1.35rem 0 0;
  font-size: 0.9rem;
  color: #64748b;
}

.auth-switch-link a {
  color: #4a8ef5;
  font-weight: 700;
  text-decoration: none;
}

.auth-switch-link a:hover {
  text-decoration: underline;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0 1rem;
  color: #94a3b8;
  font-size: 0.85rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.auth-social-row {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
}

.auth-social-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  font-size: 0.78rem;
  color: #334155;
  font-family: inherit;
  cursor: not-allowed;
  opacity: 0.85;
}

.auth-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.75rem;
  padding-top: 0.25rem;
  font-size: 0.78rem;
}

.auth-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.auth-footer-links a {
  color: #64748b;
  text-decoration: none;
}

.auth-footer-links a:hover {
  color: #4a8ef5;
}

.auth-lang {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  color: #475569;
  font-size: 0.8rem;
  background: #fff;
}

.auth-alert-inline {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.auth-alert-inline.error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

/* ثبت‌نام — چیدمان مثل ورود، باکس عریض‌تر برای فیلدها */
.auth-v2-register .auth-v2-form-col {
  max-width: min(520px, 100%);
}

@media (min-width: 900px) {
  .auth-v2-register .auth-v2-inner {
    max-width: 1240px;
  }

  .auth-v2-register .auth-v2-form-col {
    max-width: min(520px, 46vw);
  }

  .auth-v2-register .auth-card-modern {
    padding: 1.25rem 1.5rem 1rem;
    overflow: visible;
  }

  .auth-v2-register .auth-card-modern h1 {
    font-size: 1.35rem;
    margin-bottom: 0.35rem;
  }

  .auth-v2-register .auth-logo {
    margin-bottom: 0.75rem;
  }

  .auth-v2-register .auth-subtitle {
    margin-bottom: 0.65rem;
    line-height: 1.5;
    font-size: 0.8125rem;
  }

  .auth-v2-register .auth-input-modern {
    margin-bottom: 0.55rem;
    padding: 0.65rem 0.9rem;
    font-size: 0.875rem;
  }

  .auth-v2-register .auth-phone-group {
    margin-bottom: 0.55rem;
  }

  .auth-v2-register .auth-phone-input-wrap input {
    padding: 0.65rem 0;
  }

  .auth-v2-register .auth-register-grid .form-row-2 {
    gap: 0.55rem;
  }

  .auth-v2-register .auth-checkbox {
    margin-bottom: 0.7rem;
    font-size: 0.8rem;
  }

  .auth-v2-register .auth-btn-primary {
    padding: 0.75rem;
    font-size: 0.95rem;
  }

  .auth-v2-register .auth-switch-link {
    margin-top: 0.65rem;
    font-size: 0.85rem;
  }

  .auth-v2-register .auth-footer {
    margin-top: 0.75rem;
    font-size: 0.72rem;
  }

  .auth-v2-register .auth-footer-links {
    gap: 0.5rem 0.85rem;
  }
}

.auth-register-grid .form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.auth-register-grid .form-row-2 .auth-input-modern {
  margin-bottom: 0;
}

/* موبایل کوچک */
@media (max-width: 480px) {
  .auth-v2-inner {
    padding: 0.75rem;
  }

  .auth-card-modern {
    padding: 1.35rem 1.15rem 1.15rem;
    border-radius: 18px;
  }

  .auth-card-modern h1 {
    font-size: 1.25rem;
  }

  .auth-subtitle {
    font-size: 0.82rem;
  }

  .auth-social-row {
    flex-direction: column;
  }

  .auth-footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .auth-register-grid .form-row-2 {
    grid-template-columns: 1fr;
  }
}

/* موبایل: بدون تصویر، کارت وسط */
@media (max-width: 899px) {
  .auth-v2 {
    justify-content: flex-start;
    padding-block: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-bottom));
  }

  .auth-v2-inner {
    padding: 0.75rem 1rem;
    align-items: stretch;
  }

  .auth-v2-main {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .auth-v2-visual-col {
    display: none !important;
  }

  .auth-v2-form-col {
    order: 0;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
  }

  .auth-card-modern {
    margin-inline: auto;
    box-shadow: 0 12px 40px rgba(25, 55, 120, 0.15);
  }

  .auth-social-row {
    flex-direction: column;
  }

  .auth-footer-links {
    gap: 0.75rem 1rem;
  }
}

/* دسکتاپ ورود: بدون اسکرول */
@media (min-width: 900px) {
  html.auth-modern-page:has(body[data-page="userLogin"]) {
    height: 100dvh;
    overflow: hidden;
  }

  body.auth-modern-page[data-page="userLogin"] {
    overflow: hidden;
    height: 100dvh;
    max-height: 100dvh;
  }

  body.auth-modern-page[data-page="userLogin"] .auth-v2 {
    min-height: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.auth-modern-page[data-page="userLogin"] .auth-v2-inner {
    padding: 1rem 2rem;
    max-height: 100%;
    box-sizing: border-box;
  }

  /* دسکتاپ ثبت‌نام: بدون اسکرول داخل باکس؛ در صورت نیاز فقط اسکرول صفحه */
  html.auth-modern-page:has(body[data-page="userRegister"]) {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
  }

  body.auth-modern-page[data-page="userRegister"] {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
    max-height: none;
  }

  body.auth-modern-page[data-page="userRegister"] .auth-v2 {
    min-height: 100dvh;
    height: auto;
    max-height: none;
    overflow: visible;
    justify-content: center;
  }

  body.auth-modern-page[data-page="userRegister"] .auth-v2-inner {
    padding: 1.25rem 2rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    overflow: visible;
  }
}
