/**
 * ChurchCRM Authentication Pages Styles
 *
 * Styles for login, 2FA, password reset, and error pages.
 * Uses login-photo.png background with dark overlay and centered form layout.
 * Component-specific - no Bootstrap duplicates.
 */

// --- Two-Factor Authentication Enrollment (merged from _two-factor-enrollment.scss) ---
#TwoFAEnrollmentSteps div.col-lg-4 {
  text-align: center;
}

#TwoFAEnrollmentSteps div.col-lg-4 i {
  font-size: 100px;
}

#TwoFAEnrollmentSteps button.btn-success {
  display: block;
  margin-right: auto;
  margin-left: auto;
  width: 40%;
  min-height: 60px;
}

// Base layout for all non-admin public pages (login, kiosk, external, etc.)
//
// Sticky footer pattern: body is a column flex container the height of the
// viewport. The card containers use `margin: auto` to center themselves in
// the remaining space, which is the bulletproof flex centering pattern —
// when content is taller than the viewport, `margin: auto` collapses to 0
// and the card top-aligns (instead of overflowing above the viewport like
// `align-items: center` does). The footer's own `margin-top: auto` keeps
// it pinned to the bottom of the viewport on tall screens.
body.page-auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

// Login background photo + dark overlay — only for login/auth flow pages.
// Templates that need this must set $sBodyClass = 'page-auth page-login'.
body.page-login {
  background: url('/Images/login-photo.png') center/cover no-repeat fixed;

  &::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 1;
  }
}

// Container and wrapper
//
// `margin: auto` is the magic: in a column flex parent (body.page-auth) it
// centers the container in BOTH axes when there's slack, and collapses to 0
// when content is taller than the viewport — so the card top stays reachable
// and the page scrolls normally on short viewports. No `align-items` /
// `justify-content` gymnastics on the body needed.
.login-container {
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 20px;
  position: relative;
  z-index: 2;

  &.login-container-split {
    max-width: 920px;
  }
}

.login-wrapper {
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  background: white;

  &.login-wrapper-split {
    flex-direction: row !important;
    min-height: 520px;
    align-items: stretch;
  }
}

// 2-Column layout for login with registration
.login-form-column {
  flex: 1 1 0;
  padding: 45px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-register-column {
  flex: 1 1 0;
  padding: 50px 45px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.05) 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-left: 1px solid #f0f0f0;

  .register-content {
    text-align: center;
    max-width: 100%;
  }

  .register-icon {
    font-size: 60px;
    color: #667eea;
    margin-bottom: 20px;
    opacity: 0.9;
  }

  .register-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 12px;
    line-height: 1.3;
  }

  .register-text {
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 28px;

    strong {
      color: #1a1a1a;
      font-weight: 600;
    }
  }

  .register-benefits {
    list-style: none;
    padding: 0;
    margin: 0 0 28px 0;
    text-align: left;
    display: inline-block;

    li {
      padding: 8px 0;
      color: #666;
      font-size: 13px;

      i {
        color: #43d997;
        margin-right: 8px;
        font-weight: 700;
      }
    }
  }

  .btn-register {
    max-width: 100%;
  }
}

// Church info panel — shown on the right when self-registration is disabled.
// Provides visual balance and useful contact details.
.login-info-column {
  flex: 1 1 0;
  padding: 50px 45px;
  background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;

  .login-info-content {
    text-align: center;
    max-width: 100%;
  }

  .login-info-icon {
    font-size: 56px;
    color: rgba(255, 255, 255, 0.25);
    margin-bottom: 24px;
  }

  .login-info-name {
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    line-height: 1.3;
  }

  .login-info-tagline {
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 32px;
  }

  .login-info-details {
    list-style: none;
    padding: 0;
    margin: 0 0 32px 0;
    text-align: left;
    display: inline-block;

    li {
      padding: 7px 0;
      color: rgba(255, 255, 255, 0.65);
      font-size: 13px;
      line-height: 1.5;

      i {
        color: rgba(255, 255, 255, 0.35);
        width: 16px;
        margin-right: 10px;
        text-align: center;
      }

      a {
        color: rgba(255, 255, 255, 0.75);
        text-decoration: none;

        &:hover {
          color: #fff;
          text-decoration: underline;
        }
      }
    }
  }

  .login-info-contact {
    display: inline-flex;
    align-items: center;
    padding: 10px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;

    &:hover {
      border-color: rgba(255, 255, 255, 0.5);
      color: #fff;
      background: rgba(255, 255, 255, 0.06);
    }
  }
}

