/*
  CSS Reset
  https://www.joshwcomeau.com/css/custom-css-reset/
*/

*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
}
body {
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}
input,
button,
textarea,
select {
  font: inherit;
}
p,
h1,
h2,
h3,
h4,
h5,
h6 {
  overflow-wrap: break-word;
}
#root,
#__next,
#app {
  isolation: isolate;
}

/*
  App Styles - Lumina Design System

  All visual properties are driven by CSS custom properties (variables).
  Override any of these in a custom theme file to restyle the UI:

  --color-primary        Main accent color (buttons, links, focus rings)
  --color-background     Page background
  --color-surface        Card / input background
  --color-text           Primary text
  --color-text-muted     Subdued text (labels, placeholders)
  --color-text-secondary Lower-contrast body text
  --color-border         Input / card borders
  --color-hover          Hover highlight on interactive rows
  --color-error          Error accent
  --color-error-bg       Error message background
  --color-error-border   Error field border
  --color-error-text     Error message text
  --radius-container     Border-radius for cards, inputs, buttons
  --font-family          Base font stack
*/
:root {
  --radius-container: 0.6rem;
  --color-primary: #006874;
  --color-background: #EFF5F6;
  --color-surface: #ffffff;
  --color-text: #000000;
  --color-text-muted: #1E1E1EA8;
  --color-text-secondary: rgba(30, 30, 30, 0.66);
  --color-border: #DEE3E5;
  --color-hover: #edeff2;
  --color-error: #b92f2f;
  --color-error-bg: #f8d7da;
  --color-error-border: #dc3545;
  --color-error-text: #721c24;
  --font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
    "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

body {
  --page-bg: var(--color-background);
  background: var(--page-bg);
  color: var(--color-text);
  font-family: var(--font-family);
}

.narrow {
  max-width: 50ch;
  margin-left: auto;
  margin-right: auto;
}
.wide {
  max-width: 90ch;
  margin: auto;
}

.columns {
  display: grid;
  grid-template-columns: 30ch 1fr;
  gap: 3rem;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  body {
    padding: 0 1rem;
    /* Extra bottom padding to allow scrolling when mobile keyboard appears */
    padding-bottom: 50vh;
  }

  .columns {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .wide {
    max-width: 100%;
    padding: 0;
  }

  .narrow {
    max-width: 100%;
    padding: 0;
    width: 100%;
  }

  /* Ensure forms don't overflow */
  form.narrow,
  form.gap {
    width: 100%;
    max-width: 100%;
  }

  .menu {
    gap: 1rem;
  }

  .menu ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .menu ul li {
    flex: 1 1 auto;
  }

  .menu a {
    text-align: center;
    padding: 0.75rem 1rem;
  }

  .menu > a {
    text-align: center;
    padding: 0.75rem 1rem;
    background: var(--color-hover);
    border-radius: var(--radius-container);
  }

  .user-info {
    margin-top: 0.5rem;
  }

  .box {
    padding: 0 1rem;
    width: 100%;
    max-width: 100%;
  }

  .box-title {
    font-size: 1.25rem;
    margin-bottom: 8px;
  }

  .box-title--spaced {
    margin-bottom: 16px;
  }

  .box-subtitle {
    font-size: 1rem;
    margin-bottom: 32px;
  }

  /* Form elements - ensure they don't overflow */
  .text-input-fieldset {
    width: 100%;
    max-width: 100%;
  }

  .text-input-fieldset input,
  .text-input-fieldset select {
    width: 100%;
    max-width: 100%;
  }

  .input-button,
  .secondary-btn {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
  }

  /* Back link and info messages */
  .back-button {
    padding: 0.5rem 0;
  }

  .info-message,
  .error-message {
    padding: 0.75rem;
    font-size: 0.9rem;
  }

  /* Form gaps */
  .gap {
    gap: 0.75rem;
  }

  /* Logo/header */
  #logomark {
    padding: 1.5rem 1rem;
    font-size: 2rem;
    margin: 1rem auto 1.5rem;
  }

  .client-logo {
    max-height: 3.5rem;
    margin: 2rem auto;
  }

  /* Code input mobile */
  .code-input-container {
    gap: 0.5rem;
  }

  .code-digit-input {
    width: 40px;
    height: 50px;
    font-size: 1.25rem;
  }
}

.gap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.small-gap {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.gap-above-to-small {
  margin-top: -0.8rem;
}

.box {
  border-radius: var(--radius-container);
  background: transparent;
  padding: 0 1.5rem;
  text-align: center;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}
.menu ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.2rem;
}
.menu a {
  border-radius: var(--radius-container);
  display: inline-block;
  padding: 0.5rem 0.75rem;
  width: 100%;
  color: inherit;
  text-decoration: none;
}
.menu a:hover {
  background: var(--color-hover);
}

.box-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}
.box-title--spaced {
  margin-bottom: 16px;
}
.box-subtitle {
  font-size: 1rem;
  color: var(--color-text);
  font-weight: normal;
  opacity: 0.9;
  margin-bottom: 32px;
}
.box-subtitle--tight {
  margin-bottom: 0;
}

#logomark {
  padding: 2rem 1rem;
  font-size: 3rem;
  border-radius: var(--radius-container);
  text-align: center;
  margin: 3rem auto 8px;
}

.client-logo {
  max-height: 4rem;
  margin: 3rem auto 8px;
  border-radius: 0.75rem;
}

