/* =========================================================
 * Trade Logik — Auth Pages (Login, Forgot, Reset, Change)
 * Modern, clean, professional design with brand identity
 * ========================================================= */

@import url('https://rsms.me/inter/inter.css');

:root {
  --tblr-font-sans-serif: 'Inter Var', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
  --auth-primary: var(--tblr-primary, #206bc4);
  --auth-primary-rgb: 32, 107, 196;
  --auth-primary-light: color-mix(in oklab, var(--auth-primary) 12%, white);
  --auth-primary-glow: color-mix(in oklab, var(--auth-primary) 35%, transparent);
  --auth-bg: #f0f4fa;
  --auth-bg-top: #dce8f8;
  --auth-surface: #ffffff;
  --auth-surface-border: rgba(0,0,0,.06);
  --auth-text: #1e293b;
  --auth-text-muted: #64748b;
  --auth-card-shadow: 0 1px 3px rgba(0,0,0,.04), 0 8px 32px rgba(0,0,0,.08);
  --auth-card-radius: 20px;
  --auth-input-radius: 12px;
  --auth-transition: .2s cubic-bezier(.22,.61,.36,1);
}

[data-bs-theme="dark"] {
  --auth-bg: #0c0f17;
  --auth-bg-top: #101828;
  --auth-surface: #161b26;
  --auth-surface-border: rgba(255,255,255,.06);
  --auth-text: #f1f5f9;
  --auth-text-muted: #94a3b8;
  --auth-card-shadow: 0 1px 3px rgba(0,0,0,.12), 0 12px 40px rgba(0,0,0,.3);
  --auth-primary-light: color-mix(in oklab, var(--auth-primary) 15%, #161b26);
}

html, body {
  height: 100%;
}

body {
  font-feature-settings: "cv03", "cv04", "cv11";
  color: var(--auth-text);
}

/* ── Full-page gradient background ── */
body.auth-page {
  background:
    linear-gradient(175deg, var(--auth-bg-top) 0%, var(--auth-bg) 35%, var(--auth-bg) 100%);
  background-attachment: fixed;
}

body.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 700px 500px at 10% 0%, rgba(var(--auth-primary-rgb), .12), transparent 65%),
    radial-gradient(ellipse 500px 400px at 90% 100%, rgba(var(--auth-primary-rgb), .06), transparent 60%);
  pointer-events: none;
}

body.d-flex {
  min-height: 100vh;
  min-height: 100dvh;
}

.page.page-center {
  flex: 1 0 auto;
  min-height: auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* ── Container ── */
.auth-page .container-tight {
  max-width: 420px;
  width: 100%;
  padding: 1.5rem 1rem;
}

/* ── Logo area ── */
.auth-logo {
  display: block;
  text-decoration: none;
}

.auth-logo img {
  max-height: 48px;
  width: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,.08));
  transition: transform var(--auth-transition);
}

.auth-logo:hover img {
  transform: scale(1.03);
}

.auth-powered {
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--auth-text-muted);
  margin-top: .4rem;
  opacity: .55;
}

/* ── Card ── */
.auth-card {
  background: var(--auth-surface);
  border: 1px solid var(--auth-surface-border);
  border-radius: var(--auth-card-radius);
  box-shadow: var(--auth-card-shadow);
  padding: 1.75rem 1.5rem 1.5rem;
  animation: auth-card-in .4s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(10px) scale(.995); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

.auth-card-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--auth-text);
  letter-spacing: -.01em;
  margin-bottom: 1.25rem;
}

/* ── Form controls ── */
.auth-card .form-label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--auth-text);
  letter-spacing: .01em;
  margin-bottom: .3rem;
}

.auth-card .form-control {
  border-radius: var(--auth-input-radius);
  padding: .65rem .9rem;
  font-size: .88rem;
  border: 1.5px solid rgba(0,0,0,.1);
  background: var(--auth-surface);
  transition: border-color var(--auth-transition), box-shadow var(--auth-transition);
}

.auth-card .form-control::placeholder {
  color: var(--auth-text-muted);
  opacity: .5;
}

.auth-card .form-control:focus {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 3px var(--auth-primary-light);
}

.auth-card .input-group-flat {
  border-radius: var(--auth-input-radius);
  display: flex;
  flex-wrap: nowrap;
}

.auth-card .input-group-flat .form-control {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  min-width: 0;
}

.auth-card .input-group-flat .input-group-text {
  border-radius: 0 var(--auth-input-radius) var(--auth-input-radius) 0;
  border: 1.5px solid rgba(0,0,0,.1);
  border-left: 0;
  background: var(--auth-surface);
  display: flex;
  align-items: center;
  flex-shrink: 0;
  padding: .65rem .75rem;
}

/* ── Primary button ── */
.auth-card .btn-primary {
  border-radius: var(--auth-input-radius);
  padding: .7rem 1.25rem;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: .01em;
  border: none;
  background: var(--auth-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 2px 8px rgba(var(--auth-primary-rgb), .25);
  transition: transform var(--auth-transition), box-shadow var(--auth-transition), background var(--auth-transition);
}

.auth-card .btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,.12), 0 4px 16px rgba(var(--auth-primary-rgb), .3);
}

