/**
 * Login Page Styles
 * Aligned to iOS LoginView.swift / SignUpView.swift values.
 * Every iOS-sourced value is commented with its origin.
 */

body {
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  /* iOS: .background(Color.ccBackground) */
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
}

/* iOS LoginView: .padding(.horizontal, 16), .frame(maxWidth: 400) */
.auth-container {
  width: 100%;
  max-width: 400px; /* iOS: .frame(maxWidth: 400) */
  padding: 0 16px; /* iOS: .padding(.horizontal, 16) */
}

/* ─── Branding (above the card) ───
   iOS LoginView brandingSection:
     VStack(spacing: 8)
       .padding(.top, 48)
       .padding(.bottom, 32)
*/
.auth-branding {
  text-align: center;
  padding-top: 48px; /* iOS: .padding(.top, 48) */
  margin-bottom: 32px; /* iOS: .padding(.bottom, 32) */
}

/* iOS: Image("AppIconImage"), no extra wrapper margin needed */
.logo-large {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px; /* iOS: VStack(spacing: 8) between logo and title */
}

/* Fallback icon (not used when image is present) */
.logo-icon-large {
  width: 96px; /* iOS: .frame(width: 96, height: 96) */
  height: 96px; /* iOS: .frame(width: 96, height: 96) */
  background: var(--primary);
  color: white;
  border-radius: 20px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 20)) */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* iOS: .frame(width: 96, height: 96), .clipShape(RoundedRectangle(cornerRadius: 20)), .ccShadowMd() */
.logo-img-large {
  width: 96px; /* iOS: .frame(width: 96, height: 96) */
  height: 96px; /* iOS: .frame(width: 96, height: 96) */
  border-radius: 20px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 20)) */
  object-fit: contain;
  /* iOS: .ccShadowMd() — light: shadow(0.06, r4, y2) + shadow(0.04, r2, y1) */
  box-shadow: 0 2px 4px rgba(28, 25, 23, 0.06), 0 1px 2px rgba(28, 25, 23, 0.04);
}

/* iOS: .font(.system(size: 32, weight: .bold)), .padding(.top, 8) */
.app-title {
  font-size: 32px; /* iOS: size: 32 */
  font-weight: 700; /* iOS: weight: .bold */
  color: var(--text-primary); /* iOS: Color.ccTextPrimary */
  margin-top: 8px; /* iOS: .padding(.top, 8) */
  margin-bottom: 8px; /* iOS: VStack(spacing: 8) between title and subtitle */
}

/* iOS: .font(.system(size: 16)), Color.ccTextSecondary */
.app-subtitle {
  color: var(--text-secondary); /* iOS: Color.ccTextSecondary */
  font-size: 16px; /* iOS: size: 16 */
}

/* ─── Form Card ───
   iOS LoginView formCard:
     .padding(32)
     .background(Color.ccCard)
     .clipShape(RoundedRectangle(cornerRadius: 16))
     .ccShadowMd()
     .padding(.bottom, 48)
*/
.auth-form {
  display: none;
  background: var(--bg-card); /* iOS: Color.ccCard */
  padding: 32px; /* iOS: .padding(32) */
  border-radius: 16px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 16)) */
  /* iOS: .ccShadowMd() — light: shadow(0.06, r4, y2) + shadow(0.04, r2, y1) */
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.06), 0 1px 4px rgba(28, 25, 23, 0.04);
  margin-bottom: 48px; /* iOS: .padding(.bottom, 48) */
}

.auth-form.active {
  display: block;
}

/* iOS: .font(.system(size: 24, weight: .semibold)), .padding(.bottom, 24) */
.auth-form h2 {
  text-align: center;
  font-size: 24px; /* iOS: size: 24 */
  font-weight: 600; /* iOS: weight: .semibold */
  margin-bottom: 24px; /* iOS: .padding(.bottom, 24) */
  color: var(--text-primary); /* iOS: Color.ccTextPrimary */
}

/* ─── Form Fields ───
   iOS LoginView:
     VStack(alignment: .leading, spacing: 8) for label-to-input gap
     .padding(.bottom, 16) between fields
*/

/* iOS: VStack .padding(.bottom, 16) */
.auth-form .form-group {
  margin-bottom: 16px; /* iOS: .padding(.bottom, 16) */
}

