/**
 * seenzi — Auth Site themes (light / dark)
 *
 * Shared stylesheet for login, register, forgot-password, callback pages.
 * Tokens mirror the extension design system; switched via <html data-theme="light|dark">.
 */

/* Theme tokens */
:root,
[data-theme="dark"] {
  --auth-bg: #1f292b;
  --auth-text: #fff;
  --auth-text-muted: rgba(255, 255, 255, 0.6);
  --auth-text-muted-2: rgba(255, 255, 255, 0.4);
  --auth-text-muted-3: rgba(255, 255, 255, 0.5);
  --auth-security-note: rgba(255, 255, 255, 0.65);
  --auth-label: #a4b9be;
  --auth-optional-label: rgba(255, 255, 255, 0.4);
  --auth-input-bg: rgba(255, 255, 255, 0.08);
  --auth-input-border: rgba(255, 255, 255, 0.12);
  --auth-input-border-focus: rgba(255, 255, 255, 0.25);
  --auth-input-text: #fff;
  --auth-placeholder: rgba(255, 255, 255, 0.3);
  --auth-accent: #dcf34d;
  --auth-logo-text: #ffffff;
  --auth-error-bg: rgba(255, 107, 107, 0.1);
  --auth-error-border: rgba(255, 107, 107, 0.3);
  --auth-error-text: #ff6b6b;
  --auth-divider-line: rgba(255, 255, 255, 0.12);
  --auth-divider-text: rgba(255, 255, 255, 0.4);
  --auth-oauth-bg: transparent;
  --auth-oauth-border: rgba(255, 255, 255, 0.12);
  --auth-oauth-text: #fff;
  --auth-oauth-hover: rgba(255, 255, 255, 0.05);
  --auth-link-disabled: rgba(255, 255, 255, 0.3);
  --auth-btn-primary-start: #d4f54d;
  --auth-btn-primary-end: #c0e03a;
  --auth-btn-primary-fg: #1F292B;
  --auth-spinner-border: rgba(31, 41, 43, 0.3);
  --auth-spinner-top: #1F292B;
  --auth-rule-passed: #ace2c2;
  --auth-rule-fail: rgba(255, 255, 255, 0.4);
  --auth-code-focus: #dcf34d;
  --auth-callback-spinner-track: rgba(255, 255, 255, 0.1);
  --auth-callback-spinner-top: #dcf34d;
  --auth-callback-text: rgba(255, 255, 255, 0.8);
  --auth-toast-bg: rgba(172, 226, 194, 0.15);
  --auth-toast-border: rgba(172, 226, 194, 0.3);
  --auth-toast-text: #ace2c2;
}

[data-theme="light"] {
  --auth-bg: #f4f6f7;
  --auth-text: #1a2428;
  --auth-text-muted: rgba(26, 36, 40, 0.65);
  --auth-text-muted-2: rgba(26, 36, 40, 0.45);
  --auth-text-muted-3: rgba(26, 36, 40, 0.55);
  --auth-security-note: rgba(26, 36, 40, 0.7);
  --auth-label: #4a5c62;
  --auth-optional-label: rgba(26, 36, 40, 0.45);
  --auth-input-bg: #fff;
  --auth-input-border: rgba(26, 36, 40, 0.12);
  --auth-input-border-focus: rgba(26, 36, 40, 0.28);
  --auth-input-text: #1a2428;
  --auth-placeholder: rgba(26, 36, 40, 0.38);
  --auth-accent: #5a6b0a;
  --auth-logo-text: #1a2428;
  --auth-error-bg: rgba(220, 53, 69, 0.08);
  --auth-error-border: rgba(220, 53, 69, 0.35);
  --auth-error-text: #c62828;
  --auth-divider-line: rgba(26, 36, 40, 0.12);
  --auth-divider-text: rgba(26, 36, 40, 0.45);
  --auth-oauth-bg: #fff;
  --auth-oauth-border: rgba(26, 36, 40, 0.15);
  --auth-oauth-text: #1a2428;
  --auth-oauth-hover: rgba(26, 36, 40, 0.04);
  --auth-link-disabled: rgba(26, 36, 40, 0.35);
  --auth-btn-primary-start: #c8f547;
  --auth-btn-primary-end: #a3e635;
  --auth-btn-primary-fg: #1a2428;
  --auth-spinner-border: rgba(26, 36, 40, 0.2);
  --auth-spinner-top: #1a2428;
  --auth-rule-passed: #2e7d4a;
  --auth-rule-fail: rgba(26, 36, 40, 0.4);
  --auth-code-focus: #5a6b0a;
  --auth-callback-spinner-track: rgba(26, 36, 40, 0.12);
  --auth-callback-spinner-top: #5a6b0a;
  --auth-callback-text: rgba(26, 36, 40, 0.75);
  --auth-toast-bg: rgba(46, 125, 74, 0.12);
  --auth-toast-border: rgba(46, 125, 74, 0.28);
  --auth-toast-text: #2e7d4a;
}

