/* ==============================================================
   AUTH PAGE – COMPLETE CONSOLIDATED STYLES
   ============================================================== */

/* ==============================================================
   INPUT GROUP & VALIDATION
   ============================================================== */

.input-group {
  position: relative;
}

.input-group input {
  transition: all 0.3s ease;
}

.input-group input:focus {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
  outline: none;
  border-color: currentColor;
}

.input-group .text-xs {
  display: flex;
  align-items: center;
  gap: 4px;
}

#msg i {
  margin-right: 6px;
}

/* Input validation states */
input:valid {
  border-color: #10b981 !important;
}

input:invalid {
  border-color: #ef4444 !important;
}

/* OTP & Text Input Spinner Removal */
input[type="text"]::-webkit-outer-spin-button,
input[type="text"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Better password toggle visibility */
.password-toggle {
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ==============================================================
   AUTH CONTAINER & BACKDROP
   ============================================================== */

#auth .container {
  backdrop-filter: blur(10px);
}

/* ==============================================================
   BUTTON STATES & STYLING
   ============================================================== */

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button, a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ==============================================================
   LOADING SPINNER
   ============================================================== */

.spinner {
  border: 3px solid #f3f4f6;
  border-top: 3px solid #4f46e5;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  margin-right: 8px;
}

@keyframes spin {
  0% { 
    transform: rotate(0deg); 
  }
  100% { 
    transform: rotate(360deg); 
  }
}

/* ==============================================================
   ANIMATIONS
   ============================================================== */

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fadeIn {
  animation: fadeIn 0.4s ease-out;
}

#msg {
  animation: fadeIn 0.5s ease;
}

/* Slide Down Animation */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-slideDown {
  animation: slideDown 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Shake Animation for Error Messages */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

.text-red-600 {
  animation: shake 0.3s ease-in-out;
}

/* ==============================================================
   GLOBAL PAGE STYLES
   ============================================================== */

body {
  overflow-x: hidden;
}

/* Smooth transitions for all elements */
* {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

/* ==============================================================
   MOBILE OPTIMIZATIONS (max-width: 640px)
   ============================================================== */

@media (max-width: 640px) {
  .container {
    margin-top: 2rem !important;
    padding: 1.5rem !important;
  }

  h2 {
    font-size: 1.5rem !important;
  }

  input, button {
    font-size: 16px !important; /* Prevents zoom on iOS */
  }

  .text-xs {
    font-size: 0.7rem !important;
  }
}

/* ==============================================================
   VISUAL REDESIGN — brand header, card entrance, tab-style
   switcher, input focus polish. Logic/IDs untouched.
   ============================================================== */

@keyframes authCardIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 28px auto 0;
  text-align: center;
}

.auth-brand-tagline {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
  max-width: 280px;
  line-height: 1.4;
}

.container {
  animation: authCardIn 0.35s ease;
  position: relative;
}

.container::before {
  content: "";
  position: absolute;
  top: 0; left: 16px; right: 16px;
  height: 4px;
  border-radius: 0 0 6px 6px;
  background: linear-gradient(90deg, #4f46e5, #6366f1, #818cf8);
}

/* Login / Signup pill switcher */
.auth-switch-row {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}
.auth-switch-row a {
  transition: color 0.15s ease;
}
.auth-switch-row a:hover {
  color: #4338ca !important;
}

/* Password-recovery option buttons: subtle lift on hover, handled by
   existing Tailwind hover: classes already present on the buttons. */
#forgotSection button[type="button"] {
  box-shadow: 0 4px 10px rgba(0,0,0,0.08);
}

/* OTP inputs: make the 6-digit code visually distinct/engaging */
#signupOtpInput, #otpInput {
  letter-spacing: 6px !important;
}

/* Trust note under the card */
.auth-trust-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 14px auto 24px;
  font-size: 12px;
  color: #6b7280;
  text-align: center;
}
.auth-trust-note i { color: #a5b4fc; }

@media (max-width: 480px) {
  .auth-brand { margin-top: 18px; }
}

/* ==============================================================
   MODERN REDESIGN v2 — tab pill, glass card, icon inputs, buttons.
   Purely visual. No IDs/classes used by auth.js are removed.
   ============================================================== */

.container {
  border-radius: 20px !important;
  box-shadow: 0 20px 45px -12px rgba(79, 70, 229, 0.22), 0 4px 14px rgba(0,0,0,0.04) !important;
}

.container::before { display: none; }

/* --- Login / Sign Up pill toggle --- */
.auth-tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f1f2f9;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 22px;
  overflow: hidden;
}