.text-input-fieldset {
  border: none;
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-container);
  padding: 0.5rem 0.75rem;
  outline: 2px solid var(--color-border);
}
.text-input-fieldset label {
  font-size: 0.8rem;
  opacity: 0.85;
}
.text-input-fieldset input {
  background: none;
  border: none;
  color: inherit;
  padding: 0.1rem 0;
}
.text-input-fieldset input:focus {
  outline: none;
}
.text-input-fieldset:focus-within {
  outline: 2px solid var(--color-primary);
}

/* Primary button */
.input-button {
  width: 100%;
  border: none;
  border-radius: var(--radius-container);
  background: var(--color-primary);
  color: white;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 500;
  transition: opacity 0.15s ease;
}
.input-button:hover {
  opacity: 0.9;
}

.login-terms-notice {
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text);
  line-height: 1.4;
}
.login-terms-notice .legal-link {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}
.login-terms-notice .legal-link:hover {
  opacity: 0.7;
}

.text-btn {
  text-align: center;
  display: inline-block;
  text-decoration: none;
  width: 100%;
  border: none;
  border-radius: var(--radius-container);
  color: var(--color-primary);
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.messages {
  padding: 0;
  list-style-type: none;
  display: grid;
  gap: 1rem;
}

.messages li {
  display: flex;
  gap: 1rem;
  align-items: center;
}
.messages li svg {
  flex-shrink: 0;
  height: 1.75rem;
  width: 1.75rem;
}
.messages .msg-error {
  fill: var(--color-error);
}

.divider {
  text-align: center;
  position: relative;
}
.divider > span {
  background: var(--page-bg);
  padding: 0 .3rem;
  z-index: 1;
  position: relative;
}
.divider::after {
  content: "";
  height: 1px;
  width: 100%;
  display: block;
  position: absolute;
  top: 50%;
  background: currentColor;
  opacity: .2;
}

/* Back button styling (top of page, above logo) */
.back-button {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--color-text);
  text-decoration: none;
  font-size: 1rem;
  font-weight: 500;
  padding: 1rem;
  transition: opacity 0.15s ease;
  /* Position at very top of page */
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
}
.back-button:hover {
  opacity: 0.7;
}
.back-button svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Add top padding to body when back button is present */
body:has(.back-button) {
  padding-top: 3rem;
}

/* Ensure body can contain absolutely positioned elements */
body {
  position: relative;
  min-height: 100vh;
}

/* Back link styling (bottom of form) */
.back-link {
  display: inline-block;
  text-align: center;
  color: var(--color-text-muted);
  text-decoration: none;
  padding: 0.5rem 0;
  font-size: 0.95rem;
  transition: opacity 0.15s ease;
}
.back-link:hover {
  opacity: 0.7;
}

/* Secondary button (resend) styling */
.secondary-btn {
  width: 100%;
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-container);
  background: transparent;
  color: var(--color-primary);
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.secondary-btn:hover {
  background: var(--color-primary);
  color: white;
}

/* Resend form styling */
.resend-form {
  margin-top: -0.5rem;
}

/* Disabled input styling */
.text-input-fieldset input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

/* Info message styling */
.info-message {
  text-align: center;
  padding: 0.75rem 1rem;
  background: var(--color-surface);
  border-radius: var(--radius-container);
  font-size: 0.95rem;
  color: var(--color-text-secondary);
  margin: 0;
}

/* Error message styling (same position as info, but error colors) */
.error-message {
  text-align: center;
  padding: 0.75rem 1rem;
  background: var(--color-error-bg);
  border-radius: var(--radius-container);
  font-size: 0.95rem;
  color: var(--color-error-text);
  margin: 0;
}

/* Field error styling */
.field-error {
  color: var(--color-error-border);
  background: var(--color-error-bg);
  border: 1px solid var(--color-error-bg);
  border-radius: var(--radius-container);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  margin: 0;
}

/* Email highlight (teal color) */
.email-highlight {
  color: var(--color-primary);
  font-weight: 600;
}

/* Helper text */
.helper-text {
  font-size: 0.875rem;
  margin-top: -1rem;
  font-weight: 500;
}

.code-spam-hint {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  font-weight: normal;
  text-align: center;
  margin: 8px 0 0;
}

/* Code entry label */
.code-label {
  text-align: center;
  font-size: 1.2rem;
  color: var(--color-text-secondary);
  font-weight: 600;
  margin-top: 32px;
}

form[aria-busy="true"] .code-digit-input,
form[aria-busy="true"] .input-button,
form[aria-busy="true"] .input {
  pointer-events: none;
  opacity: 0.6;
}

/* 6-digit code input container */
.code-input-container {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.25rem 0;
}

/* Individual digit input box */
.code-digit-input {
  width: 50px;
  height: 60px;
  text-align: center;
  font-size: 1.5rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-container);
  background: var(--color-surface);
  color: var(--color-text);
  outline: 2px solid var(--color-border);
  transition: outline-color 0.15s ease;
}

.code-digit-input:focus {
  outline: 2px solid var(--color-primary);
}

/* Error state for code inputs */
.code-digit-input.error {
  outline: 2px solid var(--color-error-border);
  background: var(--color-surface);
}

.code-digit-input.error:focus {
  outline: 2px solid var(--color-error-border);
}

/* Resend link (underlined text style) */
.resend-link {
  display: inline-block;
  color: var(--color-text);
  text-decoration: underline;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: opacity 0.15s ease;
}
.resend-link:hover {
  opacity: 0.7;
}

/* Use different email link */
.change-email-link {
  display: inline-block;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;
  transition: opacity 0.15s ease;
}
.change-email-link:hover {
  opacity: 0.7;
}

/* Center container for code page links */
.code-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

/* Page container with back button */
.page-container {
  max-width: 50ch;
  margin: 0 auto;
  padding: 0 1rem;
}

