/**
 * 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;
  }
}

// Single-card login container.
//
// `margin: auto` centres the card in both axes within the column-flex body
// when there is slack, and collapses to 0 when content fills the viewport —
// so the card top stays reachable and the page scrolls normally on short
// screens. No `align-items` / `justify-content` needed on the body.
.login-container {
  width: 100%;
  max-width: 460px;
  margin: auto;
  padding: 20px;
  position: relative;
  z-index: 2;
}

.login-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

// Card header — logo, church name, tagline
.login-card-header {
  text-align: center;
  padding: 32px 40px 28px;
  border-bottom: 2px solid #f0f0f0;
  background: linear-gradient(to bottom, rgba(102, 126, 234, 0.03), transparent);
  border-radius: 12px 12px 0 0;
}

// Card body — pill control + form
.login-card-body {
  padding: 28px 40px 36px;
}

// Segmented pill tab control.
//
// "Sign In" is a <button>; "Register" is an <a> that opens a new tab.
// Only rendered when self-registration is enabled ($hasSelfReg = true).
.login-tab-control {
  display: flex;
  background: #f0f2f5;
  border-radius: 50px;
  padding: 4px;
  margin-bottom: 24px;
  gap: 2px;
}

.login-tab-btn {
  flex: 1;
  padding: 10px 16px;
  border: none;
  border-radius: 46px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  color: #666;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  white-space: nowrap;
  text-decoration: none; // <a> variant

  i {
    font-size: 13px;
  }

  &.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.35);
  }

  &:hover:not(.active) {
    background: rgba(102, 126, 234, 0.08);
    color: #667eea;
    text-decoration: none; // <a> variant
  }
}

// Compact church contact links below the form when self-reg is disabled
.login-contact-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 20px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #f0f0f0;

  a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #888;
    font-size: 12px;
    text-decoration: none;
    transition: color 0.2s;

    i {
      font-size: 11px;
      color: #bbb;
      transition: color 0.2s;
    }

    &:hover {
      color: #667eea;

      i {
        color: #667eea;
      }
    }
  }
}

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

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

.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
//
// Single breakpoint at 600px for the login card.
// The single-card layout works at all widths; below 600px we tighten padding,
// shrink the logo, and drop the pill icons to keep the Sign In button
// on-screen without scrolling even on iPhone SE (375px).
@media (max-width: 600px) {
  .login-container {
    max-width: 100%;
    padding: 12px;
  }

  // Header — reduced vertical footprint so form is above the fold
  .login-card-header {
    padding: 14px 20px 12px;
  }

  .login-header-logo {
    margin-bottom: 10px; // override base 20px

    img {
      max-height: 48px; // override base 120px / desktop 70px
    }
  }

  .login-header-church-name {
    font-size: 16px;
    margin-bottom: 2px;
  }

  // Tagline is decorative filler — hiding it saves ~20px on small phones
  .login-header-tagline {
    display: none;
  }

  // Card body — tighter top/bottom, form content starts higher
  .login-card-body {
    padding: 14px 20px 16px;
  }

  // Pill control — less gap below, icons hidden to prevent label wrap
  .login-tab-control {
    margin-bottom: 14px;
  }

  .login-tab-btn {
    font-size: 13px;
    padding: 9px 12px;

    i {
      display: none;
    }
  }

  // Form title (self-reg off) — compact on phone
  .login-form-title {
    margin-bottom: 14px;

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

      i {
        font-size: 18px;
      }
    }

    p {
      font-size: 12px;
    }
  }

  // Inputs — 16px prevents iOS auto-zoom on focus
  body.page-auth .mb-3 {
    margin-bottom: 12px;

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

  // Form footer — less gap before Sign In button
  .form-footer {
    margin-bottom: 10px;
  }

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

  // Legacy form section — tighter padding on mobile
  .login-form-section {
    padding: 24px 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;
  }
}
