/* ============================================================
   AUTH PAGES — Shared Stylesheet
   Modern SaaS auth: centered card, subtle background, clean form.
   ============================================================ */

/* --- Background --- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
  background: #f0f2f5;
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 20% 0%, rgba(67,97,238,.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 100%, rgba(118,75,162,.05) 0%, transparent 70%);
  pointer-events: none;
}

/* --- Card --- */
.auth-card {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 16px;
  box-shadow:
    0 1px 3px rgba(0,0,0,.04),
    0 6px 24px rgba(0,0,0,.06);
  padding: 40px 36px;
  z-index: 1;
}

.auth-card-register {
  max-width: 760px;
  padding: 30px 32px;
}

/* --- Logo / Brand --- */
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

.auth-brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: contain;
  margin-bottom: 20px;
}

.auth-brand h1 {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -.02em;
  margin: 0 0 4px;
}

.auth-brand p {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
}

/* --- Form --- */
.auth-form {
  width: 100%;
}

.auth-form .auth-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-form-register .auth-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.auth-form-register .auth-field-full {
  grid-column: 1 / -1;
}

.auth-form-register .auth-btn-primary {
  width: auto;
  min-width: 180px;
  height: 42px;
  margin: 18px 0 0 auto;
}

[dir="rtl"] .auth-form-register .auth-btn-primary {
  margin-right: auto;
  margin-left: 0;
}

/* --- Field --- */
.auth-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.auth-field .auth-input-wrap {
  position: relative;
}

.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="tel"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  color: #111827;
  background: #f9fafb;
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: none;
}

.auth-field input:focus {
  border-color: #4361ee;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(67,97,238,.1);
}

.auth-field input.auth-input-error {
  border-color: #ef4444;
  background: #fef2f2;
}

.auth-field input.auth-input-error:focus {
  box-shadow: 0 0 0 3px rgba(239,68,68,.1);
}

/* Error text */
.auth-error {
  display: block;
  font-size: 12px;
  color: #ef4444;
  margin-top: 4px;
  line-height: 1.4;
}

/* Password toggle */
.auth-pw-toggle {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  color: #9ca3af;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color .15s;
  line-height: 1;
}

.auth-pw-toggle:hover {
  color: #4b5563;
}

.auth-pw-toggle:focus-visible {
  outline: 2px solid #4361ee;
  outline-offset: 2px;
}

/* RTL: toggle on left */
[dir="rtl"] .auth-pw-toggle {
  right: auto;
  left: 12px;
}

/* --- Row (remember me + forgot) --- */
.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 2px;
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
  user-select: none;
}

.auth-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4361ee;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.auth-forgot {
  font-size: 13px;
  color: #4361ee;
  text-decoration: none;
  font-weight: 500;
  transition: color .15s;
  white-space: nowrap;
}

.auth-forgot:hover {
  color: #3451d1;
  text-decoration: underline;
}

/* --- Primary button --- */
.auth-btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 46px;
  margin-top: 6px;
  padding: 0 20px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: #4361ee;
  cursor: pointer;
  transition: background .15s, box-shadow .15s, transform .1s;
}

.auth-btn-primary:hover:not(:disabled) {
  background: #3451d1;
  box-shadow: 0 4px 14px rgba(67,97,238,.35);
  transform: translateY(-1px);
}

.auth-btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.auth-btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.auth-btn-primary:focus-visible {
  outline: 2px solid #4361ee;
  outline-offset: 2px;
}

.auth-btn-primary .auth-spinner {
  display: none;
}

.auth-btn-primary.is-loading .auth-btn-text {
  display: none;
}

.auth-btn-primary.is-loading .auth-spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin .6s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* --- Secondary button (SMS OTP) --- */
.auth-btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  margin-top: 10px;
  padding: 0 20px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  background: #fff;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .15s, background .15s;
}

.auth-btn-secondary:hover {
  border-color: #4361ee;
  background: #f0f4ff;
}

.auth-btn-secondary:focus-visible {
  outline: 2px solid #4361ee;
  outline-offset: 2px;
}

/* --- Divider --- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 20px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #e5e7eb;
}

.auth-divider span {
  font-size: 12px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}

/* --- Social login (placeholder) --- */
.auth-social {
  display: flex;
  gap: 10px;
}

.auth-social-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-weight: 500;
  color: #374151;
  text-decoration: none;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.auth-social-btn:hover {
  border-color: #d1d5db;
  background: #f9fafb;
}

.auth-social-btn:focus-visible {
  outline: 2px solid #4361ee;
  outline-offset: 2px;
}

/* --- Footer link --- */
.auth-footer {
  text-align: center;
  margin-top: 28px;
  font-size: 14px;
  color: #6b7280;
}

