@import url('./tokens.css');

html:not(.auth-ready) { visibility: hidden; }
html.auth-ready { visibility: visible; }

body.auth-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
  box-sizing: border-box;
}

.auth-shell, .auth-field, .google-btn, .auth-submit, .auth-links, .auth-footer,
.auth-error, .auth-success, .auth-brand, .auth-title, .auth-subtitle, .auth-divider {
  box-sizing: border-box;
}

/* --- User menu dropdown (used in app/account/admin headers) --- */
.user-menu { position: relative; }
.user-menu-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 36px; padding: 0 var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text);
  font-family: inherit; font-size: var(--text-sm); font-weight: 500;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}
.user-menu-trigger:hover { background: var(--color-surface-secondary); }
.user-menu-avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--color-accent); color: var(--color-text-inverse);
  display: inline-grid; place-items: center;
  font-size: 11px; font-weight: 700;
}
.user-menu-label { max-width: 140px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-menu-dropdown {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 220px; padding: var(--space-2);
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: 2px; z-index: 50;
}
.user-menu-dropdown[hidden] { display: none; }
.user-menu-info { padding: var(--space-3); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-2); }
.user-menu-name { font-weight: 600; font-size: var(--text-sm); }
.user-menu-email { font-size: var(--text-xs); color: var(--color-text-secondary); word-break: break-all; }
.user-menu-dropdown a,
.user-menu-dropdown button {
  display: block; text-align: left; width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none; background: transparent; color: var(--color-text);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: var(--text-sm); cursor: pointer;
  text-decoration: none;
}
.user-menu-dropdown a:hover,
.user-menu-dropdown button:hover { background: var(--color-surface-secondary); }

.auth-shell {
  width: 100%;
  max-width: 440px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-10) var(--space-8);
  box-shadow: var(--shadow-lg);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-bottom: var(--space-8);
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
  text-decoration: none;
}

.auth-brand .brand-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
}

.auth-title {
  margin: 0 0 var(--space-2) 0;
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.auth-subtitle {
  margin: 0 0 var(--space-6) 0;
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.auth-form { display: flex; flex-direction: column; gap: var(--space-4); }

.auth-field { display: flex; flex-direction: column; gap: var(--space-2); }

.auth-field label {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
}

.auth-field input {
  height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-base);
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}

.auth-field input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-subtle);
}

.auth-field .hint {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

/* Password input with press-and-hold reveal toggle. The input is wrapped in
   a .pw-input-wrap (JS-injected) that sizes exactly to the 44px input row,
   so the absolutely-positioned button lands inside the field instead of
   next to the hint text underneath.

   padding-right reserves room inside the input so long passwords don't
   underlap the icon. */
.pw-input-wrap { position: relative; display: block; }
.pw-input-wrap > input { width: 100%; padding-right: 44px; box-sizing: border-box; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-text-tertiary);
  cursor: pointer;
  padding: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: color var(--duration-fast) var(--ease), background var(--duration-fast) var(--ease);
}

.password-toggle:hover { color: var(--color-text-secondary); background: var(--color-surface-secondary); }
.password-toggle:focus-visible {
  outline: none;
  color: var(--color-accent);
  box-shadow: 0 0 0 2px var(--color-accent-subtle);
}

.password-toggle svg { width: 20px; height: 20px; display: block; }
/* Default (password hidden): show the slashed/closed eye to indicate the
   password is currently NOT visible. While the button is pressed (password
   revealed), show the open eye to indicate it IS visible. */
.password-toggle .icon-show { display: none; }
.password-toggle .icon-hide { display: block; }
.password-toggle[aria-pressed="true"] .icon-show { display: block; }
.password-toggle[aria-pressed="true"] .icon-hide { display: none; }

.auth-submit {
  display: block;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: var(--color-text-inverse);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.auth-submit:hover { background: var(--color-accent-hover); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--color-text-tertiary);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin: var(--space-4) 0;
}

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

.google-btn {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration-fast) var(--ease);
}

.google-btn:hover { background: var(--color-surface-secondary); }

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

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-5);
  font-size: var(--text-sm);
}

.auth-links a {
  color: var(--color-accent);
  text-decoration: none;
}

.auth-links a:hover { text-decoration: underline; }

.auth-footer {
  text-align: center;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.auth-footer a { color: var(--color-accent); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }

.auth-error {
  padding: var(--space-3) var(--space-4);
  background: var(--color-danger-light);
  color: var(--color-danger);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: none;
}

.auth-error.visible { display: block; }

.auth-success {
  padding: var(--space-3) var(--space-4);
  background: var(--color-success-light);
  color: var(--color-success);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: none;
}

.auth-success.visible { display: block; }

.auth-loading { opacity: 0.7; pointer-events: none; }
