html {
  scroll-behavior: smooth;
  margin: 0;
  padding: 0;
  height: 100%;
}

/* Auth page body */
body.auth-shell-body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  position: relative;
  min-height: var(--viewport-h, 100vh);
}

/* Auth page layout */
.auth-page {
  position: relative;
  min-height: var(--viewport-h, 100vh);
  display: flex;
  flex-direction: column;
}

.auth-container {
  width: min(1200px, 92%);
  margin: 0 auto;
  padding: 0 1rem;
}

/* Mobile-first sizing (template-aware) */
body.is-mobile.auth-shell-body .auth-container {
  width: 100%;
  max-width: 100%;
}

/* Match mobile layout when viewport is small even on desktop UA */
@media (max-width: 768px) {
  .auth-container {
    width: 100%;
    max-width: 100%;
  }
}

/* Navigation */
.auth-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--nav-border);
  background: var(--nav-bg);
  backdrop-filter: var(--backdrop-blur);
}

/* Minimal nav - fully transparent always, no background on scroll */
.auth-nav.auth-nav--minimal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: transparent !important;
}

.auth-nav.auth-nav--hidden {
    display: none !important;
    border-bottom: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

.auth-nav__inner {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 2rem;
  padding: 1.25rem 0;
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 800;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--color-primary);
  text-decoration: none;
}

.auth-brand__logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-block;
  object-fit: cover;
}

.auth-brand__dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--color-primary);
  box-shadow: 0 0 0 6px var(--color-primary-glow);
}

.auth-nav__links {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.auth-nav__link {
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.auth-nav__link:hover,
.auth-nav__link:focus {
  color: var(--text-primary);
  background: var(--nav-link-hover);
}

.auth-nav--minimal .auth-nav__link {
  position: relative;
  background: transparent;
}
.auth-nav--minimal .auth-nav__link::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 6px;
  height: 2px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--text-primary) 24%, transparent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--transition-normal);
  opacity: 0.9;
}
.auth-nav--minimal .auth-nav__link:hover::after,
.auth-nav--minimal .auth-nav__link:focus::after {
  transform: scaleX(1);
}

.auth-nav__link:focus-visible,
.auth-button:focus-visible {
  outline: 3px solid var(--border-primary);
  outline-offset: 2px;
}

.auth-nav__toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-primary);
  cursor: pointer;
}

/* Auth buttons - Using unified button system from components/buttons.css */
/* Base styles, variants, and hover states are defined in components/buttons.css */

/* Subtle glow for minimal navbar primary button */
.auth-nav--minimal .auth-button--primary {
  box-shadow: var(--shadow-primary);
}
.auth-nav--minimal .auth-button--primary:hover {
  box-shadow: var(--shadow-primary-hover);
}
/* Main content area */
.auth-main {
  flex: 1;
  padding: 2rem 0;
}

/* Footer */
.auth-footer {
  margin-top: auto;
  padding: 1rem 0;
  border-top: 1px solid var(--footer-border);
  background: transparent;
  backdrop-filter: blur(8px);
}

.auth-footer__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--footer-text);
}

.auth-footer__links {
  display: flex;
  gap: 1rem;
}

.auth-footer__links a {
  color: inherit;
  text-decoration: none;
}

.auth-footer__links a:hover {
  color: var(--primary);
}

