/* ==========================================================================
   Authentication pages (sign in, register, forgot / reset password, verify email)
   Standalone layout, design modelled on the Nexora auth screens and adapted to
   the DevOS tokens:
   - >= 992px : gradient brand showcase (left) + form card (right)
   - <  992px : colourful gradient band at the top, form card overlapping it
   Light and dark themes are supported through the design tokens.
   ========================================================================== */

.auth-body {
  --auth-grad: linear-gradient(140deg, #4f46e5 0%, #7c3aed 48%, #c026d3 100%);
  --auth-ease: cubic-bezier(0.22, 1, 0.36, 1);
  min-height: 100vh;
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(124, 58, 237, 0.09), transparent 60%),
    radial-gradient(700px 420px at 0% 100%, rgba(13, 148, 136, 0.08), transparent 60%),
    var(--dv-bg);
}
:root[data-bs-theme="dark"] .auth-body {
  background:
    radial-gradient(900px 520px at 100% 0%, rgba(124, 58, 237, 0.16), transparent 60%),
    radial-gradient(700px 420px at 0% 100%, rgba(45, 212, 191, 0.08), transparent 60%),
    var(--dv-bg);
}
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }

/* ---------------------------------------------------------------- Showcase (left) */
.auth-aside {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 2.5rem clamp(2rem, 4vw, 3.5rem);
  color: #fff;
  background: var(--auth-grad);
  overflow: hidden;
  isolation: isolate;
}
/* Glow orbs (slow drift) */
.auth-aside::before,
.auth-aside::after {
  content: "";
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  pointer-events: none;
  animation: auth-drift 16s ease-in-out infinite alternate;
}
.auth-aside::before { width: 540px; height: 540px; right: -190px; top: -210px; background: radial-gradient(circle, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 70%); }
.auth-aside::after { width: 460px; height: 460px; left: -170px; bottom: -190px; background: radial-gradient(circle, rgba(45, 212, 191, 0.42), rgba(45, 212, 191, 0) 70%); animation-delay: -8s; }
@keyframes auth-drift { from { transform: translate3d(0, 0, 0) scale(1); } to { transform: translate3d(24px, 18px, 0) scale(1.08); } }

