/* =========================================================
   THEME TOKENS & GLOBAL RESET
   ========================================================= */
:root {
  --primary: #ff6b5a;
  --primary-dark: #ff3c2e;
  --secondary: #1e2a3a;

  --bg-main: linear-gradient(135deg, #0a1830 0%, #1e2a3a 100%);
  --glass: rgba(255, 255, 255, 0.08);

  --text-main: #eaf4ff;
  --text-muted: #9bb0c6;

  --border-radius: 14px;
  --shadow: 0 18px 50px rgba(2, 8, 18, 0.6);
  --transition: 0.25s cubic-bezier(.2, .9, .3, 1);
}

html, body {
  min-height: 100vh;
  background: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', system-ui, Segoe UI, Roboto, Arial, sans-serif;
  transition: background .4s;
}

/* =========================================================
   ANIMATIONS (shared)
   ========================================================= */
/* used by form .btn and now by .btn-back so they sync */
@keyframes fieldIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* small "pop" used by other elements (kept for badge) */
@keyframes badgePop {
  from { opacity: 0; transform: translateY(-14px) scale(.86); }
  50%  { opacity: 1; transform: translateY(3px) scale(1.04); }
  to   { opacity: 1; transform: none; }
}

/* =========================================================
   BACK (inside card) BUTTON — now animates with login button
   ========================================================= */
.auth-card { position: relative; } /* ensure back button can position inside */

.auth-card .btn-back {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  color: #eaf4ff;
  border: 1px solid rgba(255,255,255,0.06);
  text-decoration: none;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(2,8,18,0.35);
  transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
  backdrop-filter: blur(4px);
  -webkit-tap-highlight-color: transparent;

  /* start hidden like other inputs/buttons, then animate in with same animation+delay */
  opacity: 0;
  transform: translateY(14px);
  animation: fieldIn 0.65s cubic-bezier(.16,1,.3,1) 0.70s forwards;
}

.auth-card .btn-back .chev {
  font-weight: 900;
  opacity: 0.95;
  line-height: 1;
}
.auth-card .btn-back .text {
  font-size: 0.92rem;
  letter-spacing: .2px;
}
.auth-card .btn-back:hover,
.auth-card .btn-back:focus {
  transform: translateY(-3px);
  background: rgba(255,255,255,0.06);
  box-shadow: 0 14px 30px rgba(2,8,18,0.50);
}

/* small screens — scale down the back button to avoid overlap */
@media (max-width:420px) {
  .auth-card .btn-back {
    top: 10px;
    left: 10px;
    padding: 5px 8px;
    gap: 6px;
  }
  .auth-card .btn-back .text { display: none; } /* show only chevron on very small screens */
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn-primary {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border: none;
  color: #fff;
  font-weight: 600;
  border-radius: 10px;
  transition: background var(--transition), box-shadow var(--transition);
  padding: .85rem 1.1rem;
  font-size: 1.06rem;
}
.btn-primary:hover,
.btn-primary:focus {
  background: linear-gradient(90deg, var(--primary-dark), var(--primary));
  box-shadow: 0 4px 24px rgba(255, 107, 90, 0.18);
}

/* Ensure login card button aligns and animates in (same animation used above) */
.auth-card .btn.btn-lg {
  padding: .6rem .95rem;
  font-size: 1rem;
}
.auth-card .btn-primary {
  display: block;
  max-width: 380px;
  margin: 0 auto;
}

/* login button animation — keep this intact so it matches .btn-back */
.auth-card form .btn {
  opacity: 0;
  transform: translateY(14px);
  animation: fieldIn 0.65s cubic-bezier(.16,1,.3,1) 0.70s forwards;
}

/* =========================================================
   LOGO & BRANDING
   ========================================================= */
.logo-img {
  filter: drop-shadow(0 2px 8px rgba(255, 107, 90, 0.12));
}
.brand-badge {
  width: 76px; height: 76px;
  border-radius: 50%;
  margin: -58px auto 8px;
  display: grid; place-items: center;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.14), rgba(255,255,255,0.04));
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 10px 28px rgba(2,8,18,0.55);
  opacity: 0;
  animation: badgePop 0.65s cubic-bezier(.16,1,.3,1) 0.05s forwards;
}
.brand-badge .logo-img {
  width: 44px; height: 44px; opacity: 0.95;
}
.app-title {
  margin: 4px 0 0;
  color: #fff;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.4px;
}
.sub {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: .98rem;
}

