
/* ── Base Auth Screen ── */
#auth-modal {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: var(--gray-900);
}

#auth-modal.screen {
  display: none;
}

#auth-modal.screen.active {
  display: flex;
}

/* ── Auth Layout: Split Screen ── */
.auth-backdrop {
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* ── LEFT PANEL: Brand Story ── */
.auth-left {
  flex: 1;
  min-width: 420px;
  max-width: 520px;
  background: linear-gradient(160deg, var(--primary-900) 0%, #0f2918 40%, var(--primary-800) 100%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 2.5rem 2.5rem 2rem;
  color: white;
}

.auth-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.025'%3E%3Cpath d='M40 40c0-11.046-8.954-20-20-20s-20 8.954-20 20 8.954 20 20 20 20-8.954 20-20zm40 0c0-11.046-8.954-20-20-20s-20 8.954-20 20 8.954 20 20 20 20-8.954 20-20z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.8;
  pointer-events: none;
}

/* Organic animated blobs */
.organic-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.12;
  pointer-events: none;
  animation: blobFloat 10s ease-in-out infinite;
}

.blob-1 {
  width: 350px;
  height: 350px;
  background: var(--primary-400);
  top: -80px;
  left: -80px;
  animation-delay: 0s;
}

.blob-2 {
  width: 280px;
  height: 280px;
  background: var(--accent-500);
  bottom: 5%;
  right: -40px;
  animation-delay: -4s;
  opacity: 0.08;
}

.blob-3 {
  width: 220px;
  height: 220px;
  background: var(--primary-300);
  top: 45%;
  left: 15%;
  animation-delay: -7s;
  opacity: 0.06;
}

@keyframes blobFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(25px, -25px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* Floating decorative leaves */
.floating-leaf {
  position: absolute;
  font-size: 1.5rem;
  opacity: 0.12;
  animation: leafFloat 14s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

.leaf-1 { top: 12%; left: 8%; animation-delay: 0s; }
.leaf-2 { top: 55%; left: 3%; animation-delay: -5s; font-size: 2rem; }
.leaf-3 { top: 28%; right: 12%; animation-delay: -9s; }
.leaf-4 { bottom: 22%; right: 8%; animation-delay: -3s; font-size: 1.2rem; }
.leaf-5 { top: 75%; left: 18%; animation-delay: -7s; font-size: 1.8rem; }

@keyframes leafFloat {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-18px) rotate(6deg); }
  50% { transform: translateY(-6px) rotate(-4deg); }
  75% { transform: translateY(-24px) rotate(10deg); }
}

/* Left panel content */
.auth-left-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.auth-left-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.auth-left-logo svg {
  width: 42px;
  height: 42px;
  filter: drop-shadow(0 2px 10px rgba(34,197,94,0.4));
}

.auth-left-logo span {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-left-headline {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.12;
  margin-bottom: 1rem;
  letter-spacing: -0.03em;
}

.auth-left-headline .highlight {
  background: linear-gradient(135deg, var(--primary-400), var(--accent-500));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-left-sub {
  font-size: 1rem;
  line-height: 1.65;
  opacity: 0.72;
  max-width: 340px;
  font-weight: 300;
}

/* Feature cards on left */
.auth-features {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 2rem 0;
}

.auth-feature-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  backdrop-filter: blur(8px);
  transition: all 0.3s ease;
}

.auth-feature-item:hover {
  background: rgba(255,255,255,0.09);
  transform: translateX(4px);
}

.auth-feature-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(34,197,94,0.25), rgba(245,158,11,0.15));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}

.auth-feature-text {
  font-size: 0.875rem;
  font-weight: 500;
}

.auth-feature-text small {
  display: block;
  font-size: 0.75rem;
  opacity: 0.55;
  font-weight: 400;
  margin-top: 1px;
}

/* Trust badges footer */
.auth-left-footer {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-wrap: wrap;
  padding-top: 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.mobile-trust-strip {
  display: none;
}

.trust-badge {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4rem 0.875rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.85;
}

/* ── RIGHT PANEL: Forms ── */
.auth-right {
  flex: 1.3;
  background: var(--gray-50);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem 2.5rem;
  position: relative;
  overflow-y: auto;
}

.auth-container {
  width: 100%;
  max-width: 440px;
  animation: authSlideUp 0.5s ease;
}

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

/* Mobile brand (visible only on small screens) */
.auth-mobile-brand {
  display: none;
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-mobile-brand .auth-logo {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75rem;
}

.auth-mobile-brand h1 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-800);
  margin-bottom: 0.25rem;
}

