/* =========================================================
   Login page: sign in, forced password change, forgot password.
   Load AFTER app.css.
   ========================================================= */

:root {
  --auth-slide: cubic-bezier(.77, 0, .18, 1);
  --auth-ease: cubic-bezier(.2, .8, .2, 1);
  --auth-speed: .7s;
  --auth-danger: #c4320a;
}

/* ---------- Card ---------- */
.auth-card {
  position: relative;
  animation: authCardIn .7s var(--auth-ease) both;
}

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

@media (min-width: 768px) {
  .auth-card {
    /* minmax(0, …) keeps both halves exactly equal so the panel slides cleanly */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    min-height: 640px;
  }
}

/* ---------- Form panes ---------- */
.auth-pane {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 2.75rem;
  background: var(--surface);
  transition: transform var(--auth-speed) var(--auth-slide), opacity .35s ease;
}

.auth-pane--signin { z-index: 2; }

.auth-card.was-switched[data-mode="signin"] .auth-pane--signin {
  animation: authPaneShow var(--auth-speed) both;
}

/* ---------- Forms ---------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: .9rem;
}
.auth-form.is-shaking { animation: authShake .4s ease; }

.auth-head { margin-bottom: .25rem; }
.auth-eyebrow {
  display: block;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--gold-600);
}
.auth-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--brand-900);
  margin: .15rem 0 .2rem;
  letter-spacing: -.01em;
}
.auth-sub {
  color: var(--ink-muted);
  font-size: .9rem;
  margin: 0;
}

/* ---------- Floating-label fields ---------- */
.auth-field { position: relative; }

.auth-input {
  width: 100%;
  height: 52px;
  padding: 18px 44px 4px 42px;
  font-size: .95rem;
  color: var(--ink);
  background: #fcfbf9;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  transition: border-color .2s, box-shadow .2s, background-color .2s;
}
.auth-input:hover { border-color: #d6cbbf; }
.auth-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand-600);
  box-shadow: 0 0 0 4px rgba(224, 165, 38, .18);
}

.auth-field label {
  position: absolute;
  left: 42px;
  top: 26px;
  transform: translateY(-50%);
  font-size: .95rem;
  color: var(--ink-muted);
  pointer-events: none;
  white-space: nowrap;
  transition: top .2s var(--auth-ease), font-size .2s var(--auth-ease), color .2s, letter-spacing .2s;
}
.auth-input:focus + label,
.auth-input:not(:placeholder-shown) + label {
  top: 15px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--brand-700);
}

.auth-field-icon {
  position: absolute;
  left: 15px;
  top: 26px;
  transform: translateY(-50%);
  color: #a39689;
  font-size: 1rem;
  transition: color .2s, transform .2s var(--auth-ease);
  pointer-events: none;
}
.auth-field:focus-within .auth-field-icon {
  color: var(--brand-700);
  transform: translateY(-50%) scale(1.1);
}

.auth-eye {
  position: absolute;
  right: 6px;
  top: 6px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-muted);
  transition: background-color .2s, color .2s;
}
.auth-eye:hover { background: var(--brand-50); color: var(--brand-700); }
.auth-eye:focus-visible { outline: 2px solid var(--gold-500); outline-offset: 1px; }

.auth-field-error {
  display: none;
  margin: .3rem 0 0 .25rem;
  font-size: .75rem;
  font-weight: 500;
  color: var(--auth-danger);
}

.was-validated .auth-input:invalid {
  border-color: var(--auth-danger);
  background: #fffaf9;
}
.was-validated .auth-input:invalid:focus { box-shadow: 0 0 0 4px rgba(196, 50, 10, .12); }
.was-validated .auth-input:invalid + label { color: var(--auth-danger); }
.was-validated .auth-input:invalid ~ .auth-field-icon { color: var(--auth-danger); }
.was-validated .auth-input:invalid ~ .auth-field-error {
  display: block;
  animation: authFadeDown .2s ease both;
}
.was-validated .auth-input:valid { border-color: #a9d3b8; }

.auth-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}

/* ---------- Links ---------- */
.auth-link {
  position: relative;
  padding: 0;
  border: 0;
  background: none;
  font-size: .85rem;
  font-weight: 700;
  color: var(--brand-700);
}
.auth-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  border-radius: 2px;
  background: var(--gold-500);
  transform: scaleX(0);
  transform-origin: right;
  transition: transform .3s var(--auth-ease);
}
.auth-link:hover::after,
.auth-link:focus-visible::after {
  transform: scaleX(1);
  transform-origin: left;
}
.auth-link:focus-visible { outline: none; }

.auth-back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-left: -.35rem;
  padding: .3rem .65rem .3rem .4rem;
  border: 0;
  border-radius: 8px;
  background: none;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink-muted);
  transition: background-color .2s, color .2s;
}
.auth-back .bi { transition: transform .25s var(--auth-ease); }
.auth-back:hover { background: var(--brand-50); color: var(--brand-700); }
.auth-back:hover .bi { transform: translateX(-3px); }

