/* ==========================================================================
   Sign-in flow (layouts/auth.html.erb): sign in, sign up, password reset and
   two-factor setup. Same visual language as the dashboard / inventory pages.
   This layout does not load application.css (Materialize), so these rules
   are written against plain browser defaults.
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

.auth-body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 480px at 50% -120px, rgba(31, 111, 235, 0.10), transparent 70%),
    #f6f7f9;
  color: #1f2530;
  font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.auth-shell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
  padding: 48px 16px 24px;
}

.auth-logo {
  display: inline-block;
  margin-bottom: 24px;
}

.auth-logo img {
  display: block;
  height: 44px;
  width: auto;
}

/* ---------- Card ---------- */
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 28px 28px 24px;
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15, 20, 30, 0.04), 0 12px 32px rgba(15, 20, 30, 0.06);
}

.auth-card.auth-card-wide {
  max-width: 520px;
}

.auth-card-head {
  margin-bottom: 20px;
}

.auth-card-head h1 {
  margin: 0 0 6px;
  font-family: "Lato", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  color: #1f2530;
}

.auth-card-head p {
  margin: 0;
  font-size: 14px;
  color: #6a7280;
}

.auth-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: #eaf2ff;
  color: #1f6feb;
  font-size: 18px;
}

/* ---------- Alerts (flash + validation errors) ---------- */
.auth-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 16px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
}

.auth-alert i {
  margin-top: 2px;
  font-size: 14px;
}

.auth-alert ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.auth-alert-error {
  background: #fdecec;
  border-color: #f3c2c2;
  color: #8f1f1f;
}

.auth-alert-info {
  background: #e1f5e9;
  border-color: #a8d4b8;
  color: #124c25;
}

/* ---------- Form ---------- */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.auth-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.auth-label {
  font-size: 13px;
  font-weight: 600;
  color: #1f2530;
}

.auth-label .auth-optional {
  font-weight: 400;
  color: #8a94a3;
}

.auth-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.auth-input {
  width: 100%;
  height: 40px;
  margin: 0;
  padding: 0 12px;
  background: #fff;
  border: 1px solid #c8ccd3;
  border-radius: 8px;
  color: #1f2530;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.auth-input:hover {
  border-color: #8a94a3;
}

.auth-input:focus {
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.auth-input::-moz-placeholder {
  color: #9aa0a8;
}

.auth-input::placeholder {
  color: #9aa0a8;
}

.auth-input-code {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3em;
}

.auth-hint {
  font-size: 12px;
  color: #6a7280;
}

/* Password field with show/hide toggle */
.auth-password {
  position: relative;
}

.auth-password .auth-input {
  padding-right: 42px;
}

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #6a7280;
  font-size: 14px;
  cursor: pointer;
  transform: translateY(-50%);
}

.auth-password-toggle:hover {
  background: #f6f7f9;
  color: #1f2530;
}

.auth-password-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.35);
}

/* Optional file input (profile picture) */
.auth-file {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  cursor: pointer;
}

.auth-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.auth-file-button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid #c8ccd3;
  border-radius: 999px;
  color: #1f2530;
  font-size: 13px;
  font-weight: 500;
}

.auth-file:hover .auth-file-button {
  border-color: #8a94a3;
}

.auth-file-input:focus-visible + .auth-file-button {
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.15);
}

.auth-file-name {
  overflow: hidden;
  min-width: 0;
  color: #6a7280;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Buttons & links ---------- */
.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin: 4px 0 0;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}

.auth-btn-primary {
  background: #1f6feb;
  border-color: #1f6feb;
  color: #fff;
}

.auth-btn-primary:hover {
  background: #1a5fcc;
  border-color: #1a5fcc;
}

.auth-btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.3);
}

.auth-btn[disabled] {
  opacity: 0.7;
  cursor: progress;
}

.auth-card a {
  color: #1f6feb;
  text-decoration: none;
}

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

.auth-link-small {
  font-size: 12px;
  font-weight: 500;
}

.auth-switch {
  margin: 20px 0 0;
  padding-top: 16px;
  border-top: 1px solid #edeef1;
  color: #6a7280;
  font-size: 13px;
  text-align: center;
}

.auth-switch a {
  font-weight: 600;
}

.auth-fineprint {
  margin: 0;
  color: #6a7280;
  font-size: 12px;
}

.auth-next-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 12px;
  background: #f6f7f9;
  border-radius: 8px;
  color: #4a5060;
  font-size: 12px;
}

.auth-next-step i {
  margin-top: 2px;
  color: #1f6feb;
}

/* ---------- Two-factor setup steps ---------- */
.auth-steps {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin: 0 0 20px;
  padding: 0;
  list-style: none;
}

.auth-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.auth-step-num {
  display: inline-flex;
  flex: 0 0 24px;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-top: 1px;
  background: #1f6feb;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.auth-step-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.auth-step-title {
  font-size: 14px;
  font-weight: 600;
  color: #1f2530;
}

.auth-step-text {
  font-size: 13px;
  color: #6a7280;
}

.auth-qr {
  display: block;
  width: 168px;
  height: 168px;
  margin-top: 8px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  image-rendering: pixelated;
}

.auth-manual-key {
  margin-top: 8px;
  font-size: 13px;
}

.auth-manual-key summary {
  color: #1f6feb;
  cursor: pointer;
}

.auth-manual-key summary:hover {
  text-decoration: underline;
}

.auth-secret-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.auth-secret {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: #f6f7f9;
  border: 1px solid #e2e5ea;
  border-radius: 6px;
  color: #1f2530;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.auth-copy-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid #c8ccd3;
  border-radius: 999px;
  color: #1f2530;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.auth-copy-btn:hover {
  border-color: #8a94a3;
}

.auth-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #edeef1;
  color: #6a7280;
  font-size: 12px;
}

/* ---------- Page footer ---------- */
.auth-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 18px;
  margin-top: auto;
  padding-top: 32px;
  font-size: 12px;
}

.auth-footer a,
.auth-footer span {
  color: #6a7280;
  text-decoration: none;
}

.auth-footer a:hover {
  color: #1f2530;
  text-decoration: underline;
}

@media (max-width: 480px) {
  .auth-shell { padding-top: 28px; }
  .auth-card { padding: 22px 18px 18px; }
  .auth-field-row { grid-template-columns: 1fr; }
}