/* iOS: .font(.system(size: 14, weight: .medium)), spacing: 8 below label */
.auth-form .form-label {
  display: block;
  margin-bottom: 8px; /* iOS: VStack(spacing: 8) between label and input */
  font-weight: 500; /* iOS: weight: .medium */
  font-size: 14px; /* iOS: size: 14 */
  color: var(--text-primary); /* iOS: Color.ccTextPrimary */
}

/* iOS: .font(.system(size: 16)), .padding(12), .frame(minHeight: 44),
        .clipShape(RoundedRectangle(cornerRadius: 8)),
        .strokeBorder(Color.ccBorder, lineWidth: 1) */
.auth-form .form-input {
  width: 100%;
  padding: 12px; /* iOS: .padding(12) */
  min-height: 44px; /* iOS: .frame(minHeight: 44) */
  border: 1px solid var(--border-color); /* iOS: .strokeBorder(Color.ccBorder, lineWidth: 1) */
  border-radius: 8px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 8)) */
  background: var(--bg-card); /* iOS: .background(Color.ccCard) */
  color: var(--text-primary); /* iOS: Color.ccTextPrimary */
  font-size: 16px; /* iOS: .font(.system(size: 16)) — also prevents iOS zoom */
  transition: border-color 0.2s;
}

.auth-form .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ─── Sign In / Create Account Button ───
   iOS LoginView:
     .frame(height: 44)
     .background(Color.ccPrimary)
     .clipShape(RoundedRectangle(cornerRadius: 8))
     Text: .font(.system(size: 13, weight: .medium)), .foregroundStyle(.white)
*/
.auth-form .btn-primary.btn-block {
  width: 100%;
  height: 44px; /* iOS: .frame(height: 44) */
  min-height: 44px; /* iOS: .frame(height: 44) */
  background: var(--primary); /* iOS: Color.ccPrimary */
  color: white; /* iOS: .foregroundStyle(.white) */
  border: none;
  border-radius: 8px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 8)) */
  font-size: 13px; /* iOS: size: 13 */
  font-weight: 500; /* iOS: weight: .medium */
  cursor: pointer;
  transition: opacity 0.2s;
}

.auth-form .btn-primary.btn-block:hover {
  opacity: 0.9;
}

/* ─── Error Message ───
   iOS LoginView errorSection:
     .font(.system(size: 14))
     .foregroundStyle(Color(hex: "EF4444"))
     .padding(.horizontal, 16), .padding(.vertical, 12)
     .background(Color(hex: "EF4444").opacity(0.1))
     .strokeBorder(cornerRadius: 8, lineWidth: 1)
     .padding(.bottom, 16)
*/
.error-message {
  background: rgba(239, 68, 68, 0.1); /* iOS: Color(hex: "EF4444").opacity(0.1) */
  border: 1px solid var(--danger); /* iOS: .strokeBorder(Color(hex: "EF4444"), lineWidth: 1) */
  color: var(--danger); /* iOS: .foregroundStyle(Color(hex: "EF4444")) */
  padding: 12px 16px; /* iOS: .padding(.vertical, 12), .padding(.horizontal, 16) */
  border-radius: 8px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 8)) */
  margin-bottom: 16px; /* iOS: .padding(.bottom, 16) */
  font-size: 14px; /* iOS: .font(.system(size: 14)) */
}

/* ─── Divider "or continue with" ───
   iOS LoginView:
     HStack with Rectangle().frame(height: 1).foregroundStyle(Color.ccBorder)
     Text: .font(.system(size: 14)), Color.ccTextSecondary
     .padding(.horizontal, 16) on text
     .padding(.vertical, 24) on HStack
*/
.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0; /* iOS: .padding(.vertical, 24) */
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid var(--border-color); /* iOS: Rectangle().frame(height: 1).foregroundStyle(Color.ccBorder) */
}

.auth-divider span {
  padding: 0 16px; /* iOS: .padding(.horizontal, 16) */
  color: var(--text-secondary); /* iOS: Color.ccTextSecondary */
  font-size: 14px; /* iOS: .font(.system(size: 14)) */
  white-space: nowrap;
}

/* ─── Social Buttons ───
   iOS LoginView:
     HStack(spacing: 12)
     Each button: .frame(height: 44), .clipShape(RoundedRectangle(cornerRadius: 8))
     Google button: .strokeBorder(Color.ccBorder, lineWidth: 1), .background(Color.ccCard)
       HStack(spacing: 8), icon 20x20, Text .font(.system(size: 15, weight: .medium))
*/
.social-buttons {
  display: flex;
  gap: 12px; /* iOS: HStack(spacing: 12) */
}