/* 1. Global reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 2. Body */
body {
  background: var(--auth-bg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--auth-text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 3. Auth container */
.auth-container {
  max-width: 400px;
  width: 100%;
  padding: 40px 32px;
  margin: 0 auto;
}

/* Shared staggered reveal for login / register surfaces */
.auth-header > *,
#login-error,
#register-error,
#login-form > *,
#register-form > *,
.auth-divider,
.oauth-buttons,
.auth-footer-text {
  animation: slideUpFade 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.auth-header > *:nth-child(1) { animation-delay: 0.02s; }
.auth-header > *:nth-child(2) { animation-delay: 0.04s; }
#login-form > *:nth-child(1),
#register-form > *:nth-child(1) { animation-delay: 0.06s; }
#login-form > *:nth-child(2),
#register-form > *:nth-child(2) { animation-delay: 0.08s; }
#register-form > *:nth-child(3) { animation-delay: 0.1s; }
#login-form > *:nth-child(3),
#register-form > *:nth-child(4) { animation-delay: 0.12s; }
#register-form > *:nth-child(5),
.auth-divider { animation-delay: 0.16s; }
.oauth-buttons { animation-delay: 0.19s; }
.auth-footer-text { animation-delay: 0.22s; }

@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 4. Auth header */
.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

/* 5. Auth logo */
.auth-logo {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.auth-logo-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: block;
}

.auth-logo-text,
.auth-logo-accent {
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.auth-logo-text {
  color: var(--auth-logo-text);
}

.auth-logo-accent {
  color: var(--auth-accent);
}

/* 5b. Header: icon-only hero mark (login / register / forgot-password — matches original extension auth) */
.auth-logo--mark-only {
  margin-bottom: 28px;
  gap: 0;
  flex-wrap: nowrap;
}

/* Tighter gap when a page title sits directly under the hero mark */
.auth-header:has(.auth-title) .auth-logo--mark-only {
  margin-bottom: 16px;
}

.auth-logo--mark-only .auth-logo-icon {
  width: 88px;
  height: 88px;
  filter: drop-shadow(0 0 24px color-mix(in srgb, var(--auth-accent) 42%, transparent));
}

/* 6. Auth title */
.auth-title {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--auth-text);
  margin-bottom: 8px;
}

/* 7. Auth subtitle */
.auth-subtitle {
  font-size: 14px;
  color: var(--auth-text-muted);
  line-height: 1.5;
}

/* 8. Security note */
.security-note {
  font-size: 14px;
  color: var(--auth-security-note);
  line-height: 1.5;
  font-weight: 500;
}

/* 9. Form group */
.form-group {
  margin-bottom: 20px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-group:focus-within {
  transform: translateY(-2px);
}

/* 10. Label */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--auth-label);
  margin-bottom: 6px;
}

/* 11. Optional label */
.optional-label {
  font-weight: 400;
  color: var(--auth-optional-label);
}

/* 12. Text inputs */
input[type="email"],
input[type="password"],
input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  background: var(--auth-input-bg);
  border: 1px solid var(--auth-input-border);
  border-radius: 8px;
  color: var(--auth-input-text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  border-color: var(--auth-accent);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--auth-accent) 18%, transparent);
}

input[type="email"]::placeholder,
input[type="password"]::placeholder,
input[type="text"]::placeholder {
  color: var(--auth-placeholder);
}

/* 13. Password input wrapper */
.password-input-wrapper {
  position: relative;
}

.password-input-wrapper input {
  padding-right: 44px;
}

/* 14. Password toggle */
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--auth-label);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.password-toggle:hover {
  color: var(--auth-text);
}