// Form section (legacy — kept for non-split auth pages)
.login-form-section {
  padding: 45px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

// Header with logo and church name
.login-form-header {
  text-align: center;
  margin-bottom: 35px;
  padding-bottom: 30px;
  border-bottom: 2px solid #f0f0f0;
  background: linear-gradient(to bottom, rgba(102, 126, 234, 0.03), transparent);
  margin: -45px -40px 30px -40px;
  padding: 30px 40px;
  border-radius: 12px 12px 0 0;
}

.login-header-logo {
  margin-bottom: 20px;
  opacity: 0.95;
  transition: opacity 0.2s;

  &:hover {
    opacity: 1;
  }

  img {
    max-width: 100%;
    height: auto;
    width: 100%;
    max-height: 120px;
    object-fit: contain;
  }
}

.login-header-church-name {
  font-size: 24px;
  font-weight: 800;
  color: #1a1a1a;
  margin: 0 0 8px 0;
  letter-spacing: -0.5px;
  line-height: 1.3;
}

.login-header-tagline {
  font-size: 13px;
  color: #666;
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.3px;
}

// Form title
.login-form-title {
  margin-bottom: 30px;

  h1 {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;

    i {
      font-size: 24px;
      color: #667eea;
    }
  }

  p {
    color: #666;
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
  }
}

// Form fields — scoped to auth pages only to avoid polluting the main app
body.page-auth .mb-3 {
  margin-bottom: 18px;

  label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 13px;
    letter-spacing: 0.2px;
  }

  > input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fafafa;
    transition: all 0.2s ease;

    &:hover {
      background: #f5f5f5;
      border-color: #d5d5d5;
    }

    &:focus {
      outline: none;
      background: white;
      border-color: #667eea;
      box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.08);
    }

    &::placeholder {
      color: #aaa;
    }
  }
}

// 2FA code input styling
#TwoFACode {
  font-size: 2em !important;
  letter-spacing: 0.3em !important;
  text-align: center !important;
  font-weight: 300 !important;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Courier New', monospace;
  max-width: 100%;
  box-sizing: border-box;
}

// Form footer with links
.form-footer {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 18px;
  font-size: 12px;

  a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;

    &:hover {
      color: #764ba2;
    }
  }
}

// Sign in button
.btn-sign-in {
  width: 100%;
  padding: 14px 16px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  overflow: hidden;

  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    transition: left 0.3s ease;
  }

  &:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.4);

    &::before {
      left: 100%;
    }
  }

  &:active {
    transform: translateY(-1px);
  }

  &:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
  }

  i {
    font-size: 16px;
  }
}

// Register button
.btn-register {
  width: 100%;
  padding: 13px 16px;
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  display: inline-block;

  &:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    text-decoration: none;
  }

  &:active {
    transform: translateY(-1px);
    background: #5a6fd6;
  }
}

// Signup/registration link section
.signup-link {
  text-align: center;
  border-top: 2px solid #f0f0f0;
  padding-top: 24px;
  margin-top: 12px;
  background: linear-gradient(to bottom, rgba(102, 126, 234, 0.02), transparent);
  margin: 24px -40px -45px -40px;
  padding: 24px 40px;
  border-radius: 0 0 12px 12px;

  h3 {
    color: #1a1a1a;
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 14px 0;
    line-height: 1.4;

    i {
      margin-right: 6px;
      color: #667eea;
    }
  }

  p {
    margin: 0 0 12px 0;
    color: #666;
    font-size: 13px;
  }

  a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
    font-weight: 600;

    &:hover {
      color: #764ba2;
      text-decoration: underline;
    }
  }
}