.auth-footer__social {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.auth-footer__social a {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s ease, transform 0.2s ease;
}

.auth-footer__social a:hover {
  color: var(--text-primary);
  transform: translateY(-1px);
}

.auth-footer__social svg {
  width: 20px;
  height: 20px;
}

/* Flash message styles for auth layout */
.auth-alert {
  margin-bottom: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 16px;
  font-size: 0.95rem;
  box-shadow: var(--shadow-md);
}

.auth-alert-success {
  background: var(--alert-success-bg);
  color: var(--alert-success-text);
  border: 1px solid var(--alert-success-border);
}

.auth-alert-error {
  background: var(--alert-error-bg);
  color: var(--alert-error-text);
  border: 1px solid var(--alert-error-border);
}

.auth-alert-info {
  background: var(--alert-info-bg);
  color: var(--alert-info-text);
  border: 1px solid var(--alert-info-border);
}

.auth-alert-warning {
  background: var(--alert-warning-bg);
  color: var(--alert-warning-text);
  border: 1px solid var(--alert-warning-border);
}

/* Muted link styles */
.muted-link {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

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

/* Auth support links */
.auth-support a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.auth-support a:hover {
  color: var(--text-muted); /* Muted grey on hover */
}

/* Responsive navigation */
@media (max-width: 900px) {
  .auth-nav__links {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--nav-border);
    padding: 1.5rem 0;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
    visibility: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: all var(--transition-normal);
  }

  .auth-nav__links.is-open {
    visibility: visible;
    opacity: 1;
    transform: translateY(0);
  }

  .auth-nav__toggle {
    display: inline-flex;
    color: var(--text-primary);
  }
}

@media (max-width: 560px) {
  .auth-footer__inner {
    justify-content: center;
    text-align: center;
  }
}

/* ============ */
/* Auth Shell & Panel */
/* ============ */
.auth-shell {
  min-height: calc(var(--viewport-h, 100vh) - 80px);
  padding: 4rem 1rem;
  background: var(--bg-secondary);
  display: grid;
  place-items: center;
}

.auth-panel {
  width: min(100%, 520px);
  background: var(--card-bg, var(--card));
  border: 1px solid var(--border-light, var(--border));
  border-radius: 24px;
  padding: 3rem 2.5rem;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

.auth-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brand-accent-border);
}

.auth-panel--signup,
.auth-panel--login {
  display: grid;
  gap: 1.5rem;
}

/* ============ */
/* Auth Panel Badge */
/* ============ */
.auth-panel__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--badge-bg);
  color: var(--badge-text);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  width: fit-content;
  margin-bottom: 0.5rem;
}

.auth-panel__badge i {
  font-size: 1rem;
}

/* ============ */
/* Auth Panel Typography */
/* ============ */
.auth-panel__title {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.auth-panel__subtitle {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 1rem;
}

/* ============ */
/* Auth Panel Benefits List */
/* ============ */
.auth-panel__list {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  color: var(--text-secondary);
}

.auth-panel__list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-panel__list i {
  color: var(--foreground); /* White icons instead of purple */
  font-size: 1.1rem;
  flex-shrink: 0;
}

/* ============ */
/* Form Styles */
/* ============ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  border: 1.5px solid var(--border-light);
  border-radius: 12px;
  padding: 0.875rem 1.25rem;
  font-size: 1rem;
  font-family: inherit;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: rgba(168, 85, 247, 0.5); /* Dark purple focus border */
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15); /* Dark purple glow */
  outline: none;
  background: var(--bg-primary);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-soft);
}

.form-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ============ */
/* Auth Panel Form Specific */
/* ============ */
.auth-panel--signup .form-grid,
.auth-panel--login .form-grid {
  gap: 1.5rem;
}

.auth-panel--signup .form-group,
.auth-panel--login .form-group {
  margin-bottom: 0;
}

/* ============ */
/* Button Styles */
/* ============ */
/* Base button styles are now in components/buttons.css */
/* Only auth-specific overrides are kept here */

/* Auth-specific button adjustments */
.auth-panel .btn-primary {
  width: 100%;
}

/* Dark purple highlights for modal buttons */
.auth-modal .btn-primary,
.auth-modal .auth-button--primary {
  background: rgba(168, 85, 247, 0.1); /* Dark purple background */
  border-color: rgba(168, 85, 247, 0.4); /* Dark purple border */
  color: #ffffff;
}

.auth-modal .btn-primary:hover,
.auth-modal .auth-button--primary:hover {
  background: rgba(168, 85, 247, 0.15); /* Darker purple on hover */
  border-color: rgba(168, 85, 247, 0.6); /* Brighter purple border */
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.3); /* Dark purple glow */
  transform: translateY(-1px);
}

.auth-modal .btn-primary:focus-visible,
.auth-modal .auth-button--primary:focus-visible {
  outline: 3px solid rgba(168, 85, 247, 0.5); /* Dark purple focus ring */
  outline-offset: 2px;
}

/* ============ */
/* Auth Support Section */
/* ============ */
.auth-support {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--divider-color);
  display: grid;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
}

.auth-support a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
  font-weight: 500;
}

.auth-support a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ============ */
/* OTP Modal Styles */
/* ============ */
.otp-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg-overlay, rgba(0, 0, 0, 0.55));
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.otp-modal[hidden] {
  display: none;
}

.otp-modal__backdrop {
  position: absolute;
  inset: 0;
  background: var(--bg-overlay, rgba(0, 0, 0, 0.55));
  backdrop-filter: blur(8px);
}