.auth-card .btn-primary:active {
  transform: translateY(0) scale(.99);
}

/* ── Auth links ── */
.auth-card .form-check-label,
.auth-card a {
  font-size: .82rem;
}

.auth-card .form-check-label {
  color: var(--auth-text-muted);
}

.auth-card-footer {
  text-align: center;
  color: var(--auth-text-muted);
  font-size: .82rem;
  margin-top: 1rem;
  padding-top: .75rem;
  border-top: 1px solid var(--auth-surface-border);
}

.auth-card-footer a {
  font-weight: 600;
  color: var(--auth-primary);
  text-decoration: none;
}

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

/* ── Auth alerts (modern inline toast style) ── */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: .65rem;
  padding: .75rem 1rem;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.45;
  margin-bottom: .75rem;
  border: 1px solid transparent;
  animation: auth-alert-in .3s ease both;
  position: relative;
}

@keyframes auth-alert-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  margin-top: 1px;
}

.auth-alert-content {
  flex: 1;
  min-width: 0;
}

.auth-alert-title {
  font-weight: 700;
  font-size: .84rem;
  margin-bottom: .1rem;
}

.auth-alert-text {
  font-size: .8rem;
  opacity: .85;
}

.auth-alert .btn-close {
  position: absolute;
  top: .5rem;
  right: .5rem;
  font-size: .55rem;
  opacity: .5;
  padding: .35rem;
}

.auth-alert .btn-close:hover {
  opacity: 1;
}

/* Success */
.auth-alert-success {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}
.auth-alert-success .auth-alert-icon {
  background: #10b981;
  color: #fff;
}

[data-bs-theme="dark"] .auth-alert-success {
  background: rgba(16, 185, 129, .1);
  border-color: rgba(16, 185, 129, .2);
  color: #6ee7b7;
}

/* Info */
.auth-alert-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}
.auth-alert-info .auth-alert-icon {
  background: #3b82f6;
  color: #fff;
}

[data-bs-theme="dark"] .auth-alert-info {
  background: rgba(59, 130, 246, .1);
  border-color: rgba(59, 130, 246, .2);
  color: #93c5fd;
}

/* Warning */
.auth-alert-warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}
.auth-alert-warning .auth-alert-icon {
  background: #f59e0b;
  color: #fff;
}

[data-bs-theme="dark"] .auth-alert-warning {
  background: rgba(245, 158, 11, .1);
  border-color: rgba(245, 158, 11, .2);
  color: #fcd34d;
}

/* Danger / Error */
.auth-alert-danger,
.auth-alert-error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.auth-alert-danger .auth-alert-icon,
.auth-alert-error .auth-alert-icon {
  background: #ef4444;
  color: #fff;
}

[data-bs-theme="dark"] .auth-alert-danger,
[data-bs-theme="dark"] .auth-alert-error {
  background: rgba(239, 68, 68, .1);
  border-color: rgba(239, 68, 68, .2);
  color: #fca5a5;
}

/* ── Password pattern (modern 7x7 grid with glow effects) ── */
.pw-brand-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: .75rem 1rem;
  background: color-mix(in oklab, var(--auth-surface) 85%, transparent);
  border: 1px solid var(--auth-surface-border);
  border-radius: 16px;
  margin-top: .75rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.pw-brand-title {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--auth-text-muted);
  margin-bottom: .4rem;
  opacity: .7;
}

.pw-brand-help {
  font-size: .65rem;
  color: var(--auth-text-muted);
  margin-top: .4rem;
  text-align: center;
  max-width: 200px;
  line-height: 1.4;
  opacity: .65;
}

/* Pattern grid */
.pw-pattern {
  width: 64px;
  height: 64px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 1.5px;
  border-radius: 12px;
  padding: 4px;
  background: color-mix(in oklab, var(--auth-primary) 4%, var(--auth-bg));
  border: 1px solid rgba(0,0,0,.04);
  box-shadow:
    0 1px 4px rgba(0,0,0,.04),
    inset 0 1px 2px rgba(0,0,0,.02);
  transition: box-shadow .3s ease, border-color .3s ease;
}

.pw-pattern:not(.pw-pattern-empty) {
  border-color: rgba(var(--auth-primary-rgb), .15);
  box-shadow:
    0 1px 4px rgba(0,0,0,.04),
    0 0 20px -4px rgba(var(--auth-primary-rgb), .2);
}

.pw-cell {
  border-radius: 1.5px;
  background: rgba(0,0,0,.04);
  transition: all .18s cubic-bezier(.22,.61,.36,1);
}

.pw-cell--on {
  background: var(--auth-primary);
  box-shadow: 0 0 4px rgba(var(--auth-primary-rgb), .35);
  border-radius: 2px;
  animation: pw-cell-pop .2s cubic-bezier(.22,.61,.36,1) both;
}