.auth-footer a {
  color: #4361ee;
  text-decoration: none;
  font-weight: 600;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.auth-footer a:focus-visible {
  outline: 2px solid #4361ee;
  outline-offset: 2px;
  border-radius: 4px;
}

/* --- Non-field errors --- */
.auth-nonfield-errors {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.5;
}

.auth-nonfield-errors i {
  margin-top: 2px;
  flex-shrink: 0;
}

/* --- Checkbox row (terms) --- */
.auth-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

.auth-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4361ee;
  border-radius: 4px;
  cursor: pointer;
  margin-top: 2px;
  flex-shrink: 0;
}

.auth-check-row a {
  color: #4361ee;
  text-decoration: none;
  font-weight: 500;
}

.auth-check-row a:hover {
  text-decoration: underline;
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-terms-overlay[hidden] {
  display: none;
}

.auth-terms-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, .62);
  backdrop-filter: blur(3px);
}

.auth-terms-dialog {
  width: min(720px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #1f2937;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(15, 23, 42, .28);
}

.auth-terms-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.auth-terms-header h2 {
  margin: 0 0 4px;
  font-size: 17px;
  line-height: 1.5;
}

.auth-terms-header p {
  margin: 0;
  color: #6b7280;
  font-size: 12px;
}

.auth-terms-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #6b7280;
  background: #f3f4f6;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.auth-terms-content {
  overflow-y: auto;
  padding: 18px 22px;
  text-align: right;
  line-height: 1.9;
  scrollbar-gutter: stable;
}

.auth-terms-content h3 {
  margin: 20px 0 5px;
  font-size: 14px;
  color: #111827;
}

.auth-terms-content h3:first-of-type {
  margin-top: 14px;
}

.auth-terms-content p {
  margin: 0 0 8px;
  color: #4b5563;
  font-size: 13px;
}

.auth-terms-intro {
  padding: 10px 12px;
  background: #f5f7ff;
  border-right: 3px solid #4361ee;
  border-radius: 8px;
}

.auth-terms-footer {
  padding: 12px 20px;
  border-top: 1px solid #e5e7eb;
}