.otp-card {
  position: relative;
  z-index: 1;
  width: min(100%, 420px);
  background: var(--card-bg, var(--card));
  border: 1px solid var(--border-light, var(--border));
  border-radius: 24px;
  box-shadow: var(--shadow-xl);
  padding: 2.5rem;
  display: grid;
  gap: 1.5rem;
  text-align: center;
}

.otp-card h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.otp-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.otp-card strong {
  color: var(--text-primary);
  font-weight: 600;
}

.otp-card__close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all var(--transition-fast);
}

.otp-card__close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.otp-card__icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--alert-info-bg);
  color: var(--alert-info-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  margin: 0 auto;
}

.otp-card__resend {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.otp-card .form-grid {
  gap: 1.25rem;
}

.otp-card__countdown {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Modal Auth Styles */
.auth-modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: var(--viewport-h, 100vh);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto; /* Allow scrolling when content is too tall */
}

.auth-modal[hidden] {
    display: none;
}

.auth-modal__backdrop {
    position: fixed; /* Changed from absolute to fixed */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay, rgba(0, 0, 0, 0.55));
    backdrop-filter: blur(8px);
    z-index: 0;
}

.auth-modal__content {
    position: relative;
    z-index: 1;
    background: var(--card-bg, var(--card));
    border: 1px solid var(--border-light, var(--border));
    border-radius: 24px;
    padding: 2.5rem;
    /* Keep the modal a stable, readable size; only shrink when the viewport can't fit it. */
    width: 560px;
    max-width: calc(100vw - 2rem);
    max-height: calc(var(--viewport-h, 100vh) - 2rem); /* Ensure content doesn't exceed viewport */
    overflow-y: auto; /* Allow scrolling within modal if needed */
    box-shadow: var(--shadow-xl);
    animation: modalUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    margin: auto; /* Center vertically when using overflow-y on parent */
}

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

.auth-modal__close {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    transition: all 0.2s;
}

.auth-modal__close:hover {
    background: rgba(168, 85, 247, 0.1); /* Dark purple hover */
    color: #a855f7; /* Dark purple icon */
}

.auth-modal__title {
    margin: 0 0 0.5rem;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.auth-modal__subtitle {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
}

.auth-modal__footer {
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid rgba(168, 85, 247, 0.2); /* Dark purple border */
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.text-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--foreground); /* White text instead of purple */
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

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

/* Responsive Typography */
@media (max-width: 480px) {
    .auth-modal { padding: 0.5rem; }
    .auth-modal__content { 
        padding: 1.75rem;
        max-height: calc(var(--viewport-h, 100vh) - 1rem); /* Less padding for small screens */
    }
    .auth-modal__title { font-size: 1.6rem; }
    .form-input,
    .form-select,
    .form-textarea {
        padding: 0.75rem 1rem; /* Slightly smaller padding on mobile/zoom */
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    .btn {
        padding: 0.75rem 1.25rem;
        min-height: 44px; /* Touch-friendly size */
    }
}

/* Extra small screens or high zoom levels */
@media (max-height: 600px) {
    .auth-modal { 
        padding: 0.5rem;
        align-items: flex-start; /* Start from top on short screens */
    }
    .auth-modal__content {
        /* Don't shrink the modal aggressively on zoom; keep size, just allow scrolling. */
        padding: 1.75rem;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }
    .auth-modal__title { 
        font-size: 1.6rem;
        margin-bottom: 0.25rem;
    }
    .auth-modal__subtitle { 
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }
    .form-grid {
        gap: 1.1rem;
    }
    .form-group {
        gap: 0.4rem;
    }
}

/* ============ */
/* Responsive Styles */
/* ============ */
@media (max-width: 768px) {
  .auth-shell {
    padding: 2rem 1rem;
  }

  .auth-panel {
    width: 100%;
    padding: 2rem 1.5rem;
    border-radius: 20px;
  }

  .auth-panel__title {
    font-size: 1.75rem;
  }

  .auth-panel__subtitle {
    font-size: 0.95rem;
  }

  .btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
    min-height: 48px;
  }

  .otp-card {
    padding: 2rem 1.5rem;
  }

  .otp-card h2 {
    font-size: 1.5rem;
  }

  .otp-card__icon {
    width: 56px;
    height: 56px;
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .auth-panel {
    padding: 1.5rem;
  }

  .auth-panel__title {
    font-size: 1.5rem;
  }

  .auth-panel__badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.875rem;
  }
}

