/**
 * TabMail - Auth Styles
 * 
 * Styles for signin, signup, and authentication pages.
 * Requires: palette.css, base.css
 */

/* ============================================
   Auth Page Layout Overrides
   (Base sets html/body overflow:hidden globally)
   ============================================ */
html.auth-page,
body.auth-page {
  overflow: auto;
  height: auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Thunderbird popup: allow scrolling for content overflow */
html.tb-compact,
body.tb-compact {
  overflow: auto;
}

/* ============================================
   Auth Container
   ============================================ */
.auth-container {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}


/* ============================================
   Auth Box (Signin/Signup Card)
   ============================================ */
.auth-box {
  background: var(--box-bg);
  border: 1px solid var(--button-bg);
  border-radius: 12px;
  padding: 3rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  .auth-box {
    background: var(--box-bg-dark);
    border-color: var(--button-bg-dark);
  }
}

@media (max-width: 640px) {
  .auth-box {
    padding: 2rem 1.5rem;
  }
}

/* ============================================
   Auth Logo
   ============================================ */
.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.auth-logo img {
  height: 48px;
  width: auto;
}

.auth-logo h1 {
  margin: 0;
}

/* ============================================
   Auth Heading & Subtitle
   ============================================ */
.auth-box h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  text-align: center;
}

@media (max-width: 640px) {
  .auth-box h1 {
    font-size: 1.5rem;
  }
}

.auth-subtitle {
  font-size: 0.9375rem;
  opacity: 0.7;
  text-align: center;
  margin-bottom: 2rem;
}

/* ============================================
   Signin Methods Container
   ============================================ */
.signin-methods,
.login-methods {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* ============================================
   Signin Button (OAuth, Email)
   ============================================ */
.signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.875rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-color);
  background: var(--page-bg);
  border: 1px solid var(--button-bg);
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  width: 100%;
}

.signin-btn:hover {
  background: var(--button-bg-hover);
  border-color: var(--button-bg-hover);
  transform: translateY(-1px);
}

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

.signin-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

@media (prefers-color-scheme: dark) {
  .signin-btn {
    color: var(--text-color-dark);
    background: var(--page-bg-dark);
    border-color: var(--button-bg-dark);
  }

  .signin-btn:hover {
    background: var(--button-bg-hover-dark);
    border-color: var(--button-bg-hover-dark);
  }
}

/* ============================================
   Google Sign-In Button (Material Design)
   Per Google Branding Guidelines HTML Builder
   https://developers.google.com/identity/branding-guidelines
   ============================================ */
.gsi-material-button {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-appearance: none;
  appearance: none;
  background-color: WHITE;
  background-image: none;
  border: 1px solid #747775;
  -webkit-border-radius: 4px;
  border-radius: 4px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #1f1f1f;
  cursor: pointer;
  font-family: 'Roboto', arial, sans-serif;
  font-size: 19px;
  height: 44px;
  letter-spacing: 0;
  outline: none;
  overflow: hidden;
  padding: 0 16px;
  position: relative;
  text-align: center;
  -webkit-transition: background-color .218s, border-color .218s, box-shadow .218s;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
  vertical-align: middle;
  white-space: nowrap;
  /* Modified for full-width layout */
  width: 100%;
  max-width: none;
  min-width: min-content;
  border-radius: 6px;
}

.gsi-material-button .gsi-material-button-icon {
  height: 20px;
  margin-right: 10px;
  min-width: 20px;
  width: 20px;
}

.gsi-material-button .gsi-material-button-content-wrapper {
  -webkit-align-items: center;
  align-items: center;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: nowrap;
  flex-wrap: nowrap;
  height: 100%;
  justify-content: center;
  position: relative;
  width: 100%;
}

