/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Brand */
  --primary: #a855f7;
  --secondary: #ff0080;
  --accent: #22c55e;

  /* Surfaces */
  --glass: rgba(255, 255, 255, 0.06);
  --glass-border: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(255, 255, 255, 0.06);
  --label-bg: rgba(10, 6, 30, 0.92);

  /* Text */
  --text: #f1f1f1;
  --text-muted: rgba(255, 255, 255, 0.62);

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  /* Border */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 24px;
  --border-w: 1.5px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 16px rgba(255, 0, 128, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.35);

  /* Animation */
  --transition: 0.25s ease;
  --transition-fast: 0.15s ease;
  --transition-slow: 0.4s cubic-bezier(0.22, 1, 0.36, 1);

  /* Misc */
  --input-h: 50px;
}

[data-theme="light"] {
  --glass: rgba(255, 255, 255, 0.35);
  --glass-border: rgba(0, 0, 0, 0.08);
  --input-bg: rgba(0, 0, 0, 0.04);
  --label-bg: rgba(255, 255, 255, 0.95);
  --text: #1a1a2e;
  --text-muted: rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
}
[data-theme="light"] body {
  background: linear-gradient(135deg, #e8e0f0, #f0e6ef, #e0e0f0);
}
[data-theme="light"] .orb--1 {
  opacity: 0.2;
}
[data-theme="light"] .orb--2 {
  opacity: 0.15;
}

html {
  height: 100%;
  color-scheme: dark;
}
[data-theme="light"] html {
  color-scheme: light;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: "Inter", system-ui, sans-serif;
  background: linear-gradient(135deg, #0f0a2e, #1a0a3e, #0d0a1a);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ===== Skip Link ===== */
.skip-link {
  position: fixed;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: var(--primary);
  color: #fff;
  padding: 8px 20px;
  border-radius: 0 0 8px 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
}

/* ===== Background Orbs ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
  will-change: transform;
}
.orb--1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #7928ca, transparent 70%);
  top: -15%;
  left: -10%;
  animation: float 18s ease-in-out infinite;
}
.orb--2 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #ff0080, transparent 70%);
  bottom: -15%;
  right: -10%;
  animation: float 22s ease-in-out infinite reverse;
}
@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(40px, -50px) scale(1.1);
  }
  66% {
    transform: translate(-30px, 30px) scale(0.95);
  }
}

/* ===== Card / Panel ===== */
.card,
.panel {
  position: relative;
  z-index: 1;
  width: 100%;
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: cardIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.card {
  max-width: 400px;
  overflow: hidden;
}
@keyframes cardIn {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.card-inner {
  padding: 40px 32px 32px;
  position: relative;
}

/* ===== Form Switching ===== */
.form {
  display: none;
  flex-direction: column;
  animation: formIn 0.4s ease both;
}
.form.active {
  display: flex;
}
@keyframes formIn {
  0% {
    opacity: 0;
    transform: translateX(24px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}
.form.out {
  display: flex;
  animation: formOut 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  pointer-events: none;
  position: absolute;
  inset: 40px 32px 32px;
}
@keyframes formOut {
  0% {
    opacity: 1;
    transform: translateX(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-24px);
  }
}

/* ===== Avatar ===== */
.avatar {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: #fff;
}
.avatar::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  border: 2px solid var(--secondary);
  opacity: 0;
  pointer-events: none;
  animation: pulse 3s ease-in-out infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 0;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
}
@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% {
    transform: scale(1.08);
  }
  70% {
    transform: scale(0.95);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.avatar.bounce-in {
  animation: bounceIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) !important;
}

/* ===== Typography ===== */
.gradient-text {
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.title {
  font-size: 1.8rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: -0.5px;
}
.subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 6px 0 28px;
}

/* ===== Input Fields ===== */
.field {
  margin-bottom: 20px;
}
.field-input {
  position: relative;
}
.field .input {
  width: 100%;
  height: 50px;
  padding: 0 16px 0 44px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--text);
  background: var(--input-bg);
  border: var(--border-w) solid transparent;
  border-radius: var(--radius);
  outline: none;
  transition:
    border var(--transition),
    box-shadow var(--transition),
    background var(--transition);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.field .input[type="password"] {
  padding-right: 44px;
}
.field .input::placeholder {
  color: transparent;
}
.field .input:focus {
  border-color: var(--primary);
  background: linear-gradient(
    90deg,
    var(--input-bg) 80%,
    rgba(168, 85, 247, 0.06)
  );
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}
.field .input:focus ~ label {
  color: var(--primary);
}
.field .input.error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.field .input.error ~ .error-text {
  display: block;
}
.error-text {
  display: none;
  font-size: 0.72rem;
  color: #ef4444;
  margin-top: 4px;
  padding-left: 4px;
  min-height: 1em;
}
.error-text:empty {
  display: none;
}

/* ===== Floating Labels ===== */
.field-input label {
  position: absolute;
  left: 44px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.9rem;
  color: var(--text-muted);
  pointer-events: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  transition: 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  padding: 0 4px;
  background: transparent;
}
.field-input .input:focus + label,
.field-input .input:not(:placeholder-shown) + label {
  top: -10px;
  left: 12px;
  font-size: 0.75rem;
  color: var(--primary);
  background: var(--label-bg);
  padding: 0 6px;
  border-radius: 4px;
}

/* ===== Icons ===== */
.field .icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
  transition: color var(--transition);
}
.field-input .input:focus ~ .icon,
.field-input .input:not(:placeholder-shown) ~ .icon {
  color: var(--primary);
}

/* Override browser autofill background */
.field .input:-webkit-autofill,
.field .input:-webkit-autofill:hover,
.field .input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
  box-shadow: 0 0 0 1000px transparent inset !important;
  -webkit-text-fill-color: var(--text) !important;
  transition: background-color 5000s ease-in-out 0s;
}
.field-input .input:-webkit-autofill ~ label {
  top: -10px;
  left: 12px;
  font-size: 0.75rem;
  color: var(--primary);
  background: var(--label-bg);
  padding: 0 6px;
  border-radius: 4px;
}
.field-input .input:-webkit-autofill ~ .icon {
  color: var(--primary);
}

/* ===== Password Toggle ===== */
.field-input .toggle-pass {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: all var(--transition);
  font-size: 0.95rem;
}
.field-input .toggle-pass:hover {
  color: var(--primary);
  background: rgba(168, 85, 247, 0.08);
}

/* ===== Tooltip ===== */
[data-tooltip] {
  position: relative;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  white-space: nowrap;
  background: var(--label-bg);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: all 0.18s ease;
  border: 1px solid var(--glass-border);
}
[data-tooltip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ===== Password Generator ===== */
.gen-pass {
  position: absolute;
  right: 46px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  transition: all var(--transition);
  font-size: 0.85rem;
}
.gen-pass:hover {
  color: var(--primary);
  background: rgba(168, 85, 247, 0.08);
}

/* ===== Row (remember + forgot) ===== */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 12px;
}

/* ===== Custom Checkbox ===== */
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.checkbox.terms {
  margin-bottom: 1rem;
}
.checkbox input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
.checkbox .check {
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 4px;
  border: 2px solid var(--text-muted);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}
.checkbox .check::after {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 0.6rem;
  color: #fff;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.checkbox input:checked + .check {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox input:focus-visible + .check {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}
.checkbox input:checked + .check::after {
  opacity: 1;
  transform: scale(1);
}
.checkbox:hover .check {
  border-color: var(--primary);
}
.checkbox .label-text a {
  color: var(--primary);
  text-decoration: none;
}
.checkbox .label-text a:hover {
  text-decoration: underline;
}

/* ===== Password Strength ===== */
.strength-bar {
  height: 3px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.06);
  margin-top: 8px;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--transition);
}
.strength-bar.visible {
  opacity: 1;
}
.strength-fill {
  height: 100%;
  width: 0%;
  border-radius: 2px;
  transition:
    width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.3s ease;
}
.strength-text {
  display: block;
  font-size: 0.72rem;
  margin-top: 3px;
  height: 14px;
  color: var(--text-muted);
  transition: color var(--transition);
  font-weight: 500;
}

/* ===== Character Counter ===== */
.char-counter {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 2px;
  height: 14px;
  transition: color var(--transition);
}
.char-counter.warn {
  color: #f59e0b;
}
.char-counter.danger {
  color: #ef4444;
}

/* ===== Links ===== */
.link,
.link-button {
  color: var(--secondary);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity var(--transition);
}
.link:hover,
.link-button:hover {
  opacity: 0.8;
}
.link-button {
  display: inline;
  padding: 0;
  border: none;
  background: none;
  font-family: inherit;
  line-height: inherit;
  cursor: pointer;
}

/* ===== Button ===== */
.btn {
  position: relative;
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #fff;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  overflow: hidden;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
  box-shadow: 0 4px 16px rgba(255, 0, 128, 0.25);
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn:focus-visible {
  outline-offset: 3px;
}
.btn:disabled {
  opacity: 0.7;
  cursor: wait;
  transform: none;
}
.btn-spinner {
  display: none;
  animation: spin 0.8s linear infinite;
}
.btn.loading .btn-text {
  visibility: hidden;
}
.btn.loading .btn-spinner {
  display: block;
  position: absolute;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== Button Variants ===== */
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
  box-shadow: none;
}
.btn-outline:hover {
  background: rgba(168, 85, 247, 0.08);
  box-shadow: none;
}
.btn-ghost {
  background: transparent;
  border: none;
  color: var(--text-muted);
  box-shadow: none;
}
.btn-ghost:hover {
  color: var(--primary);
  background: rgba(168, 85, 247, 0.06);
  box-shadow: none;
}

/* ===== Ripple Effect ===== */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  pointer-events: none;
  animation: rippleAnim 0.6s ease-out forwards;
}
@keyframes rippleAnim {
  0% { width: 0; height: 0; opacity: 0.5; }
  100% { width: 200px; height: 200px; opacity: 0; transform: scale(2.5); }
}

/* ===== Switch Text ===== */
.switch-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 20px;
}
.switch-text .link {
  font-weight: 600;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 90%;
  max-width: 380px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  font-size: 0.88rem;
  font-weight: 500;
  pointer-events: auto;
  animation: toastIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
  color: var(--text);
}
.toast.toast-out {
  animation: toastOut 0.3s ease both;
}
.toast i {
  font-size: 1rem;
}
.toast.success {
  border-left: 3px solid #22c55e;
}
.toast.success i {
  color: #22c55e;
}
.toast.error {
  border-left: 3px solid #ef4444;
}
.toast.error i {
  color: #ef4444;
}
@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateY(-16px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes toastOut {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-16px) scale(0.95);
  }
}

/* ===== Shake ===== */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-6px);
  }
  40%,
  80% {
    transform: translateX(6px);
  }
}
.shake {
  animation: shake 0.45s ease;
}