.auth-tabs.is-hidden { display: none; }

.auth-tab {
  position: relative;
  z-index: 2;
  border: none;
  background: transparent;
  padding: 9px 0;
  font-size: 14px;
  font-weight: 700;
  color: #6b7280;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.25s ease;
  min-height: 38px;
}

.auth-tab.active { color: #4338ca; }

.auth-tab-glider {
  position: absolute;
  top: 4px; bottom: 4px; left: 4px;
  width: calc(50% - 4px);
  background: #ffffff;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(79,70,229,0.18);
  transition: transform 0.28s cubic-bezier(0.65, 0, 0.35, 1);
  z-index: 1;
}

.auth-tabs.is-signup .auth-tab-glider {
  transform: translateX(100%);
}

/* --- Inputs: icon badge + soft focus glow --- */
.relative input[type="text"],
.relative input[type="email"],
.relative input[type="password"] {
  border-color: #e5e7eb !important;
  border-radius: 12px !important;
  background: #fafafe;
}

.relative input[type="text"]:focus,
.relative input[type="email"]:focus,
.relative input[type="password"]:focus {
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12) !important;
}

#loginSection .relative > i.fas:first-of-type,
#signupSection .relative > i.fas:first-of-type,
#forgotSection .relative > i.fas:first-of-type {
  width: 22px;
  height: 22px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  background: rgba(79, 70, 229, 0.1);
  color: #4f46e5 !important;
  border-radius: 7px;
  font-size: 11px !important;
}

/* --- Primary action buttons: gradient + lift --- */
#loginBtn, #signupBtn, #resetBtn, #verifyBtn, #getUsernameBtn, #verifyOtpBtn {
  border: none !important;
  background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.55) !important;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
}

#loginBtn:hover, #signupBtn:hover, #resetBtn:hover,
#verifyBtn:hover, #getUsernameBtn:hover, #verifyOtpBtn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px -6px rgba(79, 70, 229, 0.6) !important;
}

#loginBtn:active, #signupBtn:active, #resetBtn:active,
#verifyBtn:active, #getUsernameBtn:active, #verifyOtpBtn:active {
  transform: translateY(0);
}

/* --- OTP boxes --- */
#signupOtpInput, #otpInput {
  border-radius: 10px !important;
  background: #fafafe;
}

/* --- Forgot-password option cards --- */
#showUsernameRecovery, #showPasswordRecovery {
  border-radius: 12px !important;
  box-shadow: 0 8px 18px -6px rgba(0,0,0,0.15) !important;
  transition: transform 0.18s ease !important;
}

#showUsernameRecovery:hover, #showPasswordRecovery:hover {
  transform: translateY(-2px);
}

@media (max-width: 480px) {
  .auth-tab { font-size: 13px; }
}

/* ==============================================================
   SIGNUP WIZARD (3 steps) — same indigo theme as login: gradient
   primary buttons, soft #fafafe fields, pill chips, tinted badges.
   ============================================================== */

/* primary actions of steps 1 and 2 = same look as #signupBtn / #verifyOtpBtn */
#verifyEmailBtn, #verifySignupOtpBtn {
  border: none !important;
  color: #ffffff !important;
  background: linear-gradient(135deg, #4f46e5, #6366f1) !important;
  box-shadow: 0 8px 20px -6px rgba(79, 70, 229, 0.55) !important;
  border-radius: 12px !important;
  min-height: 44px;
  transition: transform 0.18s ease, box-shadow 0.18s ease !important;
}
#verifyEmailBtn:hover:not(:disabled), #verifySignupOtpBtn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 26px -6px rgba(79, 70, 229, 0.6) !important;
}
#verifyEmailBtn:active, #verifySignupOtpBtn:active { transform: translateY(0); }
#signupBtn { border-radius: 12px !important; min-height: 44px; }

/* progress: 1 - 2 - 3 */
#suProgress { color: #6b7280; }
#suProgress .su-dot { transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease; }
#suProgress .su-dot.su-active {
  background: linear-gradient(135deg, #4f46e5, #6366f1);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}
#suProgress .su-line { border-radius: 2px; transition: background-color 0.25s ease; }
@media (max-width: 380px) {
  #suProgress .su-label { display: none; }
  #suProgress [data-current="1"] .su-label { display: inline; }
}

/* OTP card (step 2) */
#signupOtpSection > div {
  background: #eef2ff !important;
  border: 1px solid #c7d2fe !important;
  border-radius: 14px !important;
}
#signupOtpInput {
  border: 2px solid #c7d2fe !important;
  background: #ffffff !important;
  color: #3730a3;
  min-height: 48px;
}
#signupOtpInput:focus {
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12) !important;
  outline: none;
}
#suChangeEmail { min-height: 32px; transition: color 0.15s ease; }
#suChangeEmail:hover { color: #4338ca !important; }

