/* ============================================================
   AI SandBox — AUTH PAGES (Login & Signup)
   ============================================================ */

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

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

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

body {
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button, input { font: inherit; }
a { color: inherit; text-decoration: none; }

/* ────────────────────────────────────────────────────────────
   AMBIENT
   ──────────────────────────────────────────────────────────── */

body::before,
body::after {
  content: "";
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
  filter: blur(90px);
}

body::before {
  width: 500px;
  height: 500px;
  top: -150px;
  left: -100px;
  background: radial-gradient(circle, rgba(99,102,241,0.08) 0%, transparent 70%);
  animation: orb-drift 20s ease-in-out infinite;
}

body::after {
  width: 400px;
  height: 400px;
  bottom: -100px;
  right: -80px;
  background: radial-gradient(circle, rgba(168,85,247,0.06) 0%, transparent 70%);
  animation: orb-drift 28s ease-in-out infinite reverse;
}

/* ────────────────────────────────────────────────────────────
   SHELL
   ──────────────────────────────────────────────────────────── */

.auth-shell {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(400px, 480px);
  z-index: 1;
}

/* ────────────────────────────────────────────────────────────
   STORY / LEFT SIDE
   ──────────────────────────────────────────────────────────── */

.auth-story {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  padding: clamp(28px, 5vw, 64px);
  min-height: 100vh;
}

/* Brand */
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  animation: fadeUp var(--dur-enter) var(--ease) both;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #e4e4e7, #71717a);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 4px 12px rgba(0,0,0,0.5);
}

.brand-mark svg {
  width: 16px;
  height: 16px;
  fill: #09090b;
}

.brand-wordmark {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  letter-spacing: -0.01em;
  color: var(--ink-1);
}

/* Copy */
.auth-copy {
  animation: fadeUp var(--dur-enter) var(--ease) 80ms both;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-xs);
  font-weight: var(--weight-semi);
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.eyebrow-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
}

.auth-copy h1 {
  font-size: clamp(36px, 5vw, 64px);
  font-weight: var(--weight-bold);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink-0);
  max-width: 600px;
  margin-bottom: 18px;
}

.auth-copy p:not(.eyebrow) {
  font-size: var(--text-md);
  color: var(--text-soft);
  max-width: 520px;
  line-height: 1.7;
}

/* Visual mockup */
.auth-visual {
  width: min(540px, 100%);
  padding: 16px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xl);
  background: rgba(15,15,16,0.8);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  animation: fadeUp var(--dur-enter) var(--ease) 160ms both;
}

.visual-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border-0);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--surface-1);
}

.visual-toolbar span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border-1);
}

.visual-command {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding: 13px 14px;
  border: 1px solid var(--border-0);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.visual-command kbd {
  margin-left: auto;
  padding: 3px 8px;
  border: 1px solid var(--border-1);
  border-radius: 6px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--surface-1);
}

.command-icon-svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--border-0);
  border-radius: var(--radius-md);
  background: var(--surface-0);
}

.visual-grid span {
  height: 72px;
  border: 1px solid var(--border-0);
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface-0) 100%);
}

/* Benefits */
.auth-benefits {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  list-style: none;
  animation: fadeUp var(--dur-enter) var(--ease) 240ms both;
}

.auth-benefits li {
  padding: 7px 13px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-pill);
  background: var(--surface-1);
  color: var(--text-soft);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* ────────────────────────────────────────────────────────────
   AUTH PANEL / RIGHT SIDE
   ──────────────────────────────────────────────────────────── */

.auth-panel {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: clamp(24px, 4vw, 52px) clamp(24px, 4vw, 52px);
  border-left: 1px solid var(--border-0);
  background: rgba(9,9,11,0.5);
  backdrop-filter: blur(24px) saturate(160%);
}

/* Auth card */
.auth-card {
  width: 100%;
  max-width: 400px;
  animation: scaleIn 420ms var(--ease) both;
}

.auth-header {
  margin-bottom: 28px;
}

.auth-header h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: -0.03em;
  color: var(--ink-0);
  margin: 6px 0 8px;
}

.auth-header p:not(.eyebrow) {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.55;
}

/* Alert */
.auth-alert {
  display: none;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-1);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.auth-alert.show {
  display: block;
  animation: fadeUp 220ms var(--ease) both;
}

.auth-alert.error {
  border-color: rgba(239,68,68,0.3);
  color: #fca5a5;
  background: rgba(239,68,68,0.08);
}

.auth-alert.success {
  border-color: rgba(34,197,94,0.3);
  color: #86efac;
  background: rgba(34,197,94,0.08);
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-soft);
}

.field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border-1);
  border-radius: var(--radius-md);
  outline: none;
  background: var(--surface-1);
  color: var(--text);
  font-size: var(--text-sm);
  transition: border-color var(--dur-base) var(--ease),
              background var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease);
}

.field input::placeholder { color: var(--text-muted); }

.field input:focus {
  border-color: var(--border-focus);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06);
}

.field small {
  min-height: 16px;
  font-size: var(--text-xs);
  color: var(--error);
}

.field.invalid input {
  border-color: rgba(239,68,68,0.5);
  animation: shake 200ms var(--ease);
}

/* Form row */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: -2px;
}