.btn-social {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px; /* iOS: HStack(spacing: 8) */
  height: 44px; /* iOS: .frame(height: 44) */
  min-height: 44px; /* iOS: .frame(height: 44) */
  padding: 0 16px;
  border: 1px solid var(--border-color); /* iOS: .strokeBorder(Color.ccBorder, lineWidth: 1) */
  border-radius: 8px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 8)) */
  background: var(--bg-card); /* iOS: .background(Color.ccCard) */
  color: var(--text-primary); /* iOS: Color.ccTextPrimary */
  font-size: 15px; /* iOS: .font(.system(size: 15, weight: .medium)) */
  font-weight: 500; /* iOS: weight: .medium */
  cursor: pointer;
  transition: all 0.2s;
}

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

/* iOS: .signInWithAppleButtonStyle(colorScheme == .dark ? .white : .black) */
.btn-apple {
  background: #000;
  color: #fff;
  border-color: #000;
}

.btn-apple:hover {
  background: #333;
  border-color: #333;
}

[data-theme="dark"] .btn-apple {
  background: #fff;
  color: #000;
  border-color: #fff;
}

[data-theme="dark"] .btn-apple:hover {
  background: #eee;
  border-color: #eee;
}

/* ─── Google icon size ───
   iOS: GoogleLogoSVG().frame(width: 20, height: 20)
*/
.btn-social svg {
  width: 20px; /* iOS: .frame(width: 20, height: 20) */
  height: 20px; /* iOS: .frame(width: 20, height: 20) */
  flex-shrink: 0;
}

/* ─── Passkey Button ───
   iOS LoginView:
     .padding(.top, 16)
     .frame(height: 44)
     .background(Color.ccPrimary.opacity(0.1))
     .clipShape(RoundedRectangle(cornerRadius: 8))
     Text: .font(.system(size: 15, weight: .medium)), Color.ccPrimary
     Icon: .font(.system(size: 16))
*/
#passkeyLoginSection {
  margin-top: 16px; /* iOS: .padding(.top, 16) */
}

#passkeyLoginSection .auth-divider {
  margin: 16px 0; /* Tighter divider above passkey */
}

#passkeyLoginBtn {
  width: 100%;
  height: 44px; /* iOS: .frame(height: 44) */
  min-height: 44px; /* iOS: .frame(height: 44) */
  background: var(--primary-light); /* iOS: Color.ccPrimary.opacity(0.1) */
  color: var(--primary); /* iOS: .foregroundStyle(Color.ccPrimary) */
  border: none;
  border-radius: 8px; /* iOS: .clipShape(RoundedRectangle(cornerRadius: 8)) */
  font-size: 15px; /* iOS: .font(.system(size: 15, weight: .medium)) */
  font-weight: 500; /* iOS: weight: .medium */
  cursor: pointer;
  transition: opacity 0.2s;
}

#passkeyLoginBtn:hover {
  opacity: 0.85;
}

/* ─── Footer Links ───
   iOS LoginView:
     HStack(spacing: 0), .padding(.top, 24)
     Button text: .font(.system(size: 14)), Color.ccPrimary
     Dot separator: .font(.system(size: 14)), Color.ccTextSecondary
*/
.auth-links {
  text-align: center;
  margin-top: 24px; /* iOS: .padding(.top, 24) */
}