/* ===== Focus-visible ===== */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.card :focus-visible {
  outline-color: var(--accent);
}

/* ===== No-JS Fallback ===== */
.nojs-warning {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  color: #fff;
  font-family: Inter, sans-serif;
  font-size: 1.1rem;
  z-index: 9999;
}

/* ===== Selection ===== */
::selection {
  background: var(--primary);
  color: #fff;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.3);
  border-radius: 3px;
}

/* ===== Theme Toggle ===== */
.theme-toggle {
  position: fixed;
  top: 30px;
  right: 20px;
  z-index: 50;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}
.theme-toggle:hover {
  color: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.1);
}
.theme-toggle .fa-sun { display: none; }
.theme-toggle .fa-moon { display: block; }
[data-theme="light"] .theme-toggle .fa-sun { display: block; }
[data-theme="light"] .theme-toggle .fa-moon { display: none; }

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  .orb,
  .card,
  .panel,
  .form,
  .toast,
  .avatar,
  .avatar::after,
  .ripple,
  .shake,
  .skeleton {
    animation: none !important;
  }
  .terms-page section {
    opacity: 1 !important;
    animation: none !important;
  }
  * {
    transition-duration: 0.01ms !important;
  }
}

/* ===== Shimmer Loading ===== */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--input-bg) 25%, rgba(168, 85, 247, 0.06) 50%, var(--input-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
  .card-inner {
    padding: 28px 20px 24px;
  }
  .title {
    font-size: 1.5rem;
  }
  .subtitle {
    font-size: 0.85rem;
    margin-bottom: 24px;
  }
  .field {
    margin-bottom: 16px;
  }
  .field-input .input {
    height: 46px;
    padding-left: 38px;
    font-size: 0.9rem;
  }
  .field-input label {
    left: 38px;
    font-size: 0.85rem;
  }
  .field-input .input:focus + label,
  .field-input .input:not(:placeholder-shown) + label {
    left: 10px;
    font-size: 0.7rem;
  }
  .field-input .icon {
    left: 13px;
    font-size: 0.9rem;
  }
  .field-input .toggle-pass {
    width: 32px;
    height: 32px;
    right: 6px;
  }
  .btn {
    height: 46px;
    font-size: 0.95rem;
  }
  .row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .orb--1 {
    width: 250px;
    height: 250px;
    filter: blur(60px);
  }
  .orb--2 {
    width: 200px;
    height: 200px;
    filter: blur(60px);
  }
}

/* ===== Print ===== */
@media print {
  .bg-orbs {
    display: none !important;
  }
  .card {
    box-shadow: none !important;
    border: 1px solid #aaa !important;
  }
}

/* ===== Screen-reader only ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