.check-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.check-field input { accent-color: var(--ink-0); }

.text-link {
  font-size: var(--text-sm);
  color: var(--text-soft);
  font-weight: var(--weight-medium);
  transition: color var(--dur-fast) var(--ease);
}

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

/* Auth buttons */
.btn-auth {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 44px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  cursor: pointer;
  transition:
    transform var(--dur-fast) var(--ease-spring),
    background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    opacity var(--dur-fast) var(--ease);
}

.btn-auth:active { transform: translateY(1px) scale(0.985); }
.btn-auth:disabled { opacity: 0.6; cursor: wait; }

.btn-primary {
  background: var(--ink-0);
  color: var(--ink-8);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.1), 0 4px 16px rgba(0,0,0,0.4);
  margin-top: 4px;
}

.btn-primary:hover {
  background: var(--ink-1);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.15), 0 6px 24px rgba(0,0,0,0.5);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-1);
  border-color: var(--border-1);
  color: var(--text-soft);
}

.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-2);
  color: var(--text);
}

/* Provider logo */
.provider-logo {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.04em;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-0);
}

/* Social grid */
.social-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.social-grid.two { grid-template-columns: repeat(2, 1fr); }

/* Guest icon */
.icon-user {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3f3f46, #27272a);
  display: inline-block;
  border: 1px solid var(--border-1);
}

/* Switch link */
.auth-switch {
  margin-top: 22px;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--text-soft);
  font-weight: var(--weight-semi);
  margin-left: 4px;
  transition: color var(--dur-fast) var(--ease);
}

.auth-switch a:hover { color: var(--text); }

/* ────────────────────────────────────────────────────────────
   RESPONSIVE
   ──────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-story {
    min-height: auto;
    padding-bottom: 24px;
  }

  .auth-panel {
    min-height: auto;
    border-left: none;
    border-top: 1px solid var(--border-0);
  }

  .auth-copy h1 { font-size: clamp(32px, 6vw, 52px); }
}

@media (max-width: 640px) {
  .auth-story, .auth-panel { padding: 24px 20px; }
  .auth-visual { display: none; }
  .social-grid, .social-grid.two { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   OTP MODAL
   ============================================================ */

.otp-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6); /* Slightly darker overlay */
  backdrop-filter: blur(12px); /* Stronger blur for elements behind the modal */
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  padding: 20px; /* Prevents the card from touching screen edges on small devices */
}

.otp-card {
  width: 100%;
  max-width: 420px;
  padding: 40px 32px;
  
  /* Increased opacity and added inner blur to prevent see-through */
  background: rgba(15, 15, 16, 0.95); 
  backdrop-filter: blur(20px);
  
  border: 1px solid var(--border-1);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 20px 40px rgba(0, 0, 0, 0.4);
  
  animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  
  /* Flexbox guarantees perfect centering and symmetry */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.otp-card h2 {
  text-align: center;
  margin: 0 0 8px 0;
  font-size: var(--text-2xl); /* Matches your auth-header h2 */
  font-weight: var(--weight-bold);
  color: var(--ink-0);
  letter-spacing: -0.03em;
}

.otp-card p {
  text-align: center;
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.5;
  margin: 0;
}

.otp-email {
  display: block;
  text-align: center;
  margin-top: 4px;
  margin-bottom: 32px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semi);
  color: var(--text);
}

.otp-input-container {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 32px;
  width: 100%;
}

.otp-box {
  /* CRITICAL FIX: This allows the boxes to share space and shrink if needed */
  flex: 1 1 0px;
  min-width: 0; 
  max-width: 52px; /* Prevents them from getting too huge on desktop */
  height: 60px;
  
  /* Existing styles */
  border-radius: var(--radius-md);
  border: 1px solid var(--border-1);
  background: var(--surface-1);
  color: var(--text);
  text-align: center;
  
  /* Responsive font size so text doesn't clip when boxes shrink */
  font-size: clamp(18px, 5vw, 24px); 
  font-weight: var(--weight-bold);
  outline: none;
  transition: border-color var(--dur-base) var(--ease),
              background var(--dur-base) var(--ease),
              box-shadow var(--dur-base) var(--ease);
}

.otp-box:focus {
  border-color: var(--border-focus);
  background: var(--surface-2);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}

/* Optional but recommended: give the card itself a bit more breathing room on mobile */
@media (max-width: 480px) {
  .otp-card {
    padding: 32px 16px; 
  }
}

#verify-otp-btn {
  width: 100%;
  margin-bottom: 12px;
}

#resend-otp-btn {
  width: 100%;
  margin: 0;
}

.otp-card {
  transition: background 0.3s var(--ease), border-color 0.3s var(--ease), box-shadow 0.3s var(--ease);
}

.otp-card.error-state {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  box-shadow: 0 0 32px rgba(239, 68, 68, 0.2) !important;
} 

#otp-alert {
    display: none;
    margin-bottom: 15px;
    padding: 10px 14px;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
}

#otp-alert.error {
    background: rgba(255, 0, 0, 0.15);
    color: #ff6b6b;
    border: 1px solid rgba(255, 0, 0, 0.3);
}

#otp-alert.success {
    background: rgba(0, 255, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(0, 255, 128, 0.3);
} 