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

/* ===== CSS VARIABLES ===== */
:root {
  --brand: #00aaff;
  --brand-dim: rgba(0,170,255,0.10);
  --brand-glow: rgba(0,170,255,0.30);
  --brand-dark: #0088cc;
  --success: #00c07a;
  --success-dim: rgba(0,192,122,0.10);
  --error: #e8334a;
  --error-dim: rgba(232,51,74,0.10);
  --warn: #f59e0b;
  --font-display: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);
}

[data-theme="light"] {
  --bg: #f3f8ff;
  --bg2: #e8f2ff;
  --surface: #ffffff;
  --surface2: #f7faff;
  --border: rgba(0,100,200,0.10);
  --border-focus: rgba(0,170,255,0.55);
  --text: #0d1a2e;
  --text-muted: #8096b8;
  --text-sub: #4d6480;
  --shadow: rgba(0,80,180,0.10);
  --card-glow: rgba(0,170,255,0.05);
  --grid-color: rgba(0,120,255,0.06);
}

[data-theme="dark"] {
  --bg: #080c12;
  --bg2: #0d1117;
  --surface: #111820;
  --surface2: #161e2a;
  --border: rgba(255,255,255,0.07);
  --border-focus: rgba(0,170,255,0.5);
  --text: #eef2ff;
  --text-muted: #6b7a99;
  --text-sub: #8896b3;
  --shadow: rgba(0,0,0,0.6);
  --card-glow: rgba(0,170,255,0.05);
  --grid-color: rgba(255,255,255,0.04);
}

/* ===== BASE ===== */
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s, color 0.3s;
}

/* ===== ANIMATED BG ===== */
.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.bg-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(0,170,255,0.12), transparent 70%);
  top: -150px; right: -100px;
  animation: orbFloat 8s ease-in-out infinite;
}
.bg-orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(0,170,255,0.07), transparent 70%);
  bottom: -100px; left: -100px;
  animation: orbFloat 10s ease-in-out infinite reverse;
}

@keyframes orbFloat {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 4px 20px var(--shadow);
}
.theme-toggle:hover {
  border-color: var(--brand);
  color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-dim);
  transform: scale(1.08);
}
.theme-toggle svg { width: 18px; height: 18px; }

/* ===== WRAPPER ===== */
.wrapper {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
}

/* ===== LOGO ===== */
.logo-wrap {
  text-align: center;
  margin-bottom: 28px;
  animation: fadeUp 0.6s ease both;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}
.logo-img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  box-shadow: 0 6px 24px var(--brand-glow);
  background: var(--surface);
  padding: 4px;
  border: 1.5px solid var(--border);
}
/* Fallback icon if logo.png not found */
.logo-icon-fallback {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--brand), #0066cc);
  border-radius: 12px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px var(--brand-glow);
  position: relative;
  overflow: hidden;
}
.logo-icon-fallback::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.2), transparent);
}
.logo-icon-fallback svg {
  width: 24px; height: 24px;
  fill: white;
  position: relative;
  z-index: 1;
}
.logo-text {
  font-size: 1.55rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.5px;
}
.logo-text span {
  color: var(--brand);
}
.logo-sub {
  margin-top: 8px;
  font-size: 0.83rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* ===== CARD ===== */
.card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.8) inset,
    0 20px 60px var(--shadow),
    0 0 0 1px rgba(0,170,255,0.04);
  position: relative;
  overflow: hidden;
  animation: fadeUp 0.7s ease 0.1s both;
}
.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  opacity: 0.6;
}

.card-header {
  margin-bottom: 24px;
}
.card-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.4px;
  margin-bottom: 4px;
}
.card-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== FORM ===== */
.form { display: flex; flex-direction: column; gap: 15px; }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ===== INPUTS ===== */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon {
  position: absolute;
  left: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  pointer-events: none;
  transition: color var(--transition);
}
.input-icon svg { width: 15px; height: 15px; stroke-width: 2; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"] {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px 11px 38px;
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  -webkit-appearance: none;
}
input::placeholder { color: var(--text-muted); font-weight: 400; opacity: 0.7; }
input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
.input-wrap:focus-within .input-icon { color: var(--brand); }

/* Username status */
.username-status {
  position: absolute;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
  transition: all var(--transition);
  letter-spacing: 0.3px;
}
.username-status.checking { color: var(--warn); }
.username-status.available { color: var(--success); }
.username-status.taken { color: var(--error); }
.username-status .dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
}
.checking .dot { animation: pulse 0.8s infinite; }

@keyframes pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.6); }
}

/* Password toggle */
.pwd-toggle {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 5px;
  border-radius: 6px;
  transition: color var(--transition), background var(--transition);
}
.pwd-toggle:hover { color: var(--brand); background: var(--brand-dim); }
.pwd-toggle svg { width: 15px; height: 15px; stroke-width: 2; }

/* Password strength */
.strength-bar {
  display: flex;
  gap: 4px;
  margin-top: 7px;
}
.strength-seg {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--border);
  transition: background 0.3s ease;
}
.strength-label {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-top: 4px;
  font-weight: 600;
  transition: color 0.3s;
}