.auth-mobile-brand p {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* ── Tabs ── */
.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.75rem;
  background: var(--gray-100);
  padding: 4px;
  border-radius: 14px;
  width: fit-content;
}

.auth-tab {
  padding: 0.65rem 1.5rem;
  border: none;
  background: transparent;
  color: var(--gray-500);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 12px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  font-family: var(--font-sans);
}

.auth-tab:hover {
  color: var(--gray-700);
}

.auth-tab.active {
  background: white;
  color: var(--primary-700);
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

/* ── Forms ── */
.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: formFadeIn 0.4s ease;
}

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

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-wrapper {
  position: relative;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.875rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: white;
  color: var(--gray-900);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.1);
}

.form-group input::placeholder {
  color: var(--gray-400);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  padding-right: 2.75rem;
}

/* Password toggle */
.toggle-password {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.35;
  transition: opacity 0.2s;
  padding: 0.25rem;
  line-height: 1;
}

.toggle-password:hover {
  opacity: 0.7;
}

/* Phone input */
.phone-input-wrapper {
  display: flex;
  align-items: center;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: white;
  overflow: hidden;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.phone-input-wrapper:focus-within {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.1);
}

.phone-input-wrapper .country-code {
  padding: 0.875rem 0.875rem;
  background: var(--gray-100);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 0.9rem;
  border-right: 2px solid var(--gray-200);
  user-select: none;
}

.phone-input-wrapper input {
  border: none;
  flex: 1;
  padding: 0.875rem 1rem;
  font-size: 0.95rem;
  outline: none;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
}

.phone-input-wrapper input:focus {
  box-shadow: none;
}

/* OTP input */
.otp-input {
  width: 100%;
  padding: 1rem;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.75rem;
  text-align: center;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: white;
  color: var(--gray-900);
  font-family: var(--font-sans);
  transition: all 0.2s ease;
  outline: none;
}

.otp-input:focus {
  border-color: var(--primary-400);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.1);
}

/* ── Buttons ── */
.btn-block {
  width: 100%;
}

#auth-modal .btn-primary {
  background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.9rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 16px rgba(22,163,74,0.3);
  position: relative;
  overflow: hidden;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-decoration: none;
  line-height: 1.25;
}

#auth-modal .btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(22,163,74,0.4);
}

#auth-modal .btn-primary:active {
  transform: translateY(0);
}

#auth-modal .btn-primary::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.12), transparent);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}

#auth-modal .btn-primary:hover::after {
  opacity: 1;
}

#auth-modal .btn-secondary {
  background: white;
  color: var(--gray-600);
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
}

#auth-modal .btn-secondary:hover {
  border-color: var(--gray-300);
  background: var(--gray-50);
}

/* ── Divider ── */
.divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 0;
  color: var(--gray-400);
  font-size: 0.8rem;
  font-weight: 500;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gray-300), transparent);
}

.divider span {
  padding: 0 1rem;
}

/* ── OAuth Grid ── */
.oauth-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  color: var(--gray-700);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-sans);
}

.btn-oauth:hover {
  border-color: var(--gray-300);
  background: var(--gray-50);
  transform: translateY(-1px);
}

.btn-oauth svg {
  display: block;
  flex-shrink: 0;
}

.btn-phone {
  background: var(--primary-50);
  border-color: var(--primary-200);
  color: var(--primary-800);
}

.btn-phone:hover {
  background: var(--primary-100);
  border-color: var(--primary-300);
}

/* ── Role Selection Grid ── */
.role-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.role-card {
  padding: 0.75rem 0.5rem;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: white;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--gray-600);
  user-select: none;
}

.role-card:hover {
  border-color: var(--primary-300);
  background: var(--primary-50);
}

.role-card.active {
  border-color: var(--primary-500);
  background: var(--primary-50);
  color: var(--primary-700);
}

.role-card .role-emoji {
  font-size: 1.5rem;
  display: block;
  margin-bottom: 0.25rem;
  line-height: 1;
}

/* ── Forgot Password Link ── */
.forgot-password {
  text-align: right;
  font-size: 0.8rem;
  color: var(--primary-600);
  text-decoration: none;
  font-weight: 500;
  display: block;
  margin-top: -0.5rem;
  margin-bottom: 1rem;
  transition: opacity 0.2s;
}