.auth-brand, .auth-brand:hover { color: #fff; }
.auth-aside .brand-mark { background: rgba(255, 255, 255, 0.2); border: 1px solid rgba(255, 255, 255, 0.35); box-shadow: 0 8px 20px -10px rgba(15, 23, 42, 0.5); }
.auth-aside .brand-name { color: #fff; font-size: var(--dv-fs-lg); }
.auth-aside .brand-name span { color: #fde68a; }
.auth-aside .brand-sub { color: rgba(255, 255, 255, 0.78); }

.auth-showcase-body { margin: auto 0; padding: 2rem 0; }
.auth-headline { color: #fff; font-size: clamp(1.75rem, 2.4vw, 2.4rem); font-weight: var(--dv-fw-bold); letter-spacing: -0.025em; line-height: 1.2; max-width: 22ch; margin-bottom: 0.85rem; }
.auth-lead { color: rgba(255, 255, 255, 0.86); font-size: var(--dv-fs-md); max-width: 48ch; margin-bottom: 1.75rem; }
.auth-illustration {
  display: block;
  width: 100%;
  max-width: 500px;
  height: auto;
  margin: 0 0 1.75rem;
  filter: drop-shadow(0 24px 40px rgba(30, 27, 75, 0.35));
  animation: auth-float 6s ease-in-out infinite;
}
.auth-illustration .ai-float-a { animation: auth-float 5s ease-in-out infinite; animation-delay: -1s; }
.auth-illustration .ai-float-b { animation: auth-float 7s ease-in-out infinite; animation-delay: -3s; }
.auth-illustration .ai-float-c { animation: auth-float 6s ease-in-out infinite; animation-delay: -2s; }
@keyframes auth-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.auth-features { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; max-width: 540px; list-style: none; padding: 0; margin: 0; }
.auth-features li {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: var(--dv-fs-sm);
  font-weight: var(--dv-fw-medium);
  transition: background-color 0.3s var(--auth-ease), transform 0.3s var(--auth-ease);
}
.auth-features li:hover { background: rgba(255, 255, 255, 0.2); transform: translateY(-2px); }
.auth-features .bi { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; background: rgba(255, 255, 255, 0.2); font-size: 0.85rem; }

.auth-aside-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; font-size: var(--dv-fs-xs); color: rgba(255, 255, 255, 0.82); }
.auth-aside-badge { display: inline-flex; align-items: center; gap: 8px; }
.auth-aside-badge .status-dot { background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.3); }

/* ---------------------------------------------------------------- Form panel (right) */
.auth-main { display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 2.5rem; min-width: 0; }
.auth-card {
  width: 100%;
  max-width: 460px;
  padding: 2.25rem 2rem;
  border: 1px solid var(--dv-border);
  border-radius: 20px;
  background: var(--dv-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 24px 48px -24px rgba(15, 23, 42, 0.25);
  animation: auth-rise 0.6s var(--auth-ease) both;
}
:root[data-bs-theme="dark"] .auth-card { box-shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.7); }
@keyframes auth-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.auth-mobile-brand { display: none; justify-content: center; margin-bottom: 1.5rem; }
.auth-mobile-brand .brand-name { color: var(--dv-text); font-size: var(--dv-fs-lg); font-weight: var(--dv-fw-bold); }

.auth-card .auth-title { font-size: 1.6rem; font-weight: var(--dv-fw-bold); letter-spacing: -0.02em; margin-bottom: 0.35rem; }
.auth-card .auth-subtitle { color: var(--dv-muted); margin-bottom: 1.75rem; }
.auth-card .auth-subtitle strong { color: var(--dv-text); }
.auth-card .form-label { font-weight: var(--dv-fw-semibold); }
.auth-label-row { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.auth-label-row a { font-size: var(--dv-fs-xs); font-weight: var(--dv-fw-semibold); margin-bottom: 0.375rem; }
.auth-card .btn-lg { width: 100%; }
.auth-card .form-control-lg { border-radius: 12px; }

/* Inputs with a leading icon (Nexora pattern). The icon is centred on the 44px input, so
   validation messages below never move it. */
.input-icon { position: relative; }
.input-icon > .ii-start {
  position: absolute;
  left: 0.95rem;
  top: calc(var(--dv-control-h-lg) / 2);
  transform: translateY(-50%);
  z-index: 4;
  color: var(--dv-muted);
  pointer-events: none;
  font-size: 1rem;
  line-height: 1;
  transition: color var(--dv-transition);
}
.input-icon > .form-control { padding-left: 2.65rem; }
.input-icon:focus-within > .ii-start { color: var(--dv-primary-text); }
.input-icon > .form-control.is-invalid ~ .ii-start, .input-icon > .ii-start:has(~ .form-control.is-invalid) { color: var(--dv-danger); }
/* Password fields: the toggle sits inside the input (components.css .password-field) */
.password-field.input-icon > .password-toggle { right: 6px; }
.password-field.input-icon > .password-toggle:hover { color: var(--dv-primary-text); background: var(--dv-primary-subtle); }

/* Gradient primary button */
.btn-gradient {
  border: 0;
  color: #fff;
  background: var(--auth-grad, linear-gradient(140deg, #4f46e5, #7c3aed 48%, #c026d3));
  background-size: 160% 160%;
  background-position: 0 0;
  box-shadow: 0 12px 24px -12px rgba(79, 70, 229, 0.6);
  transition: background-position 0.5s var(--dv-ease), transform 0.25s var(--dv-ease), box-shadow 0.25s var(--dv-ease);
}
.btn-gradient:hover, .btn-gradient:focus-visible { color: #fff; background-position: 100% 0; transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(124, 58, 237, 0.65); }
.btn-gradient:active { color: #fff; transform: none; }
.btn-gradient:disabled { color: #fff; opacity: 0.75; }
.btn-gradient .bi { transition: transform 0.25s var(--dv-ease); }
.btn-gradient:hover .bi-arrow-right { transform: translateX(3px); }

.auth-divider { display: flex; align-items: center; gap: var(--dv-space-3); color: var(--dv-muted); font-size: var(--dv-fs-xs); margin: 1.5rem 0 1rem; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--dv-border); }
.auth-footer-text { text-align: center; color: var(--dv-muted); margin-top: 1.5rem; margin-bottom: 0; font-size: var(--dv-fs-sm); }
.auth-footer-text a { font-weight: var(--dv-fw-semibold); }
.auth-legal { max-width: 460px; margin: 1.5rem 0 0; text-align: center; color: var(--dv-muted); font-size: var(--dv-fs-xs); }

/* Password strength meter */
.password-meter { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-top: 0.6rem; }
.password-meter span { height: 5px; border-radius: 5px; background: var(--dv-surface-3); transition: background-color 0.25s var(--dv-ease); }
.password-meter[data-score="1"] span:nth-child(-n+1) { background: var(--dv-danger); }
.password-meter[data-score="2"] span:nth-child(-n+2) { background: var(--dv-warning); }
.password-meter[data-score="3"] span:nth-child(-n+3) { background: var(--dv-info); }
.password-meter[data-score="4"] span { background: var(--dv-success); }

/* OTP (verify email) */
.otp-inputs { display: flex; gap: var(--dv-space-2); justify-content: space-between; }
.otp-inputs .form-control { text-align: center; font-size: var(--dv-fs-xl); font-weight: var(--dv-fw-bold); padding: 0; height: 56px; border-radius: 12px; transition: border-color var(--dv-transition), box-shadow var(--dv-transition), transform var(--dv-transition); }
.otp-inputs .form-control:focus { transform: translateY(-2px); }

/* Status icon (forgot / verify / success states) */
.auth-status-icon {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0.5rem auto 1.5rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 1.75rem;
  color: #fff;
  background: var(--auth-grad);
  box-shadow: 0 14px 28px -12px rgba(124, 58, 237, 0.6);
}
.auth-status-icon::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px dashed rgba(124, 58, 237, 0.35); animation: auth-spin 18s linear infinite; }
@keyframes auth-spin { to { transform: rotate(360deg); } }
.auth-status-icon ~ .auth-title, .auth-status-icon ~ .auth-subtitle { text-align: center; }

.auth-theme-toggle { position: fixed; top: var(--dv-space-4); right: var(--dv-space-4); z-index: 10; background: var(--dv-surface); border: 1px solid var(--dv-border) !important; box-shadow: var(--dv-shadow-sm); }

/* ---------------------------------------------------------------- Responsive */
@media (min-width: 1400px) { .auth-shell { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); } }
/* Short laptop screens: keep the showcase compact */
@media (max-height: 760px) and (min-width: 992px) {
  .auth-illustration { max-width: 360px; margin-bottom: 1.25rem; }
  .auth-features { display: none; }
}
/* Tablet & phone: no showcase - a gradient band at the top with the card overlapping it */
@media (max-width: 991.98px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .auth-mobile-brand { display: flex; }
  /* Gradient band with its glow orbs painted as background layers, so nothing extends past
     the viewport edge (no horizontal scroll). */
  .auth-body::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 240px;
    background:
      radial-gradient(260px 220px at 100% 0%, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0) 70%),
      radial-gradient(240px 200px at 0% 100%, rgba(45, 212, 191, 0.38), rgba(45, 212, 191, 0) 70%),
      var(--auth-grad);
    border-radius: 0 0 32px 32px;
    z-index: 0;
    pointer-events: none;
  }
  .auth-shell { position: relative; z-index: 1; }
  .auth-main { justify-content: flex-start; padding: 4.5rem 1.5rem 2rem; }
  .auth-theme-toggle { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; background: rgba(255, 255, 255, 0.18); border-color: rgba(255, 255, 255, 0.35) !important; box-shadow: none; }
  .auth-theme-toggle:hover { background: rgba(255, 255, 255, 0.28); }
}
@media (max-width: 575.98px) {
  .auth-main { padding: 4rem 0.85rem 1.5rem; }
  .auth-card { padding: 1.6rem 1.15rem; border-radius: 16px; }
  .auth-card .auth-title { font-size: 1.35rem; }
  .auth-body::before { height: 210px; border-radius: 0 0 24px 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-aside::before, .auth-aside::after, .auth-illustration, .auth-illustration g, .auth-status-icon::before { animation: none; }
  .auth-card { animation: none; }
}