.auth-hint {
  display: flex;
  align-items: center;
  gap: .4rem;
  margin: 0;
  font-size: .8rem;
  color: var(--ink-muted);
}

/* ---------- Buttons ---------- */
.auth-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  width: 100%;
  min-height: 50px;
  padding: 0 1.25rem;
  border-radius: 12px;
  font-size: .95rem;
  font-weight: 700;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform .2s var(--auth-ease), box-shadow .25s var(--auth-ease),
              background-color .25s, border-color .25s, color .25s;
}

.auth-btn--primary {
  border: 0;
  color: #fff;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-800));
  box-shadow: 0 8px 18px -10px rgba(122, 31, 31, .75), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.auth-btn--primary:hover {
  box-shadow: 0 14px 26px -12px rgba(122, 31, 31, .75), 0 0 0 4px rgba(224, 165, 38, .2), inset 0 1px 0 rgba(255, 255, 255, .15);
}

/* lift, press, icon nudge */
.auth-btn:hover { transform: translateY(-2px); }
.auth-btn:active { transform: translateY(0) scale(.98); transition-duration: .06s; }
.auth-btn .bi { transition: transform .25s var(--auth-ease); }
.auth-btn:hover .bi-arrow-right,
.auth-btn:hover .bi-box-arrow-in-right { transform: translateX(4px); }
.auth-btn:hover .bi-arrow-left { transform: translateX(-4px); }

/* shine sweep */
.auth-btn::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -60%;
  width: 45%;
  z-index: -1;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .35), transparent);
  transform: skewX(-20deg);
  transition: left .65s var(--auth-ease);
  pointer-events: none;
}
.auth-btn:hover::before { left: 120%; }

.auth-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--gold-500);
}

/* loading state */
.auth-btn.is-loading { pointer-events: none; }
.auth-btn.is-loading .auth-btn-label,
.auth-btn.is-loading .bi { opacity: .55; }
.auth-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: authSpin .7s linear infinite;
}

/* click ripple */
.auth-ripple {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  background: currentColor;
  opacity: .22;
  transform: scale(0);
  animation: authRipple .6s ease-out forwards;
}

/* ---------- Notices ---------- */
.auth-notice {
  display: flex;
  gap: .6rem;
  align-items: flex-start;
  padding: .7rem .85rem;
  border-radius: 10px;
  border-left: 4px solid var(--gold-500);
  background: var(--gold-100);
  color: #5a3f06;
  font-size: .84rem;
  line-height: 1.4;
  animation: authFadeDown .3s var(--auth-ease) both;
}
.auth-notice[hidden] { display: none; }
.auth-notice[data-tone="danger"] { border-color: var(--auth-danger); background: #fef3f2; color: #912018; }
.auth-notice[data-tone="success"] { border-color: #2e8b57; background: #ecf7f0; color: #1d5c39; }

#signInError {
  border: 0;
  border-left: 4px solid var(--auth-danger);
  border-radius: 10px;
  font-size: .85rem;
}

/* ---------- Forgot password view ---------- */
.auth-views {
  display: grid;
  margin: -6px;
  padding: 6px;
  overflow: hidden;
}
.auth-view {
  grid-area: 1 / 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform .55s var(--auth-ease), opacity .3s ease, visibility 0s;
}
.auth-views[data-view="signin"] .auth-view--forgot,
.auth-views[data-view="forgot"] .auth-view--signin {
  opacity: 0;
  visibility: hidden;
  transition: transform .55s var(--auth-ease), opacity .3s ease, visibility 0s .55s;
}
.auth-views[data-view="signin"] .auth-view--forgot { transform: translateX(35%); }
.auth-views[data-view="forgot"] .auth-view--signin { transform: translateX(-35%); }

.auth-key {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin-bottom: .85rem;
  border-radius: 14px;
  font-size: 1.4rem;
  color: var(--brand-900);
  background: linear-gradient(145deg, #f5cd6b, var(--gold-500));
  box-shadow: 0 10px 20px -10px rgba(185, 130, 26, .8), inset 0 1px 0 rgba(255, 255, 255, .5);
}
.auth-views[data-view="forgot"] .auth-key { animation: authKeyTurn .8s .25s var(--auth-ease) both; }

/* ---------- Mobile ---------- */
@media (max-width: 767.98px) {
  .auth-pane {
    grid-row: 2;
    grid-column: 1;
    padding: 1.75rem 1.5rem 2rem;
    transform: none !important;
    animation: none !important;
  }
  .auth-card[data-mode="signin"] .auth-pane--signin {
    opacity: 1;
    animation: authFadeUp .45s var(--auth-ease) both !important;
  }
}

/* ---------- Keyframes ---------- */
@keyframes authPaneShow {
  0%, 49.99% { opacity: 0; z-index: 1; }
  50%, 100% { opacity: 1; z-index: 5; }
}
@keyframes authCardIn {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: none; }
}
@keyframes authFadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes authFadeDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
@keyframes authShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}
@keyframes authSpin { to { transform: rotate(360deg); } }
@keyframes authRipple { to { transform: scale(2.6); opacity: 0; } }
@keyframes authKeyTurn {
  0% { transform: rotate(-35deg) scale(.7); opacity: 0; }
  60% { transform: rotate(12deg) scale(1.05); opacity: 1; }
  100% { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-card *,
  .auth-card *::before,
  .auth-card *::after,
  .auth-card {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    transition-delay: 0s !important;
  }
}

/* =========================================================
   "Signing you in…" screen (shown before going to the dashboard)
   ========================================================= */
.auth-splash {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    radial-gradient(500px 400px at 50% 60%, rgba(224, 165, 38, .22), transparent 65%),
    linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0 / 100% 32px,
    linear-gradient(90deg, rgba(255, 255, 255, .04) 1px, transparent 1px) 0 0 / 32px 100%,
    linear-gradient(160deg, var(--brand-700), var(--brand-900));
  /* grows out of the spot that was clicked */
  clip-path: circle(0 at var(--cx, 50%) var(--cy, 50%));
  animation: authSplashReveal .65s cubic-bezier(.65, 0, .35, 1) forwards;
}
.auth-splash.is-leaving {
  animation: authSplashLeave .35s ease forwards;
}

.auth-splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .9rem;
  text-align: center;
  animation: authFadeUp .5s .3s var(--auth-ease) both;
}