/* verified-email pill (step 3) */
#suStep3 > div:first-child { border-radius: 12px; }

/* username suggestions: pill chips in the indigo accent */
#suUsernameSuggest .su-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #c7d2fe;
  background: #eef2ff;
  color: #4338ca;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}
#suUsernameSuggest .su-chip:hover { background: #e0e7ff; border-color: #a5b4fc; }
#suUsernameSuggest .su-chip:active { transform: scale(0.96); }
#suUsernameSuggest span { font-size: 12px; color: #6b7280; }

/* ==============================================================
   FIELD LAYOUT FIX — icon never touches the text, placeholders are
   readable, everything scales from 320px phones to desktop.
   Icon is centred on the INPUT (not a fixed top offset), the text
   starts 48px in, and long placeholders end with an ellipsis.
   ============================================================== */

/* signup wizard fields */
#signupSection .su-field { margin: 0 0 14px; }
#signupSection .su-lab {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #4b5563;
  margin: 0 0 6px;
}
#signupSection .su-inwrap { position: relative; }
#signupSection .su-inwrap > i.su-ico {
  position: absolute !important;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
#signupSection .su-inwrap > input {
  display: block;
  width: 100%;
  min-width: 0;
  height: 48px;
  padding: 0 14px 0 50px !important;
  font-size: 15px;
  line-height: 1.2;
  color: #111827;
  text-overflow: ellipsis;
}
#signupSection .su-inwrap > input[type="password"],
#signupSection .su-inwrap > input#suPassword { padding-right: 50px !important; }
#signupSection .su-eye {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#signupSection .su-eye:hover { color: #4f46e5; }
#signupSection .su-note {
  font-size: 12px;
  line-height: 1.4;
  color: #6b7280;
  margin: 6px 2px 0;
  min-height: 16px;
  overflow-wrap: anywhere;
}
#signupSection .su-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
}
#suUsernameSuggest .su-chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* placeholders: clearly readable, never mistaken for typed text */
#signupSection input::placeholder,
#loginSection input::placeholder,
#forgotSection input::placeholder {
  color: #8a91a5;
  opacity: 1;
  font-weight: 400;
}

/* login + recovery fields had the same tight icon gap (text 6px from the badge) */
#liUsername, #liPassword, #urEmail, #prUsername, #prEmail, #fgNewPassword {
  padding-left: 3.1rem !important;
  text-overflow: ellipsis;
}
#liPassword, #fgNewPassword { padding-right: 3rem !important; }

/* OTP code: big and centred on every screen (beats the 16px mobile rule) */
#signupOtpInput { font-size: 22px !important; text-align: center; padding: 0 8px !important; }

#suChangeEmail { min-height: 40px; }

/* very small phones (<= 360px) */
@media (max-width: 360px) {
  .container { padding: 1.1rem !important; margin-left: 0.5rem !important; margin-right: 0.5rem !important; }
  #signupSection .su-inwrap > input { height: 46px; padding-left: 46px !important; }
  #signupSection .su-inwrap > i.su-ico { left: 10px; }
  #signupOtpInput { font-size: 20px !important; letter-spacing: 4px !important; }
  #suProgress .su-line { width: 14px; }
}

/* tablets and desktop: a little more breathing room, 15px text */
@media (min-width: 641px) {
  #signupSection .su-inwrap > input { font-size: 15px; }
  #signupSection .su-field { margin-bottom: 16px; }
}

/* short landscape phones: keep the card compact so the keyboard fits */
@media (max-height: 480px) and (orientation: landscape) {
  .container { margin-top: 0.75rem !important; padding: 1rem 1.25rem !important; }
  #signupSection .su-field { margin-bottom: 10px; }
}

/* respect reduced-motion */
@media (prefers-reduced-motion: reduce) {
  .animate-fadeIn, .container, #msg { animation: none !important; }
}

/* small polish found while testing on real widths */
#suUsernameSuggest .su-chip { font-size: 13px !important; min-height: 34px; }
#suUsernameSuggest span { align-self: center; }
.auth-switch-row { align-items: center; gap: 4px; flex-wrap: wrap; }
.auth-switch-row a { min-height: 40px; }
#suStep3 > div:first-child { margin-bottom: 16px; }
#suStep1 > p:first-child { margin-bottom: 14px; }
