/* ============================================================
   XLNC Builder — Login dialog
   Opened by the header's Login button (login_update/login.js).
   Uses the design tokens from assets/css/styles.css.
   ============================================================ */

html.login-open { overflow: hidden; }

/* margin:auto centres the modal; the site reset (* { margin: 0 }) would otherwise pin it top-left. */
.login-dialog {
  width: min(380px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem);
  margin: auto; padding: 0; border: 0; border-radius: 22px; overflow: auto;
  background: var(--color-surface); color: var(--color-body);
  box-shadow: var(--sh-lg);
}
.login-dialog::backdrop { background: rgba(28, 25, 23, 0.5); }
.login-dialog[open] { animation: login-in 0.3s var(--ease); }
@keyframes login-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }

/* Fills the dialog, so a click that lands on the dialog itself is a backdrop click. */
.login-panel { padding: 1.6rem 1.6rem 1.7rem; }

.login-top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1rem; }
.login-logo { width: 46px; height: 46px; border-radius: 50%; }
.login-close {
  flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  background: var(--color-surface-2); color: var(--color-ink);
  transition: background 0.2s var(--ease);
}
.login-close:hover { background: var(--color-surface-3); }
.login-close svg { width: 14px; height: 14px; }

.login-title { font-size: 1.5rem; margin-bottom: 0.3rem; }
.login-lead { font-size: 0.82rem; line-height: 1.5; color: var(--color-body); margin-bottom: 1.1rem; }

/* Admin / Employee switch */
.login-roles {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.25rem;
  padding: 0.3rem; margin-bottom: 1.2rem; border-radius: var(--r-pill);
  background: var(--color-surface-3);
}
.login-role {
  padding: 0.55rem 0.8rem; border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: transparent; color: var(--color-body); font-weight: 600; font-size: 0.85rem;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.login-role[aria-pressed="true"] { background: var(--color-surface); color: var(--color-ink); box-shadow: var(--sh-sm); }

.login-field { margin-bottom: 0.95rem; }
.login-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.4rem; }
.login-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--color-ink); }
.login-label-row .login-label { margin-bottom: 0; }
.login-field > .login-label { margin-bottom: 0.4rem; }
.login-forgot {
  padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 0.76rem; font-weight: 500; color: var(--color-accent-text);
  text-decoration: underline; text-underline-offset: 2px;
}
.login-input {
  display: block; width: 100%; height: 42px; padding: 0 0.85rem;
  border: 1px solid var(--color-border-strong); border-radius: 10px;
  background: var(--color-surface); color: var(--color-ink); font-size: 0.88rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.login-input::placeholder { color: var(--stone-400); }

/* Show/hide password eye, inside the right edge of the field. Edge's own reveal icon is hidden so there is only one. */
.login-pass-wrap { position: relative; }
.login-pass-wrap .login-input { padding-right: 2.75rem; }
.login-input::-ms-reveal { display: none; }
.login-eye {
  position: absolute; top: 50%; right: 0.35rem; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; border-radius: 8px; cursor: pointer;
  display: grid; place-items: center; background: none; color: var(--stone-500);
  transition: color 0.2s var(--ease);
}
.login-eye:hover, .login-eye[aria-pressed="true"] { color: var(--color-ink); }
.login-eye svg { width: 18px; height: 18px; }
.login-input:focus { outline: none; border-color: var(--gold-700); box-shadow: 0 0 0 3px rgba(161, 98, 7, 0.18); }
.login-input[aria-invalid="true"] { border-color: var(--color-destructive); }

.login-submit {
  display: block; width: 100%; margin-top: 0.3rem; padding: 0.75rem 1.25rem;
  border: 0; border-radius: var(--r-pill); cursor: pointer;
  background: var(--grad-gold-strong); color: var(--white); font-weight: 600; font-size: 0.88rem;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.login-submit:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(161, 98, 7, 0.32); }
.login-submit:active { transform: translateY(0); }

.login-notice {
  margin-top: 0.8rem; padding: 0.6rem 0.85rem; border-radius: 10px;
  background: var(--color-surface-2); color: var(--color-ink); font-size: 0.8rem; line-height: 1.5;
}
.login-notice[hidden] { display: none; }
.login-submit:disabled { opacity: 0.7; cursor: default; transform: none; box-shadow: none; }

/* ---------- Forgot password: the reset view (email → code → new password) ---------- */
.reset-steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.4rem; margin: 0 0 1.1rem; padding: 0; list-style: none; }
.reset-steps li {
  padding-top: 0.45rem; border-top: 3px solid var(--color-border-strong);
  font-size: 0.7rem; font-weight: 600; color: var(--color-muted);
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}
.reset-steps li.is-done, .reset-steps li[aria-current] { border-color: var(--gold-700); color: var(--color-ink); }
.reset-steps li.is-done { opacity: 0.6; }
.login-lead strong { font-weight: 600; color: var(--color-ink); overflow-wrap: anywhere; }
.reset-code { height: 54px; padding-left: 0.6em; text-align: center; font-size: 1.5rem; font-weight: 600; letter-spacing: 0.6em; font-variant-numeric: tabular-nums; }
.reset-error { margin-top: 0.35rem; font-size: 0.76rem; line-height: 1.4; color: var(--color-destructive); }
.reset-alt { display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.9rem; }
.login-forgot:disabled { color: var(--color-muted); text-decoration: none; cursor: default; }
.reset-back {
  display: block; margin: 1.1rem auto 0; padding: 0; border: 0; background: none; cursor: pointer;
  font-size: 0.8rem; color: var(--color-body);
}
.reset-back:hover { color: var(--color-ink); }
/* These set display, which would otherwise beat the hidden attribute. */
.reset-error[hidden], .reset-back[hidden], .login-dialog [data-view][hidden], .login-dialog [data-reset][hidden] { display: none; }

@media (max-width: 480px) {
  .login-panel { padding: 1.4rem 1.2rem; }
}