.gsi-material-button .gsi-material-button-contents {
  -webkit-flex-grow: 0;
  flex-grow: 0;
  font-family: 'Roboto', arial, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.gsi-material-button .gsi-material-button-state {
  -webkit-transition: opacity .218s;
  transition: opacity .218s;
  bottom: 0;
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.gsi-material-button:disabled {
  cursor: default;
  background-color: #ffffff61;
  border-color: #1f1f1f1f;
}

.gsi-material-button:disabled .gsi-material-button-contents {
  opacity: 38%;
}

.gsi-material-button:disabled .gsi-material-button-icon {
  opacity: 38%;
}

.gsi-material-button:not(:disabled):active .gsi-material-button-state,
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: #303030;
  opacity: 12%;
}

.gsi-material-button:not(:disabled):hover {
  -webkit-box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
}

.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: #303030;
  opacity: 8%;
}

/* Dark mode - Google dark theme button */
@media (prefers-color-scheme: dark) {
  .gsi-material-button {
    background-color: #131314;
    border-color: #8e918f;
    color: #e3e3e3;
  }

  .gsi-material-button:not(:disabled):active .gsi-material-button-state,
  .gsi-material-button:not(:disabled):focus .gsi-material-button-state {
    background-color: #fff;
    opacity: 12%;
  }

  .gsi-material-button:not(:disabled):hover .gsi-material-button-state {
    background-color: #fff;
    opacity: 8%;
  }

  .gsi-material-button:disabled {
    background-color: #13131461;
    border-color: #8e918f1f;
  }
}

/* Signin button icons (email, etc.) */
.signin-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Apple Button - per Apple HIG proportions */
/* For 44pt button: font = 19pt (43% of height) */
/* https://developer.apple.com/design/human-interface-guidelines/sign-in-with-apple */
.signin-btn.apple {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  gap: 10px;
  font-size: 19px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
  letter-spacing: 0;
  border-radius: 6px;
  white-space: nowrap;
}

.signin-btn.apple .apple-logo-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  height: 100%;
}

.signin-btn.apple .apple-logo {
  height: 20px;
  width: auto;
  display: block;
}

/* Apple Button - per Apple HIG */
/* Light mode: black button with white text/logo */
/* Dark mode: white button with black text/logo */
.signin-btn.apple {
  background: #000;
  color: #fff;
  border-color: #000;
}

.signin-btn.apple:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
}

