/* ===================================================================
   Syntropy — Auth (Login/Signup)
   =================================================================== */

/* ===== Variables ===== */
:root {
  --primary: #6c8cff;
  --primary-dark: #4d6bfe;
  --primary-light: #a8b8ff;
  --text: #1a2233;
  --text-secondary: #4a5568;
  --text-muted: #8892a6;
  --bg: #ffffff;
  --bg-soft: #f7f9fc;
  --bg-card: #ffffff;
  --bg-input: #f7f9fc;
  --border: #e8ecf5;
  --border-focus: #6c8cff;
  --error: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --t: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --text: #e8ecf5;
  --text-secondary: #b0b8c8;
  --text-muted: #6b7280;
  --bg: #0a0e17;
  --bg-soft: #121826;
  --bg-card: #0f1420;
  --bg-input: #161c2c;
  --border: #232a3d;
  --border-focus: #6c8cff;
}

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background 0.4s var(--t), color 0.4s var(--t);
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
svg { display: block; }

::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ===== Fond animé ===== */
.bg-gradient {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(190,205,255,0.5) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(200,215,255,0.35) 0%, transparent 60%),
    linear-gradient(180deg, #eef3ff 0%, var(--bg) 60%);
  z-index: -3;
  transition: background 0.4s var(--t);
}
[data-theme="dark"] .bg-gradient {
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(108,140,255,0.2) 0%, transparent 70%),
    radial-gradient(ellipse 60% 50% at 20% 80%, rgba(120,150,255,0.12) 0%, transparent 60%),
    linear-gradient(180deg, #0d1424 0%, var(--bg) 60%);
}
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(130,160,230,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(130,160,230,0.06) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse 100% 80% at 50% 0%, black 0%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 100% 80% at 50% 0%, black 0%, transparent 100%);
  z-index: -2;
  pointer-events: none;
}
.glow-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(90px);
  z-index: -1;
  opacity: 0.5;
  animation: orbFloat 22s ease-in-out infinite;
}
.orb-1 { width: 400px; height: 400px; background: radial-gradient(circle, rgba(108,140,255,0.5), transparent 70%); top: -120px; left: 5%; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(circle, rgba(140,160,255,0.35), transparent 70%); bottom: -150px; right: 5%; animation-delay: -8s; }
.orb-3 { width: 300px; height: 300px; background: radial-gradient(circle, rgba(190,205,255,0.4), transparent 70%); top: 40%; left: 45%; animation-delay: -15s; }

@keyframes orbFloat {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(40px,-30px) scale(1.1); }
  66% { transform: translate(-30px,40px) scale(0.95); }
}

/* ===== Boutons coins ===== */
.back-btn,
.theme-toggle {
  position: fixed;
  top: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all 0.3s var(--t);
  z-index: 10;
  box-shadow: 0 2px 10px rgba(108,140,255,0.08);
}
.back-btn { left: 24px; }
.theme-toggle { right: 24px; position: fixed; overflow: hidden; }

.back-btn:hover {
  color: var(--primary);
  border-color: var(--primary-light);
  transform: translateX(-3px);
  box-shadow: 0 4px 16px rgba(108,140,255,0.2);
}
.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary-light);
  transform: rotate(20deg);
}
.theme-toggle svg { position: absolute; transition: all 0.4s var(--t); }
.icon-sun { opacity: 1; transform: rotate(0); }
.icon-moon { opacity: 0; transform: rotate(-90deg); }
[data-theme="dark"] .icon-sun { opacity: 0; transform: rotate(90deg); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: rotate(0); }

/* ===== Wrapper ===== */
.auth-wrapper {
  width: 100%;
  max-width: 440px;
  position: relative;
  z-index: 1;
  animation: fadeUp 0.6s var(--t);
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Card ===== */
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px 36px;
  box-shadow:
    0 20px 60px rgba(108,140,255,0.1),
    0 4px 12px rgba(0,0,0,0.03);
  transition: all 0.4s var(--t);
}

/* ===== Logo ===== */
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 32px;
  letter-spacing: -0.3px;
  transition: transform 0.3s var(--t);
}
.auth-logo:hover { transform: scale(1.02); }
.auth-logo svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 2px 8px rgba(108,140,255,0.25));
  transition: transform 0.5s var(--t);
}
.auth-logo:hover svg { transform: rotate(180deg); }

/* ===== Vues ===== */
.auth-view {
  display: none;
  animation: viewFade 0.4s var(--t);
}
.auth-view.active { display: block; }
@keyframes viewFade {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Titres ===== */
.auth-title {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  text-align: center;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
  line-height: 1.5;
}

/* ===== Form ===== */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  padding-left: 4px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: all 0.25s var(--t);
}
.input-wrapper:hover {
  border-color: var(--primary-light);
}
.input-wrapper:focus-within {
  border-color: var(--border-focus);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px rgba(108,140,255,0.12);
}

.input-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 14px;
  color: var(--text-muted);
  transition: color 0.25s;
}
.input-wrapper:focus-within .input-icon { color: var(--primary); }

.input-wrapper input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  padding: 14px 14px;
  font-size: 15px;
  color: var(--text);
  min-width: 0;
}
.input-wrapper input::placeholder { color: var(--text-muted); }

/* Password toggle */
.toggle-password {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--text-muted);
  transition: color 0.25s;
  position: relative;
  height: 100%;
}
.toggle-password:hover { color: var(--primary); }
.toggle-password svg { transition: all 0.3s var(--t); }
.toggle-password .eye-open { opacity: 1; }
.toggle-password .eye-closed { opacity: 0; position: absolute; }
.toggle-password.visible .eye-open { opacity: 0; }
.toggle-password.visible .eye-closed { opacity: 1; }