// Alert messages — scoped to auth pages only to avoid polluting global .alert
body.page-auth .alert {
  border-radius: 6px;
  margin-bottom: 20px;
  padding: 12px 16px;
  font-size: 14px;

  &.alert-danger {
    background-color: #fee;
    border: 1px solid #fcc;
    color: #c33;
  }

  &.alert-warning {
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
  }

  &.alert-info {
    background-color: #e7f3ff;
    border: 1px solid #b3d9ff;
    color: #004085;
    display: flex;
    align-items: center;
    gap: 12px;

    i {
      font-size: 18px;
      flex-shrink: 0;
    }
  }

  i {
    font-size: 18px;
    flex-shrink: 0;
  }
}

// Back link
.back-link {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;

  a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;

    &:hover {
      color: #764ba2;
    }
  }
}

// Forgot password container and card
// Uses the same `margin: auto` self-centering pattern as .login-container.
.forgot-password-container {
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 20px;
  position: relative;
  z-index: 2;
}

// Backwards-compatible rule for older templates that use `login-box` or
// render a `.card` directly on authentication pages. Ensure these sit
// above the background overlay (which uses z-index:1).
.page-auth .login-box,
.page-auth .forgot-password-container,
.page-auth .forgot-password-card,
.page-auth .card {
  position: relative;
  z-index: 2;
}

.forgot-password-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  padding: 45px 40px;
  max-width: 420px;
  width: 100%;
}

.forgot-password-card-logo {
  text-align: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;

  img {
    max-width: 100%;
    height: auto;
    width: 100%;
  }
}

.forgot-password-card h2 {
  text-align: center;
  color: #1a1a1a;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 20px 0;
}

.forgot-password-card h3 {
  color: #333;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
  text-align: center;
}

.forgot-password-card p {
  color: #666;
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 25px;
  text-align: center;
}

// Reset button
.btn-reset {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 20px;

  &:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
  }

  &:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
  }
}

// Auth footer - ensure it's above the overlay
.auth-footer {
  position: relative;
  z-index: 3;
  margin-top: auto;
  padding: 40px 20px 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  text-align: center;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;

  a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    transition: color 0.2s;

    &:hover {
      color: white;
      text-decoration: underline;
    }
  }
}

.auth-footer-social {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;

  a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    // 44px minimum touch target per Apple/Google guidelines
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    transition: all 0.2s;
    cursor: pointer;

    &:hover {
      background: rgba(255, 255, 255, 0.3);
      transform: translateY(-2px);
    }

    i {
      font-size: 16px;
    }
  }
}

// Success box for password reset confirmation
.success-box {
  background: #f0f8f7;
  border: 2px solid #43d997;
  border-radius: 8px;
  padding: 30px 20px;
  text-align: center;
}

.success-icon {
  width: 60px;
  height: 60px;
  background: #43d997;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 28px;
  margin: 0 auto 20px;
}

.success-box h2 {
  font-size: 20px;
  font-weight: 700;
  color: #2d3748;
  margin-bottom: 12px;
}