@media (prefers-color-scheme: dark) {
  .signin-btn.apple {
    background: #fff;
    color: #000;
    border-color: #fff;
  }

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

/* Microsoft Button - uniform style with Google/Apple */
/* https://learn.microsoft.com/en-us/entra/identity-platform/howto-add-branding-in-apps */
.signin-btn.microsoft {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 16px;
  gap: 10px;
  font-size: 19px;
  font-weight: 500;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
  border-radius: 6px;
  background: #2f2f2f;
  color: #fff;
  border-color: #2f2f2f;
  white-space: nowrap;
}

.signin-btn.microsoft .microsoft-logo {
  height: 20px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.signin-btn.microsoft:hover {
  background: #404040;
  border-color: #404040;
}

@media (prefers-color-scheme: dark) {
  .signin-btn.microsoft {
    background: #fff;
    color: #2f2f2f;
    border-color: #fff;
  }

  .signin-btn.microsoft:hover {
    background: #e5e5e5;
    border-color: #e5e5e5;
  }
}

/* ============================================
   Mobile Adjustments for OAuth Buttons
   ============================================ */

/* Intermediate mobile (360-480px) - slight font reduction */
@media (max-width: 480px) {
  .gsi-material-button {
    font-size: 16px;
  }

  .signin-btn.apple {
    font-size: 16px;
  }

  .signin-btn.microsoft {
    font-size: 16px;
  }
}

/* Small mobile (below 400px) - more aggressive reduction */
@media (max-width: 400px) {
  /* Google Sign-In Button - reduce font size for narrow screens */
  .gsi-material-button {
    font-size: 15px;
    height: 40px;
    padding: 0 12px;
  }

  .gsi-material-button .gsi-material-button-icon {
    height: 18px;
    min-width: 18px;
    width: 18px;
    margin-right: 8px;
  }

  /* Apple Button - reduce font size for narrow screens */
  .signin-btn.apple {
    font-size: 15px;
    height: 40px;
    padding: 0 12px;
    gap: 8px;
  }

  .signin-btn.apple .apple-logo {
    height: 18px;
  }

  /* Microsoft Button - reduce font size for narrow screens */
  .signin-btn.microsoft {
    font-size: 15px;
    height: 40px;
    padding: 0 12px;
    gap: 8px;
  }

  .signin-btn.microsoft .microsoft-logo {
    height: 18px;
  }

  /* Email input - smaller font on very narrow screens */
  .email-input {
    font-size: 0.875rem;
    padding: 0.75rem;
  }

  /* Auth box - tighter padding */
  .auth-box {
    padding: 1.5rem 1rem;
  }
}

/* Email Button (Primary Style) */
.signin-btn.email {
  height: 44px;
  padding: 0 16px;
  gap: 10px;
  font-size: 16px;
  font-weight: 500;
  border-radius: 6px;
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  white-space: nowrap;
}

/* Email Button - mobile adjustments */
@media (max-width: 400px) {
  .signin-btn.email {
    height: 40px;
    font-size: 14px;
    padding: 0 12px;
    gap: 8px;
  }

  .signin-btn.email svg {
    width: 18px;
    height: 18px;
  }
}

.signin-btn.email svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.signin-btn.email:hover {
  background: #0050c4;
  border-color: #0050c4;
}

@media (prefers-color-scheme: dark) {
  .signin-btn.email {
    background: var(--accent-color-dark);
    border-color: var(--accent-color-dark);
  }

  .signin-btn.email:hover {
    background: #1a8fff;
    border-color: #1a8fff;
  }
}

/* ============================================
   Divider
   ============================================ */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--button-bg);
}

@media (prefers-color-scheme: dark) {
  .auth-divider::before,
  .auth-divider::after {
    background: var(--button-bg-dark);
  }
}

.auth-divider-text {
  font-size: 0.8125rem;
  opacity: 0.6;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ============================================
   Email Form
   ============================================ */
.email-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.auth-field-hint {
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-secondary);
  background: var(--accent-bg);
  border-left: 3px solid var(--accent-color);
  border-radius: 0 6px 6px 0;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}

.auth-field-hint strong {
  color: var(--text-color);
}

.email-input {
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  font-family: inherit;
  color: var(--text-color);
  background: var(--page-bg);
  border: 1px solid var(--button-bg);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.email-input:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 96, 223, 0.15);
}

.email-input::placeholder {
  color: var(--text-color);
  opacity: 0.5;
}

@media (prefers-color-scheme: dark) {
  .auth-field-hint {
    color: var(--text-secondary-dark);
    background: var(--accent-bg-dark);
    border-left-color: var(--accent-color-dark);
  }

  .auth-field-hint strong {
    color: var(--text-color-dark);
  }

  .email-input {
    color: var(--text-color-dark);
    background: var(--page-bg-dark);
    border-color: var(--button-bg-dark);
  }

  .email-input:focus {
    border-color: var(--accent-color-dark);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
  }

  .email-input::placeholder {
    color: var(--text-color-dark);
    opacity: 0.5;
  }
}

/* ============================================
   Message (Success/Error)
   ============================================ */
.auth-message {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
  display: none;
}

.auth-message.success {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  display: block;
}

.auth-message.error {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  display: block;
}

@media (prefers-color-scheme: dark) {
  .auth-message.success {
    background: rgba(40, 167, 69, 0.2);
    color: #8fd19e;
    border-color: rgba(40, 167, 69, 0.3);
  }

  .auth-message.error {
    background: rgba(220, 53, 69, 0.2);
    color: #f5a5a5;
    border-color: rgba(220, 53, 69, 0.3);
  }
}