.forgot-password:hover {
  text-decoration: underline;
  opacity: 0.8;
}

/* ── Phone Auth Section ── */
#phone-auth-section {
  animation: fadeIn 0.3s ease;
}

#otp-section {
  animation: slideDown 0.3s ease;
}

#mfa-screen {
  animation: fadeIn 0.3s ease;
  text-align: center;
}

#mfa-screen h3 {
  color: var(--primary-800);
  margin-bottom: 0.5rem;
  font-family: var(--font-display);
  font-size: 1.25rem;
}

#mfa-screen p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1.25rem;
}

.mfa-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
}

/* ── Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; }
  to { opacity: 1; max-height: 300px; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .auth-left {
    display: none;
  }

  .auth-right {
    flex: 1;
    padding: 1.5rem;
    justify-content: flex-start;
    padding-top: 2.5rem;
    padding-bottom: 2.5rem;
    -webkit-overflow-scrolling: touch;
  }

  .auth-mobile-brand {
    display: block;
  }

  .auth-container {
    max-width: 100%;
  }

  /* Mobile trust strip — visible only when left panel is hidden */
  .mobile-trust-strip {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .auth-right {
    padding: 1.25rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
  }

  .auth-tabs {
    width: 100%;
  }

  .auth-tab {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
  }

  .oauth-grid {
    grid-template-columns: 1fr;
  }

  .role-grid {
    grid-template-columns: 1fr 1fr;
  }

  .auth-left-headline {
    font-size: 1.75rem;
  }

  /* Prevent iOS zoom on input focus — 16px minimum */
  .form-group input,
  .form-group select,
  .phone-input-wrapper input,
  .otp-input {
    font-size: 16px;
  }

  /* Larger touch targets for mobile */
  .btn-primary,
  .btn-secondary,
  .btn-oauth {
    min-height: 48px;
  }

  .role-card {
    min-height: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
}

/* Ensure auth modal sits above everything */
#auth-modal {
  z-index: 9999;
}

/* Dark mode support for auth panel */
[data-theme="dark"] .auth-right {
  background: var(--gray-900);
}

[data-theme="dark"] .auth-container {
  color: var(--gray-100);
}

[data-theme="dark"] .auth-tabs {
  background: var(--gray-800);
}

[data-theme="dark"] .auth-tab {
  color: var(--gray-400);
}

[data-theme="dark"] .auth-tab.active {
  background: var(--gray-700);
  color: var(--primary-400);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .phone-input-wrapper,
[data-theme="dark"] .role-card,
[data-theme="dark"] .btn-oauth,
[data-theme="dark"] #auth-modal .btn-secondary {
  background: var(--gray-800);
  border-color: var(--gray-700);
  color: var(--gray-100);
}

[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(34,197,94,0.15);
}

[data-theme="dark"] .phone-input-wrapper .country-code {
  background: var(--gray-700);
  border-color: var(--gray-600);
  color: var(--gray-300);
}

[data-theme="dark"] .phone-input-wrapper:focus-within {
  border-color: var(--primary-500);
}

[data-theme="dark"] .role-card:hover {
  background: var(--gray-700);
  border-color: var(--primary-600);
}

[data-theme="dark"] .role-card.active {
  background: rgba(34,197,94,0.15);
  border-color: var(--primary-500);
  color: var(--primary-400);
}

[data-theme="dark"] .btn-oauth:hover,
[data-theme="dark"] #auth-modal .btn-secondary:hover {
  background: var(--gray-700);
  border-color: var(--gray-600);
}

[data-theme="dark"] .btn-phone {
  background: rgba(34,197,94,0.1);
  border-color: rgba(34,197,94,0.2);
  color: var(--primary-400);
}

[data-theme="dark"] .btn-phone:hover {
  background: rgba(34,197,94,0.2);
  border-color: rgba(34,197,94,0.3);
}

[data-theme="dark"] .auth-mobile-brand h1 {
  color: var(--primary-400);
}

[data-theme="dark"] .divider {
  color: var(--gray-500);
}

[data-theme="dark"] .divider::before,
[data-theme="dark"] .divider::after {
  background: linear-gradient(to right, transparent, var(--gray-700), transparent);
}

[data-theme="dark"] .otp-input {
  background: var(--gray-800);
  border-color: var(--gray-700);
  color: var(--gray-100);
}

[data-theme="dark"] .otp-input:focus {
  border-color: var(--primary-500);
}