/* 15. Form group footer */
.form-group-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* 16. Forgot password link */
.forgot-password-link {
  font-size: 13px;
  color: var(--auth-accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  transition: color 0.2s, transform 0.2s, opacity 0.2s;
}

.forgot-password-link:hover {
  text-decoration: none;
  color: var(--auth-text);
  opacity: 0.92;
  transform: translateY(-1px);
}

/* 17. Primary button */
.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--auth-btn-primary-start) 0%, var(--auth-btn-primary-end) 100%);
  color: var(--auth-btn-primary-fg);
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--auth-btn-primary-end) 30%, transparent);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* 18. Button spinner */
.btn-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--auth-spinner-border);
  border-top-color: var(--auth-spinner-top);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 19. Auth divider */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 24px 0;
  color: var(--auth-divider-text);
  font-size: 13px;
}

.auth-divider span {
  padding: 0 16px;
  white-space: nowrap;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--auth-divider-line);
}

/* 20. OAuth buttons container */
.oauth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* 21. OAuth button */
.btn-oauth {
  width: 100%;
  padding: 12px;
  background: var(--auth-oauth-bg);
  border: 1px solid var(--auth-oauth-border);
  border-radius: 8px;
  color: var(--auth-oauth-text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.2s, transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn-oauth:hover {
  background: var(--auth-oauth-hover);
  border-color: color-mix(in srgb, var(--auth-accent) 24%, var(--auth-oauth-border));
  box-shadow: 0 10px 22px color-mix(in srgb, var(--auth-accent) 10%, transparent);
  transform: translateY(-1px);
}

/* 22. OAuth icon */
.oauth-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* 23. Auth footer text */
.auth-footer-text {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--auth-text-muted);
}

/* 24. Auth link */
.auth-link {
  color: var(--auth-accent);
  text-decoration: none;
  transition: color 0.2s, transform 0.2s, opacity 0.2s;
}

.auth-link:hover {
  text-decoration: none;
  color: var(--auth-text);
  opacity: 0.92;
  transform: translateY(-1px);
}

/* 25. Auth link button (looks like a link) */
.auth-link-btn {
  background: none;
  border: none;
  color: var(--auth-accent);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  padding: 0;
}

.auth-link-btn:hover {
  text-decoration: underline;
}

.auth-link-btn:disabled {
  color: var(--auth-link-disabled);
  cursor: not-allowed;
  text-decoration: none;
}

/* 26. Forgot-password page specific layout / transitions */
.auth-page--forgot .auth-header {
  margin-bottom: 16px;
}

.auth-page--forgot .auth-logo--mark-only {
  margin-bottom: 0;
}

.auth-page--forgot .step {
  animation: slideUpFade 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-page--forgot .step > * {
  animation: slideUpFade 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  opacity: 0;
}

.auth-page--forgot .step > *:nth-child(1) { animation-delay: 0.02s; }
.auth-page--forgot .step > *:nth-child(2) { animation-delay: 0.04s; }
.auth-page--forgot .step > *:nth-child(3) { animation-delay: 0.06s; }
.auth-page--forgot .step > *:nth-child(4) { animation-delay: 0.08s; }
.auth-page--forgot .step > *:nth-child(5) { animation-delay: 0.1s; }
.auth-page--forgot .step > *:nth-child(6) { animation-delay: 0.12s; }

.auth-page--forgot .step-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-page--forgot .step-header .auth-title {
  margin-bottom: 8px;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.auth-page--forgot .step-header .auth-subtitle {
  margin: 0;
  color: var(--auth-text-muted-2);
  font-size: 15px;
}

.auth-page--forgot .code-digits-wrapper {
  position: relative;
  margin: 16px 0 24px 0;
  display: flex;
  justify-content: center;
  width: 100%;
}

.auth-page--forgot .code-inputs {
  margin: 0;
  width: 100%;
}

.auth-page--forgot .code-digit {
  width: 46px;
  height: 54px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin: 0;
}

.auth-page--forgot .code-digit:focus {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px color-mix(in srgb, var(--auth-accent) 20%, transparent);
  border-color: var(--auth-accent);
}

.auth-page--forgot .resend-text {
  margin-bottom: 24px;
  text-align: center;
}

.auth-page--forgot .back-link-wrapper {
  margin-top: 16px;
  text-align: center;
  display: flex;
  justify-content: center;
}

.auth-page--forgot .back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  padding: 10px 20px;
  border-radius: 8px;
  background: transparent;
  color: var(--auth-text-muted);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-page--forgot .back-link:hover {
  color: var(--auth-text);
  background: var(--auth-oauth-hover);
  transform: translateY(-1px);
}

.auth-page--forgot .back-link svg {
  width: 16px;
  height: 16px;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.auth-page--forgot .back-link:hover svg {
  transform: translateX(-4px);
}

/* 26. Auth error */
.auth-error {
  background: var(--auth-error-bg);
  border: 1px solid var(--auth-error-border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--auth-error-text);
  font-size: 14px;
  margin-bottom: 16px;
}

/* 27. Password rules container */
.password-rules {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.password-rules:empty {
  display: none;
  margin-top: 0;
}

/* 28. Individual password rule */
.password-rule {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  transition: color 0.2s;
}

.password-rule.passed {
  color: var(--auth-rule-passed);
}

.password-rule.failed {
  color: var(--auth-rule-fail);
}

/* 29. Terms text */
.terms-text {
  font-size: 12px;
  color: var(--auth-text-muted-2);
  text-align: center;
  margin-top: 12px;
  line-height: 1.5;
}

/* 30. Verification code inputs */
.code-inputs {
  display: flex;
  flex-direction: row;
  gap: 8px;
  justify-content: center;
  margin: 24px 0;
}

/* 31. Code digit input */
.code-digit {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  background: var(--auth-input-bg);
  border: 1px solid var(--auth-input-border);
  border-radius: 8px;
  color: var(--auth-input-text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  padding: 0;
}

.code-digit:focus {
  border-color: var(--auth-code-focus);
}

/* 32. Resend text */
.resend-text {
  text-align: center;
  font-size: 13px;
  color: var(--auth-text-muted-3);
  margin-bottom: 20px;
}

/* 33. Step visibility */
.step[hidden] {
  display: none;
}

/* 34. Callback container */
.callback-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
}

/* 35. Callback spinner */
.callback-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--auth-callback-spinner-track);
  border-top-color: var(--auth-callback-spinner-top);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* 36. Callback text */
.callback-text {
  margin-top: 16px;
  font-size: 16px;
  color: var(--auth-callback-text);
  text-align: center;
}

.callback-close-btn {
  margin-top: 16px;
}

.callback-title {
  margin-top: 18px;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--auth-text);
  text-align: center;
}

.callback-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
}

.callback-back-link {
  font-size: 14px;
  font-weight: 500;
}

/* 37. Info toast */
.info-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--auth-toast-bg);
  border: 1px solid var(--auth-toast-border);
  color: var(--auth-toast-text);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  animation: toast-in 0.3s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* 38. Input error state */
.input-error {
  border-color: var(--auth-error-text) !important;
}

/* ========================================
   Utility & Accessibility
   ======================================== */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Reset fieldset UA styles for code-digit grouping */
.code-fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

/* Chrome extension popup (ext=1): balanced medium layout — scoped to html hook from config.js */
html.auth-extension-popup body {
  padding: 0;
  overflow-y: auto;
}

html.auth-extension-popup .auth-container {
  padding: 24px 28px;
}

html.auth-extension-popup .auth-header {
  margin-bottom: 20px;
}

html.auth-extension-popup .auth-logo--mark-only .auth-logo-icon {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 0 18px color-mix(in srgb, var(--auth-accent) 36%, transparent));
}

html.auth-extension-popup .auth-header:has(.auth-title) .auth-logo--mark-only {
  margin-bottom: 12px;
}

html.auth-extension-popup .auth-title {
  font-size: 24px;
  margin-bottom: 4px;
}

html.auth-extension-popup .form-group {
  margin-bottom: 16px;
}

html.auth-extension-popup .auth-divider {
  margin: 16px 0;
}

html.auth-extension-popup .oauth-buttons {
  gap: 8px;
}

html.auth-extension-popup .auth-footer-text {
  margin-top: 16px;
}

html.auth-extension-popup body.auth-page--forgot .step-header {
  margin-bottom: 20px;
}

html.auth-extension-popup body.auth-page--forgot .code-digits-wrapper {
  margin: 12px 0 16px 0;
}

html.auth-extension-popup body.auth-page--forgot .resend-text {
  margin-bottom: 16px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
