/* ── StaiClaw Auth Page — Dark Theme v4.0 — 2026-03-30 ──────────────────── */

:root {
  --brand:        #6366F1;
  --brand-dark:   #4F46E5;
  --brand-hover:  #8B5CF6;
  --brand-glow:   rgba(99,102,241,0.25);
  --brand-gradient: linear-gradient(135deg, #6366F1, #8B5CF6);
  --bg:           #0F172A;
  --surface:      #1E293B;
  --surface-2:    #263147;
  --border:       #334155;
  --text:         #F1F5F9;
  --text-muted:   #94A3B8;
  --text-subtle:  #64748B;
  --danger:       #EF4444;
  --warning:      #F59E0B;
  --success:      #10B981;
  --info:         #3B82F6;
  --radius:       14px;
  --radius-sm:    8px;
  --transition:   0.2s ease;
  --shadow-lg:    0 8px 32px rgba(0,0,0,0.5);
}

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

body.auth-page {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, 'PingFang SC', 'SF Pro Display', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  position: relative;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Gradient background */
body.auth-page::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% -10%, rgba(99,102,241,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, rgba(139,92,246,0.1) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* Grid dots pattern */
body.auth-page::after {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

/* ── Auth container ── */
.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

/* ── Brand header ── */
.auth-brand {
  text-align: center;
  margin-bottom: 32px;
}

.auth-brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  margin: 0 auto 14px;
  display: block;
  filter: drop-shadow(0 0 16px rgba(99,102,241,0.4));
}

.auth-brand-name {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.auth-brand-tag {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Card ── */
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

/* ── Tabs ── */
.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 28px;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  border: none;
  background: none;
  font-family: inherit;
}

.auth-tab.active {
  background: var(--brand-gradient);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.auth-tab:not(.active):hover {
  color: var(--text);
  background: rgba(255,255,255,0.05);
}

/* ── Form panels ── */
.auth-panel { display: none; }
.auth-panel.active {
  display: block;
  animation: fadeSlideUp 0.25s ease;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Form elements ── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.input-wrap { position: relative; }

.input-wrap .input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-subtle);
  font-size: 14px;
  pointer-events: none;
  transition: color var(--transition);
}

.input-wrap input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 42px 11px 40px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  -webkit-appearance: none;
}

.input-wrap input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.input-wrap input:focus + .input-icon,
.input-wrap input:focus ~ .input-icon {
  color: var(--brand);
}

.input-wrap input::placeholder { color: var(--text-subtle); }

/* Password toggle */
.input-wrap .input-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition);
}

.input-wrap .input-toggle:hover { color: var(--brand); }

/* ── Buttons ── */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #8B5CF6, #6366F1);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(99,102,241,0.5);
}

.btn-primary:active { transform: scale(0.98); }

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-primary .btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-primary.loading .btn-spinner { display: block; }
.btn-primary.loading .btn-text { opacity: 0.7; }

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

/* ── Forgot password link ── */
.forgot-link {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
  cursor: pointer;
  transition: color var(--transition);
}

.forgot-link:hover { color: var(--brand); }

/* ── Error / success messages ── */
.auth-msg {
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
  align-items: flex-start;
  gap: 8px;
  line-height: 1.4;
}

.auth-msg.visible { display: flex; }

.auth-msg.error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: #FCA5A5;
}

.auth-msg.success {
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.3);
  color: #6EE7B7;
}

.auth-msg.info {
  background: rgba(59,130,246,0.12);
  border: 1px solid rgba(59,130,246,0.3);
  color: #93C5FD;
}

/* ── Divider ── */
.auth-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin: 20px 0;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 40%;
  height: 1px;
  background: var(--border);
}

.auth-divider::before { left: 0; }
.auth-divider::after  { right: 0; }

/* ── Footer ── */
.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-footer a { color: var(--brand); text-decoration: none; }

/* ── Modal overlay ── */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,10,18,0.9);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(8px);
}

.auth-overlay.visible { display: flex; }

.overlay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  animation: fadeSlideUp 0.25s ease;
}

.overlay-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.overlay-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ── Code input ── */
.code-input-wrap {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

.code-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: 'Courier New', monospace;
  caret-color: var(--brand);
}

.code-digit:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.code-digit.filled {
  border-color: var(--brand);
  color: var(--brand);
}

/* ── Dev code badge ── */
.dev-code-badge {
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: #FCD34D;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dev-code-num {
  font-family: 'Courier New', monospace;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--warning);
}

/* ── Resend timer ── */
.resend-wrap {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}

.resend-btn {
  color: var(--brand);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12px;
  padding: 0;
  display: none;
  transition: color var(--transition);
}

.resend-btn:hover { color: var(--brand-hover); }
.resend-btn.visible { display: inline; }

/* ── Strength bar ── */
.password-strength {
  margin-top: 6px;
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
}

.strength-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  transition: width 0.3s ease, background 0.3s ease;
}

.strength-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .auth-card { padding: 24px 20px; }
  .auth-brand-name { font-size: 22px; }
  .code-digit { width: 40px; height: 48px; font-size: 18px; }
  .overlay-card { padding: 24px 20px; }
}
