/* ============================================================
   Auth Pages — Shared Styles (CalculatorDrive)
   Replaces duplicated inline <style> blocks across all account
   templates. Uses --cd-* design tokens from tokens.css.
   ============================================================ */

/* ——— Keyframe animations ——— */
@keyframes authFadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes authFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes authScaleIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes authFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

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

@keyframes authBounceCheck {
  0%   { transform: scale(0); opacity: 0; }
  50%  { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes authPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

@keyframes authShimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* ——— Page background ——— */
.auth-page-bg {
  position: relative;
  min-height: calc(100vh - var(--cd-header-height, 72px) - 200px);
  background:
    radial-gradient(ellipse 60% 50% at 20% 30%, rgba(26, 107, 255, 0.05), transparent 50%),
    radial-gradient(ellipse 40% 40% at 80% 70%, rgba(147, 51, 234, 0.04), transparent 45%),
    radial-gradient(ellipse 50% 30% at 60% 10%, rgba(13, 148, 136, 0.03), transparent 40%),
    var(--cd-surface);
}

.auth-page-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(12, 18, 34, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(12, 18, 34, 0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, black 0%, transparent 70%);
  pointer-events: none;
}

/* ——— Card ——— */
.auth-card {
  animation: authFadeInUp 0.6s ease-out;
  position: relative;
  z-index: 1;
  background: var(--cd-surface-elevated);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius-xl, 24px);
  box-shadow: var(--cd-shadow-md);
}

/* ——— Icon circles ——— */
.auth-icon {
  animation: authScaleIn 0.5s ease-out 0.2s both;
}

.auth-icon-circle {
  animation: authFloat 3s ease-in-out infinite;
  background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
  width: 64px;
  height: 64px;
  border-radius: var(--cd-radius-lg, 16px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--cd-accent);
}

.auth-icon-circle--success {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%);
  color: #16a34a;
}

.auth-icon-circle--error {
  background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
  color: #dc2626;
}

.auth-icon-circle--warning {
  background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
  color: #d97706;
}

.auth-icon-circle--large {
  width: 80px;
  height: 80px;
  font-size: 1.75rem;
}

/* ——— Typography ——— */
.auth-title {
  animation: authFadeIn 0.5s ease-out 0.3s both;
  font-family: var(--cd-font-display);
  font-size: clamp(1.5rem, 4vw, 1.875rem);
  font-weight: 800;
  color: var(--cd-text);
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin: 0 0 0.5rem;
}

.auth-subtitle {
  animation: authFadeIn 0.5s ease-out 0.4s both;
  font-size: var(--cd-text-sm);
  color: var(--cd-text-secondary);
  line-height: 1.6;
}

/* ——— Form elements ——— */
.auth-form {
  animation: authFadeInUp 0.5s ease-out 0.55s both;
}

.auth-input {
  font-family: var(--cd-font-ui);
  transition: all 0.25s var(--cd-ease);
  border-color: var(--cd-border-strong);
}

.auth-input:focus {
  box-shadow: 0 0 0 4px var(--cd-accent-soft);
  border-color: var(--cd-accent);
}

.auth-input:hover:not(:focus) {
  border-color: rgba(15, 39, 68, 0.25);
}

/* ——— Input icon pattern ——— */
.auth-input-wrap {
  position: relative;
  display: block;
}

.auth-input-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--cd-text-muted);
  font-size: 0.875rem;
  pointer-events: none;
  z-index: 1;
  line-height: 1;
  display: flex;
  align-items: center;
}

[dir="rtl"] .auth-input-icon {
  left: auto;
  right: 16px;
}

.auth-input--has-icon {
  padding-left: 2.75rem !important;
}

[dir="rtl"] .auth-input--has-icon {
  padding-left: 1rem !important;
  padding-right: 2.75rem !important;
}

.auth-input--has-toggle {
  padding-right: 2.75rem !important;
}

[dir="rtl"] .auth-input--has-toggle {
  padding-right: 1rem !important;
  padding-left: 2.75rem !important;
}

.auth-input--has-both {
  padding-left: 2.75rem !important;
  padding-right: 2.75rem !important;
}

[dir="rtl"] .auth-input--has-both {
  padding-left: 2.75rem !important;
  padding-right: 2.75rem !important;
}

/* ——— Submit button ——— */
.auth-submit-btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--cd-ease);
  background: var(--cd-accent);
  font-family: var(--cd-font-ui);
}

.auth-submit-btn:hover {
  transform: translateY(-1px);
  background: var(--cd-accent-hover);
  box-shadow: 0 6px 20px rgba(26, 107, 255, 0.35);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-submit-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.15), transparent);
  transition: left 0.6s ease;
}

.auth-submit-btn:hover::before {
  left: 100%;
}

/* Loading state */
.auth-submit-btn.loading {
  pointer-events: none;
  opacity: 0.85;
}

.auth-submit-btn.loading .btn-text {
  visibility: hidden;
}

.auth-submit-btn.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: authSpin 0.6s linear infinite;
}