.auth-splash-mark {
  position: relative;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: .4rem;
  border-radius: 22px;
  font-size: 2rem;
  color: var(--brand-900);
  background: linear-gradient(145deg, #f5cd6b, var(--gold-500));
  box-shadow: 0 18px 40px -14px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .5);
  animation: authSplashFloat 1.8s ease-in-out infinite;
}
.auth-splash-mark::before,
.auth-splash-mark::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 28px;
  border: 2px solid rgba(224, 165, 38, .55);
  animation: authSplashRing 1.8s ease-out infinite;
}
.auth-splash-mark::after { animation-delay: .9s; }

.auth-splash-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.01em;
}
.auth-splash-sub {
  font-size: .9rem;
  color: rgba(255, 255, 255, .7);
}

.auth-splash-bar {
  width: 180px;
  height: 4px;
  margin-top: .4rem;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, .12);
}
.auth-splash-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold-500), #f6d27a);
  animation: authSplashBar 1.1s ease-in-out infinite;
}

@keyframes authSplashReveal {
  to { clip-path: circle(150% at var(--cx, 50%) var(--cy, 50%)); }
}
@keyframes authSplashLeave {
  from { clip-path: circle(150% at var(--cx, 50%) var(--cy, 50%)); opacity: 1; }
  to { clip-path: circle(150% at var(--cx, 50%) var(--cy, 50%)); opacity: 0; }
}
@keyframes authSplashFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes authSplashRing {
  from { transform: scale(.9); opacity: 1; }
  to { transform: scale(1.35); opacity: 0; }
}
@keyframes authSplashBar {
  from { transform: translateX(-110%); }
  to { transform: translateX(260%); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-splash { clip-path: none; animation: none; }
  .auth-splash *,
  .auth-splash *::before,
  .auth-splash *::after { animation: none !important; }
}

/* =========================================================
   Login only: one centered card, no side panel.
   (The sliding-panel rules above stay for reference but are unused.)
   ========================================================= */
.auth-card--single {
  max-width: 440px;
  grid-template-columns: 1fr;
  min-height: 0;
  border-top: 4px solid var(--brand-700);
}
@media (min-width: 768px) {
  .auth-card--single { grid-template-columns: 1fr; min-height: 0; }
}
.auth-card--single .auth-pane {
  grid-row: 1;
  grid-column: 1;
  padding: 2rem 2.25rem 2rem;
}
@media (max-width: 420px) {
  .auth-card--single .auth-pane { padding: 1.5rem 1.25rem 1.75rem; }
}

.auth-logo-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding-bottom: 1.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--line);
}
.auth-logo-row img {
  flex: none;
  border-radius: 12px;
  box-shadow: 0 6px 14px -8px rgba(63, 15, 15, .6);
}
.auth-logo-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--brand-900);
  line-height: 1.2;
}
.auth-logo-sub {
  font-size: .78rem;
  color: var(--ink-muted);
}

/* Help line under the form, shown on every screen size */
.auth-help {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: .82rem;
  color: var(--ink-muted);
}

/* A filled field is not the same as a correct password: no green "valid"
   border on sign-in (it looked right next to "Incorrect username or password"). */
.auth-card--single .was-validated .auth-input:valid { border-color: var(--line); }

/* Forgot-password view starts at the top of the card (no empty gap above
   "Back to sign in"); the slide animation between the two views stays. */
.auth-card--single .auth-view { justify-content: flex-start; }

/* iPhone zooms in when a field's text is under 16px: keep login fields at 16px on phones */
@media (max-width: 575.98px) {
  .auth-input { font-size: 16px; }
}