/* ============================================
   Invite Notice
   ============================================ */
.invite-notice {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--button-bg);
  text-align: center;
}

@media (prefers-color-scheme: dark) {
  .invite-notice {
    border-top-color: var(--button-bg-dark);
  }
}

.invite-notice-text {
  font-size: 0.875rem;
  opacity: 0.8;
  margin-bottom: 1rem;
  line-height: 1.5;
}

.waitlist-btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #fff;
  background: var(--accent-color);
  border: none;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
}

.waitlist-btn:hover {
  background: #0050c4;
  transform: translateY(-1px);
  text-decoration: none;
}

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

@media (prefers-color-scheme: dark) {
  .waitlist-btn {
    background: var(--accent-color-dark);
  }
  
  .waitlist-btn:hover {
    background: #1a8fff;
  }
}

/* ============================================
   OTP Step
   ============================================ */
.otp-instructions {
  text-align: center;
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
  opacity: 0.8;
}

.otp-instructions strong {
  color: var(--text-color);
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .otp-instructions strong {
    color: var(--text-color-dark);
  }
}

/* Hidden input for paste support */
.otp-hidden-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

/* OTP Boxes Container */
.otp-boxes {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Individual OTP Box */
.otp-box {
  width: 2.5rem;
  height: 3rem;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  font-family: 'SF Mono', Monaco, 'Courier New', monospace;
  color: var(--text-color);
  background: var(--page-bg);
  border: 2px solid var(--button-bg);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  text-transform: uppercase;
}

.otp-box:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(0, 96, 223, 0.15);
}

.otp-box.filled {
  border-color: var(--accent-color);
  background: var(--box-bg);
}

@media (prefers-color-scheme: dark) {
  .otp-box {
    color: var(--text-color-dark);
    background: var(--page-bg-dark);
    border-color: var(--button-bg-dark);
  }

  .otp-box:focus {
    border-color: var(--accent-color-dark);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
  }

  .otp-box.filled {
    border-color: var(--accent-color-dark);
    background: var(--box-bg-dark);
  }
}

@media (max-width: 400px) {
  .otp-boxes {
    gap: 0.25rem;
  }
  
  .otp-box {
    width: 2rem;
    height: 2.5rem;
    font-size: 1rem;
  }
}

/* OTP Links */
.otp-links {
  text-align: center;
  margin-top: 1rem;
  font-size: 0.8125rem;
}

.otp-link {
  background: none;
  border: none;
  font-family: inherit;
  font-size: inherit;
  color: var(--accent-color);
  cursor: pointer;
  padding: 0;
  transition: opacity 0.2s ease;
}

.otp-link:hover {
  opacity: 0.7;
  text-decoration: underline;
}

.otp-link:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  .otp-link {
    color: var(--accent-color-dark);
  }
}

.otp-link-separator {
  margin: 0 0.5rem;
  opacity: 0.4;
}

/* ============================================
   Turnstile Widget (Bot Protection)
   ============================================ */
.turnstile-container {
  display: block;
  margin: 0.75rem 0;
  min-height: 65px;
  width: 100%;
}

/* Force Turnstile widget and iframe to match button width */
.turnstile-container > div {
  width: 100% !important;
}

.turnstile-container iframe {
  width: 100% !important;
  max-width: 100% !important;
}

/* When Turnstile is loading or in managed mode */
.turnstile-container:empty {
  min-height: 0;
}

/* ============================================
   Back Link
   ============================================ */
.auth-back-link {
  display: inline-block;
  margin-top: 1.5rem;
  text-align: center;
  width: 100%;
  color: var(--accent-color);
  text-decoration: none;
  font-size: 0.875rem;
  transition: opacity 0.2s ease;
}

.auth-back-link:hover {
  opacity: 0.8;
  text-decoration: none;
}

@media (prefers-color-scheme: dark) {
  .auth-back-link {
    color: var(--accent-color-dark);
  }
}