.success-box p {
  color: #666;
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.success-box .small {
  color: #777;
  font-size: 13px;
  display: block;
  margin: 8px 0;
}

// Error page styles — scoped to auth pages
body.page-auth .alert-heading {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.page-auth .alert-buttons {
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;

  a, button {
    width: 100%;
    padding: 12px 16px;
    text-align: center;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    text-decoration: none;
    transition: all 0.2s;
  }
}

// Button overrides — scoped to auth pages only to avoid polluting global .btn
body.page-auth .btn {
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;

  &.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;

    &:hover {
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }
  }

  &.btn-secondary {
    background: #f0f0f0;
    color: #333;
    border: 1px solid #ddd;

    &:hover {
      background: #e0e0e0;
    }
  }
}

// Responsive design
//
// Two breakpoint tiers, aligned with `responsive-design-guidelines.md`:
//
// 1. **<1200px (Tablet + Mobile)** — the side-by-side split with the
//    marketing sidebar only fits comfortably on actual laptops/desktops.
//    Below the 1200px Laptop boundary, stack the columns vertically and
//    collapse the register sidebar into a slim banner with just the button
//    (the marketing icon/title/blurb/benefits get hidden — they're filler
//    that loses impact in a narrow column).
//
// 2. **<768px (Mobile only)** — additionally tighten padding, font sizes,
//    and the logo so the Sign In button stays reachable without scrolling
//    on iPhone SE-class viewports.
@media (max-width: 1199.98px) {
  // Stack the split login wrapper vertically and drop the rigid 520px
  // min-height that the side-by-side layout uses.
  .login-wrapper-split {
    flex-direction: column !important;
    min-height: auto;
  }

  .login-container-split {
    max-width: 480px;
  }

  // After stacking, the register column gets a top border (instead of left
  // border) and tighter padding — but the full marketing content (icon,
  // title, blurb, benefits, button) stays visible at every viewport.
  .login-register-column {
    border-left: none;
    border-top: 1px solid #f0f0f0;
    padding: 30px 30px;
  }

  // Info column stacks below form on tablet; hide decorative icon to save space
  .login-info-column {
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 28px 30px;

    .login-info-icon {
      display: none;
    }
  }

  .btn-register {
    padding: 11px 14px;
    font-size: 13px;
  }
}

@media (max-width: 768px) {
  .login-container,
  .login-container-split {
    max-width: 100%;
  }

  // Form column — tighten padding so the form fits without overflow
  .login-form-column,
  .login-form-section {
    padding: 24px 20px;
  }

  // Header — reduce vertical footprint so the logo + church name don't
  // dominate the screen on small phones
  .login-form-header {
    margin: -24px -20px 16px -20px;
    padding: 18px 20px;
  }

  .login-header-logo img {
    max-height: 70px;
  }

  .login-header-church-name {
    font-size: 18px;
    margin-bottom: 4px;
  }

  .login-header-tagline {
    font-size: 11px;
  }

  // Form title — keep compact, allow it to wrap on one line where possible
  .login-form-title {
    margin-bottom: 18px;

    h1 {
      font-size: 17px;
      flex-wrap: wrap;

      i {
        font-size: 18px;
      }
    }

    p {
      font-size: 12px;
    }
  }

  // Inputs — 16px font is required on iOS to prevent auto-zoom on focus
  body.page-auth .mb-3 {
    margin-bottom: 14px;

    > input:not([type="checkbox"]):not([type="radio"]) {
      padding: 11px 12px;
      font-size: 16px;
    }
  }

  .btn-sign-in {
    padding: 13px 14px;
    font-size: 14px;
    margin-bottom: 12px;
  }

  // Register column — tighter padding on phone-class viewports
  .login-register-column {
    padding: 24px 20px;
  }

  .signup-link {
    margin: 16px -20px -24px -20px;
    padding: 16px 20px;
  }

  .forgot-password-card {
    padding: 30px 20px;
  }

  .forgot-password-card-logo {
    margin-bottom: 15px;
    padding-bottom: 15px;
  }

  .forgot-password-card h2 {
    font-size: 18px;
  }

  .forgot-password-card h3 {
    font-size: 16px;
  }

  .forgot-password-card p {
    font-size: 13px;
  }

  body.page-auth .alert-buttons {
    flex-direction: column;
  }

  body.page-auth .btn {
    width: 100%;
  }

  // 2FA code input — reduce size to prevent overflow on narrow screens
  #TwoFACode {
    font-size: 1.5em !important;
    letter-spacing: 0.2em !important;
    padding: 10px 8px !important;
  }

  // Footer — reduce top padding on mobile, keep touch targets
  .auth-footer {
    padding: 24px 16px 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    font-size: 12px;
  }
}