@keyframes pw-cell-pop {
  0%   { transform: scale(.4); opacity: 0; }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.pw-pattern-empty .pw-cell {
  background: rgba(0,0,0,.03);
  box-shadow: none;
}

/* Color variation for active cells based on data-hue */
.pw-cell--on[data-hue="1"] { background: color-mix(in oklch, var(--auth-primary) 100%, oklch(.7 .15 30)); }
.pw-cell--on[data-hue="2"] { background: color-mix(in oklch, var(--auth-primary) 85%, oklch(.65 .18 280)); }
.pw-cell--on[data-hue="3"] { background: color-mix(in oklch, var(--auth-primary) 70%, oklch(.7 .15 160)); }

/* ── Password requirements (modern) ── */
.auth-requirements {
  padding: .65rem .85rem;
  background: color-mix(in oklab, var(--auth-primary) 3%, var(--auth-surface));
  border: 1px solid var(--auth-surface-border);
  border-radius: 14px;
  margin-bottom: 1rem;
}

.auth-requirements .form-label {
  font-size: .72rem;
  font-weight: 700;
  color: var(--auth-text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .4rem;
}

.auth-requirements ul {
  margin-bottom: .65rem;
}

.auth-requirements li {
  padding: .15rem 0;
  font-size: .78rem;
  transition: color var(--auth-transition);
}

.auth-requirements .status-dot {
  width: 7px;
  height: 7px;
  transition: background var(--auth-transition), box-shadow var(--auth-transition);
}

.auth-requirements li.text-success .status-dot {
  box-shadow: 0 0 5px rgba(47,179,68,.3);
}

.auth-requirements .progress {
  height: 3px;
  border-radius: 99px;
  background: rgba(0,0,0,.06);
}

.auth-requirements .progress-bar {
  border-radius: 99px;
  transition: width .3s ease, background-color .3s ease;
}

/* ── Password toggle ── */
.password-toggle {
  cursor: pointer;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--auth-primary);
  user-select: none;
  transition: opacity var(--auth-transition);
}

.password-toggle:hover {
  opacity: .7;
}

/* ── Description block for non-login auth pages ── */
.auth-description {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: .6rem 1rem;
  background: color-mix(in oklab, var(--auth-surface) 85%, transparent);
  border: 1px solid var(--auth-surface-border);
  border-radius: 14px;
  margin-top: .75rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.auth-description-title {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--auth-text-muted);
  margin-bottom: .2rem;
  opacity: .7;
}

.auth-description-text {
  font-size: .76rem;
  color: var(--auth-text-muted);
  text-align: center;
  max-width: 270px;
  line-height: 1.45;
}

/* ── Footer override for auth pages ── */
.auth-page .footer {
  opacity: .4;
  font-size: .72rem;
  border: none;
}

.auth-page .footer .container-xl {
  padding: .5rem 1rem;
}

/* ── Mobile / PWA optimizations ── */
@media (max-width: 480px) {
  .auth-page .container-tight {
    padding: .75rem .75rem;
  }

  .auth-card {
    padding: 1.5rem 1.25rem 1.25rem;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 20px rgba(0,0,0,.06);
  }

  .auth-card-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }

  .auth-card .form-control {
    padding: .7rem .85rem;
    font-size: .88rem;
  }

  .auth-card .btn-primary {
    padding: .75rem 1rem;
    font-size: .92rem;
  }

  .pw-brand-block {
    padding: .6rem .75rem;
  }

  .pw-pattern {
    width: 56px;
    height: 56px;
    border-radius: 10px;
    padding: 3px;
  }

  .pw-brand-help {
    font-size: .6rem;
    max-width: 180px;
  }

  .auth-description {
    padding: .5rem .85rem;
  }

  .auth-description-text {
    font-size: .72rem;
    max-width: 240px;
  }

  .auth-alert {
    padding: .6rem .75rem;
    border-radius: 12px;
    font-size: .8rem;
  }

  .auth-requirements {
    padding: .55rem .7rem;
  }

  .auth-requirements li {
    font-size: .74rem;
  }
}

/* PWA standalone — hide footer, use full height */
@media (display-mode: standalone) {
  .auth-page .footer {
    display: none !important;
  }

  .auth-page .page.page-center {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .auth-card { animation: none; }
  .pw-cell--on { animation: none; }
  .pw-pattern, .pw-cell { transition: none; }
  .auth-alert { animation: none; }
}

/* ── Page transitions (for auth pages that don't load app.css) ── */

/* Modern browsers: cross-document view transitions */
@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: .18s cubic-bezier(.4, 0, 1, 1) both vt-fade-out;
  mix-blend-mode: normal;
}
::view-transition-new(root) {
  animation: .22s cubic-bezier(0, 0, .2, 1) both vt-fade-in;
  mix-blend-mode: normal;
}

::view-transition-image-pair(root) {
  isolation: auto;
}

@keyframes vt-fade-out {
  from { opacity: 1; }
  to   { opacity: 0; }
}
@keyframes vt-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Fallback for browsers without View Transitions API */
body.page-leaving {
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease-out;
}

body.page-entering {
  animation: page-fade-in .2s ease-out both;
}

@keyframes page-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
}