/* Erreurs */
.input-error {
  font-size: 12px;
  color: var(--error);
  padding-left: 4px;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s var(--t), margin 0.25s var(--t);
}
.input-error.show {
  max-height: 30px;
  margin-top: 2px;
}

.input-wrapper.error {
  border-color: var(--error);
  background: rgba(239,68,68,0.04);
}
.input-wrapper.error:focus-within {
  box-shadow: 0 0 0 4px rgba(239,68,68,0.12);
}
.input-wrapper.error .input-icon { color: var(--error); }

.input-hint {
  font-size: 12px;
  color: var(--text-muted);
  padding-left: 4px;
}

/* ===== Password strength ===== */
.password-strength {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s var(--t);
}
.password-strength.show {
  opacity: 1;
  max-height: 30px;
}
.strength-bar {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.strength-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition: width 0.4s var(--t), background 0.4s var(--t);
}
.strength-text {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 55px;
  text-align: right;
}
.strength-weak span { width: 25%; background: #ef4444; }
.strength-fair span { width: 50%; background: #f59e0b; }
.strength-good span { width: 75%; background: #3b82f6; }
.strength-strong span { width: 100%; background: #10b981; }

.strength-weak .strength-text { color: #ef4444; }
.strength-fair .strength-text { color: #f59e0b; }
.strength-good .strength-text { color: #3b82f6; }
.strength-strong .strength-text { color: #10b981; }

/* ===== Code wrapper ===== */
.code-wrapper input { letter-spacing: 2px; font-weight: 500; }
.btn-send-code {
  padding: 0 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
  border-left: 1px solid var(--border);
  height: 100%;
  transition: all 0.25s var(--t);
  white-space: nowrap;
}
.btn-send-code:hover:not(:disabled) { color: var(--primary-dark); }
.btn-send-code:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ===== Row forgot/signup ===== */
.auth-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: -4px;
}
.link-sm {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
}
.link-sm::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 1px;
  background: currentColor;
  transition: width 0.3s var(--t);
}
.link-sm:hover { color: var(--primary-dark); }
.link-sm:hover::after { width: 100%; }

/* ===== Bouton principal ===== */
.btn-primary {
  position: relative;
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  transition: all 0.3s var(--t);
  overflow: hidden;
  margin-top: 8px;
  box-shadow: 0 4px 14px rgba(108,140,255,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  opacity: 0;
  transition: opacity 0.3s;
}
.btn-primary:hover::before { opacity: 1; }
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(108,140,255,0.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.btn-text { position: relative; z-index: 1; transition: opacity 0.2s; }
.btn-loader {
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  opacity: 0;
  transition: opacity 0.2s;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary.loading .btn-text { opacity: 0; }
.btn-primary.loading .btn-loader { opacity: 1; }

/* ===== Séparateur ===== */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 28px 0 20px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ===== Boutons sociaux ===== */
.social-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  transition: all 0.25s var(--t);
}
.social-btn:hover {
  border-color: var(--primary-light);
  background: var(--bg-card);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(108,140,255,0.15);
}
.social-btn:active { transform: translateY(0); }

/* ===== Terms ===== */
.auth-terms {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
  margin: 4px 0 8px;
}
.auth-terms a {
  color: var(--text-secondary);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color 0.2s;
}
.auth-terms a:hover { color: var(--primary); }

/* ===== Switch ===== */
.auth-switch {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--text-muted);
}
.auth-switch a {
  color: var(--primary);
  font-weight: 500;
  margin-left: 4px;
  transition: color 0.2s;
}
.auth-switch a:hover { color: var(--primary-dark); text-decoration: underline; }

/* ===== Footer ===== */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}
.auth-footer a {
  color: var(--text-secondary);
  transition: color 0.2s;
}
.auth-footer a:hover { color: var(--primary); }

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 260px;
  max-width: 400px;
  animation: toastIn 0.4s var(--t);
  pointer-events: auto;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.hiding { animation: toastOut 0.3s var(--t) forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-20px); }
}
.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 12px;
}
.toast.success { border-color: rgba(16,185,129,0.3); }
.toast.success .toast-icon { background: rgba(16,185,129,0.15); color: #10b981; }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.error .toast-icon { background: rgba(239,68,68,0.15); color: #ef4444; }
.toast.info { border-color: rgba(108,140,255,0.3); }
.toast.info .toast-icon { background: rgba(108,140,255,0.15); color: var(--primary); }

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .auth-card { padding: 32px 22px; }
  .auth-title { font-size: 22px; }
  .auth-logo { font-size: 20px; margin-bottom: 24px; }
  .back-btn, .theme-toggle { top: 16px; width: 38px; height: 38px; }
  .back-btn { left: 16px; }
  .theme-toggle { right: 16px; }
  .social-row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== Bouton Envoyer le code (hors form) ===== */
.btn-send-code-standalone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  margin-top: 12px;
  background: transparent;
  border: 1.5px dashed var(--primary);
  border-radius: 12px;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-send-code-standalone:hover:not(:disabled) {
  background: rgba(108, 140, 255, 0.08);
  border-style: solid;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(108, 140, 255, 0.15);
}
.btn-send-code-standalone:active:not(:disabled) {
  transform: translateY(0);
}
.btn-send-code-standalone:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  border-style: solid;
  border-color: var(--border);
  color: var(--text-muted);
}