.auth-terms-done {
  min-width: 110px;
  height: 38px;
  padding: 0 16px;
  color: #fff;
  background: #4361ee;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

/* --- Optional field hint --- */
.auth-optional {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 400;
  margin-left: 4px;
}

[dir="rtl"] .auth-optional {
  margin-left: 0;
  margin-right: 4px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 480px) {
  .auth-card {
    padding: 32px 20px;
    border-radius: 12px;
  }

  .auth-brand {
    margin-bottom: 28px;
  }

  .auth-brand h1 {
    font-size: 18px;
  }

  .auth-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .auth-social {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .auth-card-register {
    max-width: 440px;
  }

  .auth-form-register .auth-fields {
    grid-template-columns: 1fr;
  }

  .auth-form-register .auth-field-full {
    grid-column: auto;
  }

  .auth-form-register .auth-btn-primary {
    width: 100%;
  }
}

/* ============================================================
   RTL SUPPORT
   ============================================================ */
[dir="rtl"] .auth-field input {
  text-align: right;
}

[dir="rtl"] .auth-error {
  text-align: right;
}

/* ============================================================
   DARK MODE SAFEGUARD (prefers-color-scheme)
   ============================================================ */
@media (prefers-color-scheme: dark) {
  .auth-page {
    background: #111827;
  }

  .auth-card {
    background: #1f2937;
    box-shadow:
      0 1px 3px rgba(0,0,0,.2),
      0 6px 24px rgba(0,0,0,.3);
  }

  .auth-brand h1 {
    color: #f9fafb;
  }

  .auth-brand p {
    color: #9ca3af;
  }

  .auth-field label {
    color: #e5e7eb;
  }

  .auth-field input {
    border-color: #374151;
    background: #111827;
    color: #f9fafb;
  }

  .auth-field input:focus {
    background: #1f2937;
  }

  .auth-remember,
  .auth-check-row {
    color: #9ca3af;
  }

  .auth-btn-secondary {
    border-color: #37451;
    background: #111827;
    color: #e5e7eb;
  }

  .auth-divider::before,
  .auth-divider::after {
    background: #374151;
  }

  .auth-nonfield-errors {
    background: #450a0a;
    border-color: #7f1d1d;
    color: #fca5a5;
  }

  .auth-terms-dialog {
    color: #e5e7eb;
    background: #1f2937;
    border-color: #374151;
  }

  .auth-terms-header,
  .auth-terms-footer {
    border-color: #374151;
  }

  .auth-terms-header h2,
  .auth-terms-content h3 {
    color: #f9fafb;
  }

  .auth-terms-header p,
  .auth-terms-content p {
    color: #cbd5e1;
  }

  .auth-terms-close {
    color: #cbd5e1;
    background: #374151;
  }

  .auth-terms-intro {
    background: #111827;
  }
}


/* 2026-09 liquid-glass auth polish */
.auth-page{
  --auth-accent:#6d5dfc;
  --auth-accent-2:#3978ff;
  --auth-ink:#172033;
  --auth-muted:#687386;
  isolation:isolate;
  min-height:100vh;
  background:
    radial-gradient(circle at 12% 10%,rgba(113,91,255,.18),transparent 30%),
    radial-gradient(circle at 88% 86%,rgba(57,120,255,.16),transparent 32%),
    linear-gradient(145deg,#f9faff 0%,#eef3ff 48%,#f8fbff 100%);
}
.auth-page::before{
  inset:-16%;
  background:
    radial-gradient(circle at 28% 20%,rgba(255,255,255,.94),transparent 24%),
    radial-gradient(circle at 72% 64%,rgba(120,190,255,.20),transparent 25%),
    radial-gradient(circle at 56% 14%,rgba(163,143,255,.18),transparent 22%);
  filter:blur(26px);
  opacity:.98;
}
.auth-page::after{
  content:'';
  position:absolute;
  z-index:0;
  width:250px;
  height:250px;
  top:7%;
  right:-85px;
  border:1px solid rgba(255,255,255,.72);
  border-radius:50%;
  background:linear-gradient(145deg,rgba(255,255,255,.70),rgba(107,92,255,.08));
  box-shadow:inset 0 1px 0 rgba(255,255,255,.95),0 30px 80px rgba(67,76,126,.10);
  pointer-events:none;
}
.auth-card{
  overflow:hidden;
  color:var(--auth-ink);
  background:linear-gradient(145deg,rgba(255,255,255,.72),rgba(255,255,255,.44));
  border:1px solid rgba(255,255,255,.72);
  border-radius:24px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.96),
    0 24px 70px rgba(48,61,108,.13),
    0 4px 16px rgba(48,61,108,.06);
  -webkit-backdrop-filter:blur(28px) saturate(155%);
  backdrop-filter:blur(28px) saturate(155%);
}
.auth-card::before{
  content:'';
  position:absolute;
  inset:0 0 auto;
  height:1px;
  background:linear-gradient(90deg,transparent,rgba(255,255,255,.98),transparent);
  pointer-events:none;
}
.auth-card-register{max-width:800px}
.auth-card-recovery{max-width:480px}
.auth-brand{margin-bottom:28px}
.auth-brand-logo{
  width:58px;
  height:58px;
  padding:7px;
  border-radius:18px;
  background:rgba(255,255,255,.52);
  border:1px solid rgba(255,255,255,.78);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.95),0 10px 26px rgba(59,68,116,.10);
  -webkit-backdrop-filter:blur(14px);
  backdrop-filter:blur(14px);
}
.auth-brand h1{color:var(--auth-ink);font-size:21px;letter-spacing:-.025em}
.auth-brand p{max-width:380px;text-align:center;color:#526074;line-height:1.8;font-weight:550}
.auth-kicker{
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin:0 0 9px;
  padding:5px 9px;
  border:1px solid rgba(109,93,252,.14);
  border-radius:999px;
  color:#5b50d8;
  background:rgba(109,93,252,.07);
  font-size:11px;
  font-weight:800;
}
.auth-stage{
  display:flex;
  align-items:flex-start;
  gap:9px;
  margin:-7px 0 21px;
  padding:11px 12px;
  border:1px solid rgba(109,93,252,.20);
  border-radius:13px;
  color:#40506a;
  background:rgba(255,255,255,.72);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.92),0 6px 18px rgba(64,80,106,.05);
  font-size:12.5px;
  font-weight:650;
  line-height:1.8;
}
.auth-stage i{margin-top:3px;color:#5b50d8}
.auth-field label{color:#394359;font-weight:700}
.auth-field input[type="text"],
.auth-field input[type="email"],
.auth-field input[type="password"],
.auth-field input[type="tel"],
.auth-field input[type="number"],
.auth-field select,
.auth-field textarea{
  width:100%;
  box-sizing:border-box;
  border:1px solid rgba(112,124,160,.20);
  border-radius:12px;
  color:var(--auth-ink);
  background:rgba(255,255,255,.46);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.78);
  outline:none;
  transition:border-color .16s ease,box-shadow .16s ease,background .16s ease,transform .16s ease;
  -webkit-backdrop-filter:blur(12px);
  backdrop-filter:blur(12px);
}
.auth-field select{height:46px;padding:0 12px}
.auth-field textarea{min-height:112px;padding:12px 14px;resize:vertical}
.auth-field input:focus,
.auth-field select:focus,
.auth-field textarea:focus{
  border-color:rgba(91,80,216,.46);
  background:rgba(255,255,255,.68);
  box-shadow:0 0 0 4px rgba(109,93,252,.09),inset 0 1px 0 rgba(255,255,255,.92);
}
.auth-btn-primary{
  border:1px solid rgba(255,255,255,.35);
  border-radius:12px;
  background:linear-gradient(135deg,#6557ee,#3f7cff);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.30),0 10px 24px rgba(81,86,220,.22);
}
.auth-btn-primary:hover:not(:disabled){
  background:linear-gradient(135deg,#5d50e5,#3974f2);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.34),0 12px 28px rgba(81,86,220,.28);
}
.auth-btn-secondary,
.auth-social-btn{
  border:1px solid rgba(255,255,255,.70);
  background:rgba(255,255,255,.38);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.82);
  -webkit-backdrop-filter:blur(12px);
  backdrop-filter:blur(12px);
}
.auth-btn-secondary:hover,.auth-social-btn:hover{
  border-color:rgba(109,93,252,.22);
  background:rgba(255,255,255,.62);
}
.auth-divider::before,.auth-divider::after{background:rgba(83,95,132,.16)}
.auth-remember,.auth-check-row,.auth-footer{color:var(--auth-muted)}
.auth-forgot,.auth-footer a,.auth-check-row a{color:#5b50d8}
.auth-nonfield-errors{
  background:rgba(254,242,242,.72);
  border-color:rgba(239,68,68,.20);
  -webkit-backdrop-filter:blur(12px);
  backdrop-filter:blur(12px);
}
.auth-messages{display:grid;gap:8px;margin-bottom:18px}
.auth-message{
  display:flex;
  align-items:flex-start;
  gap:8px;
  padding:11px 12px;
  border:1px solid rgba(22,163,74,.30);
  border-radius:12px;
  color:#14532d !important;
  background:rgba(220,252,231,.88);
  box-shadow:inset 0 1px 0 rgba(255,255,255,.80);
  font-size:12.5px;
  font-weight:700;
  line-height:1.8;
}
.auth-message i{margin-top:3px;color:#15803d;flex:0 0 auto}
.auth-message span{color:inherit !important;opacity:1 !important}
.auth-actions{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  flex-wrap:wrap;
  margin-top:18px;
  font-size:12px;
  color:var(--auth-muted);
}
.auth-actions a{color:#5b50d8;text-decoration:none;font-weight:700}
.auth-actions a:hover{text-decoration:underline}
.auth-code-input{letter-spacing:.32em;text-align:center!important;font-size:18px!important;font-weight:800}
[dir="rtl"] .auth-code-input{direction:ltr}

@media(max-width:480px){
  .auth-card{padding:28px 18px;border-radius:20px}
  .auth-card-register{padding:26px 18px}
  .auth-page::after{width:180px;height:180px;right:-90px}
}

@media(prefers-color-scheme:dark){
  .auth-page{
    background:
      radial-gradient(circle at 12% 10%,rgba(113,91,255,.18),transparent 30%),
      radial-gradient(circle at 88% 86%,rgba(57,120,255,.13),transparent 32%),
      linear-gradient(145deg,#121625 0%,#161b2e 48%,#111827 100%);
  }
  .auth-card{
    color:#f4f6fb;
    background:linear-gradient(145deg,rgba(31,41,55,.76),rgba(22,28,43,.58));
    border-color:rgba(255,255,255,.10);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.08),0 24px 70px rgba(0,0,0,.28);
  }
  .auth-brand h1{color:#f8fafc}
  .auth-brand p,.auth-remember,.auth-check-row,.auth-footer{color:#c4ccda}
  .auth-stage{color:#d7deea;background:rgba(15,23,42,.58);border-color:rgba(129,113,255,.28)}
  .auth-field label{color:#d7dce6}
  .auth-field input[type="text"],
  .auth-field input[type="email"],
  .auth-field input[type="password"],
  .auth-field input[type="tel"],
  .auth-field input[type="number"],
  .auth-field select,
  .auth-field textarea{
    color:#f8fafc;
    border-color:rgba(255,255,255,.10);
    background:rgba(15,23,42,.44);
    box-shadow:inset 0 1px 0 rgba(255,255,255,.04);
  }
  .auth-btn-secondary,.auth-social-btn{color:#e7ebf3;background:rgba(15,23,42,.35);border-color:rgba(255,255,255,.10)}
  .auth-message{color:#dcfce7 !important;background:rgba(20,83,45,.72);border-color:rgba(74,222,128,.32)}
}