/* ——— Google button ——— */
.auth-google-btn {
  animation: authFadeInUp 0.5s ease-out 0.45s both;
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--cd-ease);
  border-color: var(--cd-border-strong);
}

.auth-google-btn::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s ease;
}

.auth-google-btn:hover::after {
  left: 100%;
}

.auth-google-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--cd-shadow-md);
  border-color: rgba(15, 39, 68, 0.2);
}

/* ——— Divider ——— */
.auth-divider {
  animation: authFadeIn 0.5s ease-out 0.5s both;
}

/* ——— Error display ——— */
.auth-error {
  animation: authFadeInUp 0.4s ease-out;
}

/* ——— CTA section ——— */
.auth-cta {
  animation: authFadeInUp 0.5s ease-out 0.5s both;
}

/* ——— Links ——— */
.auth-link {
  position: relative;
  transition: color 0.2s ease;
  color: var(--cd-accent);
  font-weight: 500;
}

.auth-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--cd-accent);
  transition: width 0.3s var(--cd-ease);
}

.auth-link:hover {
  color: var(--cd-accent-hover);
}

.auth-link:hover::after {
  width: 100%;
}

/* ——— Password toggle ——— */
.password-toggle {
  transition: color 0.2s ease;
}

.password-toggle:hover {
  color: var(--cd-accent) !important;
}

/* ——— Password strength meter ——— */
.strength-meter {
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  overflow: hidden;
  transition: opacity 0.3s;
}

.strength-meter-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease, background-color 0.4s ease;
  width: 0%;
}

.strength-text {
  font-size: 11px;
  font-family: var(--cd-font-ui);
  margin-top: 4px;
  transition: color 0.3s ease;
}

/* ——— Email management cards ——— */
.email-card {
  transition: all 0.2s var(--cd-ease);
  border-color: var(--cd-border-strong);
}

.email-card:hover {
  border-color: var(--cd-accent);
  background: rgba(26, 107, 255, 0.02);
}

.email-card.selected {
  border-color: var(--cd-accent);
  background: var(--cd-accent-muted);
  box-shadow: 0 0 0 3px var(--cd-accent-soft);
}

.email-list-section {
  animation: authFadeInUp 0.5s ease-out 0.4s both;
}

.add-email-section {
  animation: authFadeInUp 0.5s ease-out 0.5s both;
}

/* ——— Action buttons ——— */
.action-btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--cd-ease);
  font-family: var(--cd-font-ui);
}

.action-btn:hover {
  transform: translateY(-1px);
}

.action-btn:active {
  transform: translateY(0);
}

/* ——— Secondary / cancel buttons ——— */
.signout-btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--cd-ease);
}

.signout-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.35);
}

.signout-btn:active {
  transform: translateY(0);
}

.cancel-btn {
  transition: all 0.3s var(--cd-ease);
}

.cancel-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 39, 68, 0.2);
}

.secondary-btn {
  transition: all 0.3s var(--cd-ease);
}

.secondary-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 39, 68, 0.2);
}

/* ——— Badge styles ——— */
.auth-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 8px;
  font-size: 0.6875rem;
  font-weight: 600;
  font-family: var(--cd-font-ui);
  transition: all 0.2s ease;
}

/* ——— Info box ——— */
.auth-info-box {
  background: var(--cd-surface);
  border: 1px solid var(--cd-border);
  border-radius: var(--cd-radius-md);
  padding: 1rem 1.25rem;
}

/* ——— Pulse dot ——— */
.pulse-dot {
  animation: authPulse 2s ease-in-out infinite;
}

/* ——— Steps ——— */
.auth-steps {
  animation: authFadeInUp 0.5s ease-out 0.6s both;
}

/* ——— Success icon (bounceCheck) ——— */
.auth-icon--success {
  animation: authBounceCheck 0.6s ease-out 0.2s both;
}

/* ——— Security badge ——— */
.auth-security-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 1.5rem;
  font-size: 0.6875rem;
  font-family: var(--cd-font-ui);
  color: var(--cd-text-muted);
}

.auth-security-badge i {
  font-size: 0.75rem;
}

/* ——— Responsive ——— */
@media (min-width: 640px) {
  .auth-page-bg {
    padding-top: 3rem;
    padding-bottom: 3rem;
  }
}

@media (min-width: 1024px) {
  .auth-page-bg {
    padding-top: 4rem;
    padding-bottom: 4rem;
  }
}

/* ——— Reduced motion ——— */
@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-icon,
  .auth-icon-circle,
  .auth-title,
  .auth-subtitle,
  .auth-form,
  .auth-error,
  .auth-cta,
  .auth-google-btn,
  .auth-divider,
  .auth-steps,
  .email-list-section,
  .add-email-section,
  .auth-icon--success {
    animation: none !important;
  }

  .auth-submit-btn:hover,
  .auth-google-btn:hover,
  .action-btn:hover,
  .signout-btn:hover,
  .cancel-btn:hover,
  .secondary-btn:hover {
    transform: none;
  }
}