/* =========================================================
   SCROLLBARS
   ========================================================= */
::-webkit-scrollbar { width: 8px; background: #1e2a3a; }
::-webkit-scrollbar-thumb { background: #2c3a4d; border-radius: 8px; }

/* =========================================================
   BACKGROUND (ANIMATED LAYERS)
   ========================================================= */
#bg-anim {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1000px 600px at 70% 20%, rgba(88,133,255,0.10), transparent 60%),
    radial-gradient(900px 500px at 20% 80%, rgba(255,107,90,0.10), transparent 60%);
  animation: bgMove 14s ease-in-out infinite alternate;
}
@keyframes bgMove {
  0%   { background-position: 70% 20%, 20% 80%; }
  100% { background-position: 62% 26%, 16% 86%; }
}

/* =========================================================
   GLASS PANELS & LAYOUT
   ========================================================= */
.glass-panel {
  background: linear-gradient(120deg, rgba(255,255,255,0.07), rgba(255,255,255,0.03));
  box-shadow: var(--shadow);
  border-radius: var(--border-radius);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(8px);
}
.auth-container {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 0 5px;
  position: relative;
  z-index: 1;
}
.auth-card {
  min-height: 500px;
  width: 100%;
  max-width: 560px;
  padding: 28px 22px 5px;
  display: flex; flex-direction: column; justify-content: center;
  border-radius: var(--border-radius);
  background: linear-gradient(180deg, rgba(7,16,28,0.92), rgba(6,12,22,0.97));
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 18px 50px rgba(2,8,18,0.55), inset 0 1px 0 rgba(255,255,255,0.03);
  position: relative;
  animation: popIn .55s cubic-bezier(.2,.9,.3,1);
}
@keyframes popIn {
  from { transform: translateY(12px) scale(.98); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
.auth-card::before {
  content: "";
  position: absolute; inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(88,133,255,0.35), rgba(255,107,90,0.2));
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events: none;
}

/* --- Header Animation --- */
.auth-card > header {
  opacity: 0;
  animation: fadeSlide 0.65s cubic-bezier(.16,1,.3,1) 0.20s forwards;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* --- Input Field Animation --- */
.auth-card form .field {
  opacity: 0;
  transform: translateY(14px);
  animation: fieldIn 0.65s cubic-bezier(.16,1,.3,1) forwards;
}
@keyframes fieldIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Stagger fields smoothly */
.auth-card form .field:nth-of-type(1) { animation-delay: 0.35s; }
.auth-card form .field:nth-of-type(2) { animation-delay: 0.50s; }

/* --- Button Animation --- */
.auth-card form .btn {
  opacity: 0;
  transform: translateY(14px);
  animation: fieldIn 0.65s cubic-bezier(.16,1,.3,1) 0.70s forwards;
}

/* --- Footer Animation --- */
.auth-card .foot {
  opacity: 0;
  animation: fadeSlide 0.65s cubic-bezier(.16,1,.3,1) 0.85s forwards;
}

/* ==============================
   WIDTH / LAYOUT — keep full width
   ============================== */
.field {
  position: relative;
  width: 100%;
  max-width: 520px;           /* wider than before */
  margin-bottom: 2rem;
  margin-top: 1rem;
}

.auth-card .btn-primary {
  width: 100%;                /* prevent prior max-width:380px constraints */
  max-width: none !important;
}

/* ==============================
   INPUT SURFACE + SIZING
   ============================== */
:root {
  --input-surface: rgba(13, 22, 38, 0.92); /* opaque enough to beat autofill */
}

.field-input {
  width: 100%;
  height: 56px;                       /* taller for comfort */
  padding: 0 16px;
  background: var(--input-surface);   /* solid surface */
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  color: #eaf4ff;
  font-size: 1rem;
  transition: border .25s, box-shadow .25s, background-color .25s;
}

/* only the password needs extra right padding */
.field-input.has-toggle { padding-right: 48px; }

.field-input:focus {
  outline: none;
  border-color: #5885ff;
  box-shadow: 0 0 0 3px rgba(88,133,255,0.22);
}

#loginForm .btn-primary {
  width: 100%;
  max-width: 380px;
  margin: 16px auto 0;
  display: block;
}

/* ==============================
   FLOATING LABELS (clean + consistent)
   ============================== */
.field-label {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  color: rgba(234,244,255,0.68);
  pointer-events: none;
  padding: 0 4px;
  transition: .2s ease;
}

/* on focus OR when the input has content (thanks to placeholder=" ") */
.field-input:focus + .field-label,
.field-input:not(:placeholder-shown) + .field-label {
  top: -15px;
  left: 10px;
  font-size: 0.9rem;
  color: #ffffff;
  background: transparent;
  border-radius: 4px;
}

/* Also float when Chrome has autofilled the field */
.field-input:-webkit-autofill + .field-label {
  top: -15px;
  left: 10px;
  font-size: 0.9rem;
  color: #ffffff;
  background: transparent;
  border-radius: 4px;
}

/* ==============================
   KILL YELLOW AUTOFILL (Chrome/Edge)
   ============================== */
input:-webkit-autofill,
input:-webkit-autofill:focus,
input:-webkit-autofill:hover {
  /* paint our own surface permanently inside */
  -webkit-box-shadow: 0 0 0px 1000px var(--input-surface) inset !important;
  box-shadow:         0 0 0px 1000px var(--input-surface) inset !important;

  /* keep text consistent */
  -webkit-text-fill-color: #eaf4ff !important;
  caret-color: #eaf4ff !important;

  /* stop flicker on load */
  transition: background-color 99999s ease-in-out 0s;
}

/* ensure border still visible with autofill */
input:-webkit-autofill {
  border: 1px solid rgba(255,255,255,0.12) !important;
  border-radius: 12px;
}

/* ==============================
   Eye toggle button
   ============================== */
.btn-toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  height: 32px;
  width: 36px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.05);
  color: #eaf4ff;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.25s;
}