.link-btn {
  background: none;
  border: none;
  color: var(--primary); /* iOS: .foregroundStyle(Color.ccPrimary) */
  font-size: 14px; /* iOS: .font(.system(size: 14)) */
  cursor: pointer;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

/* iOS: Text(" · "), .font(.system(size: 14)), Color.ccTextSecondary */
.link-divider {
  color: var(--text-secondary); /* iOS: Color.ccTextSecondary */
  font-size: 14px; /* iOS: .font(.system(size: 14)) */
  margin: 0; /* iOS: HStack(spacing: 0) — no extra margin */
}

/* ─── Dark Mode Shadows ───
   iOS Spacing.swift CCShadowMdModifier:
     dark: shadow(color: black.opacity(0.4), radius: 2, y: 1)
*/
[data-theme="dark"] .logo-img-large {
  /* iOS: dark .ccShadowMd() — shadow(black.opacity(0.4), r2, y1) */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .auth-form {
  /* iOS: dark .ccShadowMd() — shadow(black.opacity(0.4), r2, y1) */
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

/* ============================================
   Auth Loading Screen
   ============================================ */
.auth-loading {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  z-index: 1000;
}

.auth-loading-content {
  text-align: center;
}

.auth-loading-content .logo-large {
  margin-bottom: 1.5rem;
}

.auth-loading-content p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 1rem;
}

.loading-bar {
  width: 200px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  overflow: hidden;
  margin: 0 auto;
}

.loading-bar-progress {
  height: 100%;
  width: 30%;
  background: var(--primary);
  border-radius: 2px;
  animation: loading-progress 1.2s ease-in-out infinite;
}

@keyframes loading-progress {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(250%);
  }
  100% {
    transform: translateX(-100%);
  }
}

.auth-loading.hidden {
  display: none;
}

/* ============================================
   Verification Pending UI
   ============================================ */
.verification-pending {
  background: var(--bg-card);
  padding: 2.5rem 2rem;
  border-radius: 16px; /* iOS: cornerRadius: 16 */
  box-shadow: 0 2px 8px rgba(28, 25, 23, 0.06), 0 1px 4px rgba(28, 25, 23, 0.04);
  text-align: center;
  position: relative;
  z-index: 1;
}

.verification-pending h2 {
  font-size: 24px; /* iOS: size: 24 */
  font-weight: 600; /* iOS: weight: .semibold */
  margin-bottom: 1.5rem;
  color: var(--text-primary);
  background: var(--bg-card);
  position: relative;
  z-index: 2;
}

.verification-pending p {
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  line-height: 1.5;
  background: var(--bg-card);
  position: relative;
  z-index: 2;
}

.verification-pending .email-display {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin: 1.25rem 0;
  padding: 12px 16px; /* iOS: .padding(.vertical, 12), .padding(.horizontal, 16) */
  background: var(--bg-secondary);
  border-radius: 8px; /* iOS: cornerRadius: 8 */
  word-break: break-all;
  position: relative;
  z-index: 2;
}

.verification-pending .instruction {
  margin-top: 1rem;
  margin-bottom: 2rem;
}

.verification-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
  position: relative;
  z-index: 2;
}

.verification-actions .btn {
  padding: 0.875rem 1.5rem;
  min-width: 180px;
}

@media (min-width: 480px) {
  .verification-actions {
    flex-direction: row;
    justify-content: center;
  }
}

.verification-pending .btn-link {
  background: var(--bg-card);
  border: none;
  color: var(--text-secondary);
  font-size: 14px; /* iOS: size: 14 */
  cursor: pointer;
  padding: 12px; /* iOS: .padding(12) */
  margin-top: 1rem;
  display: inline-block;
  position: relative;
  z-index: 2;
}

.verification-pending .btn-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ============================================
   Password Reset Modal
   ============================================ */
.modal-description {
  color: var(--text-secondary);
  font-size: 14px; /* iOS: size: 14 */
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.success-message {
  text-align: center;
  padding: 1.5rem 0;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--success);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 1rem;
}

.success-message h4 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.success-message p {
  color: var(--text-secondary);
  font-size: 14px; /* iOS: size: 14 */
  margin-bottom: 0.5rem;
}

.success-message strong {
  color: var(--text-primary);
}

.success-hint {
  font-size: 12px; /* iOS: .ccCaption = 12pt */
  color: var(--text-muted);
  margin-top: 1rem;
}

/* ============================================
   MFA Verification Modal
   ============================================ */
.mfa-verify-container {
  text-align: center;
  padding: 1rem 0;
}

.mfa-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  margin: 0 auto 1.5rem;
  background: var(--primary-light, rgba(79, 70, 229, 0.1));
  border-radius: 50%;
  color: var(--primary);
}

.mfa-verify-desc {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 1.5rem;
}

.mfa-code-inputs {
  display: flex;
  gap: 8px; /* iOS: CCSpacing.sm = 8 */
  justify-content: center;
  margin: 1.5rem 0;
}

.mfa-code-digit {
  width: 48px;
  height: 60px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border: 2px solid var(--border-color);
  border-radius: 8px; /* iOS: cornerRadius: 8 */
  background: var(--input-bg, var(--bg-card));
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.mfa-code-digit:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.mfa-code-digit.error {
  border-color: var(--danger, #ef4444);
  animation: mfa-shake 0.3s ease;
}

@keyframes mfa-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.mfa-error {
  color: var(--danger, #ef4444);
  font-size: 13px;
  margin-top: 0.5rem;
}

@media (max-width: 400px) {
  .mfa-code-digit {
    width: 40px;
    height: 50px;
    font-size: 1.25rem;
  }
}
