/* ================================================================
   shared/auth-ui.css — Minimalist OTP Login Modal
   Works in dark mode (default) + respects [data-theme="light"]
   ================================================================ */

/* ── Import font ── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Variables (dark default) ── */
:root {
  --auth-bg: #09090d;
  --auth-card-bg: rgba(255, 255, 255, 0.04);
  --auth-card-border: rgba(255, 255, 255, 0.10);
  --auth-card-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
  --auth-text-primary: #f8fafc;
  --auth-text-secondary: #94a3b8;
  --auth-text-muted: #475569;
  --auth-input-bg: rgba(255, 255, 255, 0.05);
  --auth-input-border: rgba(255, 255, 255, 0.10);
  --auth-input-focus-border: #7c3aed;
  --auth-input-focus-glow: rgba(124, 58, 237, 0.25);
  --auth-accent-start: #6d28d9;
  --auth-accent-end: #7c3aed;
  --auth-btn-text: #ffffff;
  --auth-particle: rgba(124, 58, 237, 0.5);
  --auth-glow: rgba(109, 40, 217, 0.15);
}



/* ── Overlay ── */
#auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Always dark — independent of app theme */
  background: #09090d;
  --auth-bg: #09090d;
  --auth-card-bg: rgba(255, 255, 255, 0.05);
  --auth-card-border: rgba(255, 255, 255, 0.10);
  --auth-card-shadow: 0 32px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.05);
  --auth-text-primary: #f8fafc;
  --auth-text-secondary: #94a3b8;
  --auth-text-muted: #475569;
  --auth-input-bg: rgba(255, 255, 255, 0.06);
  --auth-input-border: rgba(255, 255, 255, 0.12);
  --auth-input-focus-border: #7c3aed;
  --auth-input-focus-glow: rgba(124, 58, 237, 0.25);
  --auth-accent-start: #6d28d9;
  --auth-accent-end: #7c3aed;
  --auth-btn-text: #ffffff;
  font-family: 'Outfit', system-ui, sans-serif;
  overflow: hidden;
}

#auth-overlay.auth-hidden {
  display: none;
}

/* ── Animated bg mesh ── */
.auth-bg-mesh {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-bg-mesh::before,
.auth-bg-mesh::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: auth-drift 12s ease-in-out infinite alternate;
}

.auth-bg-mesh::before {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(109,40,217,0.35) 0%, transparent 70%);
  top: -100px;
  left: -100px;
}

.auth-bg-mesh::after {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(124,58,237,0.25) 0%, transparent 70%);
  bottom: -80px;
  right: -80px;
  animation-delay: -6s;
}

@keyframes auth-drift {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(40px, 30px) scale(1.1); }
}

/* ── Card ── */
.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: 1rem;
  background: var(--auth-card-bg);
  border: 1px solid var(--auth-card-border);
  border-radius: 24px;
  box-shadow: var(--auth-card-shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 40px 36px 36px;
  text-align: center;
  animation: auth-card-in 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── App Icon ── */
.auth-app-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--auth-accent-start), var(--auth-accent-end));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(109, 40, 217, 0.35);
}

/* ── Heading ── */
.auth-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--auth-text-primary);
  letter-spacing: -0.02em;
  margin: 0 0 6px;
  line-height: 1.2;
}

.auth-subtitle {
  font-size: 0.875rem;
  color: var(--auth-text-secondary);
  margin: 0 0 32px;
  line-height: 1.5;
}

/* ── Screen transitions ── */
.auth-screen {
  display: none;
}
.auth-screen.active {
  display: block;
  animation: auth-screen-in 0.3s ease both;
}

@keyframes auth-screen-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Input field ── */
.auth-input-wrap {
  position: relative;
  margin-bottom: 12px;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1rem;
  pointer-events: none;
  opacity: 0.6;
  z-index: 2;
}

.auth-input,
#auth-overlay input.auth-input,
#auth-overlay input[type="email"],
#auth-overlay input[type="text"],
#auth-overlay input {
  width: 100% !important;
  box-sizing: border-box !important;
  background: #13141f !important;
  background-color: #13141f !important;
  border: 1.5px solid rgba(255, 255, 255, 0.2) !important;
  border-radius: 12px !important;
  padding: 13px 16px 13px 42px !important;
  font-size: 1rem !important;
  font-family: 'Outfit', system-ui, sans-serif !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  outline: none !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
}

.auth-input::placeholder,
#auth-overlay input.auth-input::placeholder,
#auth-overlay input::placeholder {
  color: rgba(255, 255, 255, 0.45) !important;
  -webkit-text-fill-color: rgba(255, 255, 255, 0.45) !important;
}