.btn-toggle-password:hover {
  background: rgba(255,255,255,0.08);
}

/* =========================================================
   FOOTER
   ========================================================= */
.foot {
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* =========================================================
   TOAST MESSAGES
   ========================================================= */
#messages {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top)); /* same distance from top on every screen */
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 480px);      /* a little wider for visibility */
  text-align: center;
  z-index: 11060;              /* very high so it always sits above UI */
  pointer-events: none;        /* clicks pass through; buttons inside can override */
  will-change: transform, opacity;
}

/* individual toast */
#messages .msg {
  display: inline-block;
  margin: 0 0 10px;
  padding: .75rem 1rem;        /* more breathing room */
  font-size: 1rem;             /* slightly bigger */
  font-weight: 700;            /* bolder */
  line-height: 1.1;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.10));
  box-shadow: 0 18px 40px rgba(2,8,18,0.56);
  color: #eaf4ff;
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: auto;        /* allow interactions with the toast itself (if needed) */
}

/* success (stronger green) */
#messages .msg[data-tags*="success"] {
  border-color: rgba(35,135,85,0.45);
  background: linear-gradient(180deg, rgba(35,135,85,0.18), rgba(35,135,85,0.10));
  color: #e9ffef;
  box-shadow: 0 20px 44px rgba(35,135,85,0.12);
}

/* error / danger */
#messages .msg[data-tags*="error"],
#messages .msg[data-tags*="danger"] {
  border-color: rgba(240,90,90,0.45);
  background: linear-gradient(180deg, rgba(240,90,90,0.16), rgba(240,90,90,0.08));
  color: #fff0f0;
  box-shadow: 0 20px 44px rgba(240,90,90,0.10);
}

/* info */
#messages .msg[data-tags*="info"] {
  border-color: rgba(52,110,220,0.45);
  background: linear-gradient(180deg, rgba(52,110,220,0.14), rgba(52,110,220,0.06));
  color: #eaf4ff;
  box-shadow: 0 18px 36px rgba(52,110,220,0.08);
}

/* animation - slightly stronger entrance */
@keyframes toastInOut {
  0%   { opacity: 0; transform: translateY(-12px) scale(.995); }
  10%  { opacity: 1; transform: translateY(0) scale(1); }
  85%  { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-8px) scale(.995); }
}
#messages .msg.toast-auto-hide {
  animation: toastInOut 4.6s cubic-bezier(.2,.9,.3,1) forwards;
}

/* =========================================================
   FORM LAYOUT OVERRIDES
   ========================================================= */
#loginForm {
  max-width: 500px;
  margin: 0 auto;
}