/* Field error */
.field-error {
  font-size: 0.72rem;
  color: var(--error);
  font-weight: 500;
  display: none;
  align-items: center;
  gap: 4px;
  margin-top: 1px;
}
.field-error.show { display: flex; }
.field-error svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Input states */
input.invalid { border-color: var(--error) !important; box-shadow: 0 0 0 3px var(--error-dim) !important; }
input.valid { border-color: var(--success) !important; }

/* ===== DIVIDER ===== */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
}
.divider-line { flex: 1; height: 1px; background: var(--border); }
.divider-text { font-size: 0.7rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.4px; }

/* ===== TERMS ===== */
.terms {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.terms:hover { border-color: var(--brand); background: var(--brand-dim); }
.terms input[type="checkbox"] {
  width: 15px; height: 15px;
  min-width: 15px;
  padding: 0;
  margin-top: 1px;
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--brand);
}
.terms-text {
  font-size: 0.77rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.terms-text a { color: var(--brand); text-decoration: none; font-weight: 600; }
.terms-text a:hover { text-decoration: underline; }

/* ===== SUBMIT BUTTON ===== */
.btn-submit {
  position: relative;
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--brand), #0070cc);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-display);
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.2px;
  cursor: pointer;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  box-shadow: 0 6px 24px var(--brand-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.btn-submit::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent);
  pointer-events: none;
}
.btn-submit:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 10px 36px var(--brand-glow);
}
.btn-submit:active:not(:disabled) { transform: translateY(0); }
.btn-submit:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-submit .btn-spinner {
  width: 17px; height: 17px;
  border: 2.5px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}
.btn-submit.loading .btn-text { display: none; }
.btn-submit.loading .btn-spinner { display: block; }
.btn-submit svg { width: 17px; height: 17px; flex-shrink: 0; }

@keyframes spin { to { transform: rotate(360deg); } }

/* Ripple */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.22);
  transform: scale(0);
  animation: rippleAnim 0.6s linear;
  pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(4); opacity: 0; } }

/* ===== SIGN IN LINK ===== */
.signin-link {
  text-align: center;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 20px;
}
.signin-link a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
  transition: opacity var(--transition);
}
.signin-link a:hover { opacity: 0.8; text-decoration: underline; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: 100%;
  max-width: 400px;
  padding: 0 16px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 14px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15), 0 1px 0 rgba(255,255,255,0.8) inset;
  width: 100%;
  pointer-events: all;
  cursor: pointer;
  animation: toastIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s;
}
.toast:hover { transform: scale(1.01); }
.toast.hiding { animation: toastOut 0.3s ease forwards; }

.toast.success { background: rgba(240,255,248,0.97); border: 1.5px solid rgba(0,192,122,0.2); }
.toast.error { background: rgba(255,242,244,0.97); border: 1.5px solid rgba(232,51,74,0.2); }
.toast.warn { background: rgba(255,251,235,0.97); border: 1.5px solid rgba(245,158,11,0.25); }
.toast.info { background: rgba(235,248,255,0.97); border: 1.5px solid rgba(0,170,255,0.2); }

[data-theme="dark"] .toast.success { background: rgba(0,20,12,0.95); border-color: rgba(0,192,122,0.2); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
[data-theme="dark"] .toast.error { background: rgba(20,0,8,0.95); border-color: rgba(232,51,74,0.2); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
[data-theme="dark"] .toast.warn { background: rgba(20,15,0,0.95); border-color: rgba(245,158,11,0.25); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
[data-theme="dark"] .toast.info { background: rgba(0,10,20,0.95); border-color: rgba(0,170,255,0.2); box-shadow: 0 8px 32px rgba(0,0,0,0.5); }

.toast-progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  border-radius: 2px;
  animation: toastProgress linear forwards;
}
.toast.success .toast-progress { background: var(--success); }
.toast.error .toast-progress { background: var(--error); }
.toast.warn .toast-progress { background: var(--warn); }
.toast.info .toast-progress { background: var(--brand); }

.toast-icon {
  width: 34px; height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toast-icon svg { width: 17px; height: 17px; stroke-width: 2.5; }
.toast.success .toast-icon { background: var(--success-dim); color: var(--success); }
.toast.error .toast-icon { background: var(--error-dim); color: var(--error); }
.toast.warn .toast-icon { background: rgba(245,158,11,0.12); color: var(--warn); }
.toast.info .toast-icon { background: var(--brand-dim); color: var(--brand); }

.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 0.86rem; font-weight: 700; margin-bottom: 2px; }
.toast.success .toast-title { color: var(--success); }
.toast.error .toast-title { color: var(--error); }
.toast.warn .toast-title { color: var(--warn); }
.toast.info .toast-title { color: var(--brand); }

.toast-msg { font-size: 0.76rem; color: var(--text-sub); line-height: 1.4; font-weight: 400; }

.toast-close {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 3px;
  border-radius: 4px;
  transition: color var(--transition);
  flex-shrink: 0;
}
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 13px; height: 13px; stroke-width: 2.5; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}
@keyframes toastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .card { padding: 26px 18px; }
  .field-row { grid-template-columns: 1fr; }
}