.auth-input:focus,
#auth-overlay input.auth-input:focus,
#auth-overlay input:focus {
  border-color: #8b5cf6 !important;
  background: #181928 !important;
  background-color: #181928 !important;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.35) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

/* Chrome/Edge/Safari Autofill Dark Theme Override */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus,
#auth-overlay input:-webkit-autofill {
  -webkit-text-fill-color: #ffffff !important;
  -webkit-box-shadow: 0 0 0px 1000px #13141f inset !important;
  box-shadow: 0 0 0px 1000px #13141f inset !important;
  border: 1.5px solid #8b5cf6 !important;
  caret-color: #ffffff !important;
  transition: background-color 5000s ease-in-out 0s !important;
  color: #ffffff !important;
}

/* ── OTP digit inputs ── */
.auth-otp-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-otp-digit,
#auth-overlay input.auth-otp-digit {
  width: 48px !important;
  height: 56px !important;
  padding: 0 !important;
  margin: 0 !important;
  text-align: center !important;
  background: #13141f !important;
  background-color: #13141f !important;
  border: 1.5px solid rgba(255, 255, 255, 0.22) !important;
  border-radius: 12px !important;
  font-size: 1.5rem !important;
  font-weight: 800 !important;
  font-family: 'Outfit', system-ui, sans-serif !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  outline: none !important;
  caret-color: transparent !important;
  box-sizing: border-box !important;
  line-height: 54px !important;
  display: inline-block !important;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s, background-color 0.2s !important;
}

.auth-otp-digit:focus,
#auth-overlay input.auth-otp-digit:focus {
  border-color: #8b5cf6 !important;
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.35) !important;
  transform: scale(1.05) !important;
  background: #181928 !important;
  background-color: #181928 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
}

.auth-otp-digit.filled,
#auth-overlay input.auth-otp-digit.filled {
  border-color: #8b5cf6 !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  background: rgba(139, 92, 246, 0.2) !important;
  background-color: rgba(139, 92, 246, 0.2) !important;
}

/* ── Primary button ── */
.auth-btn-primary,
#auth-overlay button.auth-btn-primary {
  width: 100% !important;
  padding: 14px !important;
  background: linear-gradient(135deg, #6d28d9, #7c3aed) !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 12px !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
  font-family: 'Outfit', system-ui, sans-serif !important;
  cursor: pointer !important;
  letter-spacing: 0.01em !important;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s !important;
  box-shadow: 0 4px 20px rgba(109, 40, 217, 0.45) !important;
  margin-top: 4px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
}

.auth-btn-primary:hover:not(:disabled),
#auth-overlay button.auth-btn-primary:hover:not(:disabled) {
  opacity: 0.92 !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 8px 28px rgba(109, 40, 217, 0.55) !important;
}

.auth-btn-primary:active:not(:disabled),
#auth-overlay button.auth-btn-primary:active:not(:disabled) {
  transform: translateY(0) !important;
}

.auth-btn-primary:disabled,
#auth-overlay button.auth-btn-primary:disabled {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

.auth-btn-primary.loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.7s linear infinite;
  margin-left: 8px;
  vertical-align: middle;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

/* ── Back link ── */
.auth-back-link {
  display: inline-block;
  font-size: 0.8rem;
  color: var(--auth-text-muted);
  cursor: pointer;
  margin-top: 16px;
  transition: color 0.2s;
  text-decoration: none;
  user-select: none;
}

.auth-back-link:hover {
  color: var(--auth-text-secondary);
}

/* ── Trust line ── */
.auth-trust-line {
  font-size: 0.775rem;
  color: var(--auth-text-muted);
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.auth-trust-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--auth-text-muted);
  opacity: 0.5;
}

/* ── Error message ── */
.auth-error {
  font-size: 0.8rem;
  color: #ef4444;
  margin-top: 8px;
  min-height: 18px;
  text-align: center;
}

/* ── Success animation ── */
.auth-success-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  animation: auth-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes auth-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── OTP hint (dev mode) ── */
.auth-dev-hint {
  background: rgba(234, 179, 8, 0.1);
  border: 1px solid rgba(234, 179, 8, 0.3);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.8rem;
  color: #eab308;
  margin-bottom: 12px;
  font-family: monospace;
  text-align: left;
  letter-spacing: 0.05em;
}

/* ── Resend timer ── */
.auth-resend {
  font-size: 0.8rem;
  color: var(--auth-text-muted);
  margin-top: 12px;
}

.auth-resend-btn {
  background: none;
  border: none;
  color: #7c3aed;
  font-size: 0.8rem;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  text-decoration: underline;
}

.auth-resend-btn:disabled {
  color: var(--auth-text-muted);
  text-decoration: none;
  cursor: not-allowed;
}
