/*
 * eas-auth-standalone — shared UI styles (v1.2.0+)
 *
 * Used by /auth/login, /auth/first-login, and /auth/profile. Each view
 * loads this file first, then its own view-specific overrides.
 *
 * Visual style is intentionally "EAS dark" so the page fits in any
 * applicative. Consumers can override via a parent stylesheet by
 * targeting the CSS custom properties below.
 */
:root {
  --eas-bg: #1a1d23;
  --eas-card: #242830;
  --eas-muted: #8b929b;
  --eas-text: #e6e8eb;
  --eas-accent: #f4bf44;
  --eas-accent-strong: #e0aa1e;
  --eas-err: #ef4444;
  --eas-ok: #22c55e;
  --eas-border: #353a44;
  --eas-input-bg: #11161d;
  --eas-radius: 12px;
  --eas-radius-sm: 6px;
  --eas-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --eas-font: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --eas-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  background: var(--eas-bg);
  color: var(--eas-text);
  font-family: var(--eas-font);
  font-size: 15px;
  line-height: 1.45;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.eas-card {
  background: var(--eas-card);
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius);
  padding: 24px;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--eas-shadow);
}

.eas-card h1 {
  font-size: 22px;
  margin: 0 0 4px;
  font-weight: 600;
}
.eas-card h3 {
  font-size: 16px;
  margin: 16px 0 8px;
  color: var(--eas-accent);
  font-weight: 600;
}
.eas-card .muted { color: var(--eas-muted); font-size: 13px; }

.eas-card input[type="text"],
.eas-card input[type="password"],
.eas-card input[type="email"],
.eas-card input[type="tel"],
.eas-card input:not([type]) {
  /* v1.3.4: `input:not([type])` matches inputs without an explicit
     `type` attribute (they default to text per spec). Required because
     the login HTML uses `<input id="f-username" autocomplete="username">`
     and `<input id="f-otp" class="otp">` with NO type — the older
     selector matched only the password field, leaving the other two
     unstyled (white browser-default). */
  display: block;
  width: 100%;
  margin: 8px 0;
  padding: 12px 14px;
  background: var(--eas-input-bg);
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius-sm);
  color: var(--eas-text);
  font-family: var(--eas-font);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s ease;
}
.eas-card input:focus {
  border-color: var(--eas-accent);
}

/* v1.3.4: Chrome (and WebKit-based browsers) override input background
   when the field is autofilled by the password manager. Without this
   override, the styled dark-theme input flashes to a grey/yellow
   browser-managed color the moment autofill happens — creating an
   inconsistency between autofilled and manually-typed fields. The
   inset box-shadow trick is the standard remedy: it fills the input
   with our background color from inside, overriding the user-agent
   autofill background. The text-fill-color keeps the text in the
   right color. */
.eas-card input:-webkit-autofill,
.eas-card input:-webkit-autofill:hover,
.eas-card input:-webkit-autofill:focus,
.eas-card input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--eas-input-bg) inset !important;
  -webkit-text-fill-color: var(--eas-text) !important;
  caret-color: var(--eas-text) !important;
  transition: background-color 9999s ease-in-out 0s;
}

.eas-card button {
  display: block;
  width: 100%;
  margin: 12px 0 6px;
  padding: 12px 16px;
  background: var(--eas-accent);
  color: #1a1d23;
  border: none;
  border-radius: var(--eas-radius-sm);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.eas-card button:hover { background: var(--eas-accent-strong); }
.eas-card button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.eas-card button.secondary {
  background: transparent;
  color: var(--eas-muted);
  border: 1px solid var(--eas-border);
}
.eas-card button.secondary:hover {
  color: var(--eas-text);
  border-color: var(--eas-muted);
}

.eas-card .err,
.eas-card .error {
  color: var(--eas-err);
  font-size: 13px;
  margin: 8px 0;
  min-height: 18px;
  word-break: break-word;
}
.eas-card .ok {
  color: var(--eas-ok);
  font-size: 13px;
  margin: 8px 0;
}

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

.hide { display: none !important; }

/* OTP / numeric inputs */
.eas-card input.otp {
  font-family: var(--eas-mono);
  font-size: 22px;
  letter-spacing: 0.3em;
  text-align: center;
}

/* Secret / backup-codes display */
.eas-card pre,
.eas-card code.secret {
  font-family: var(--eas-mono);
  background: var(--eas-input-bg);
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  word-break: break-all;
  user-select: all;
}
.eas-card pre {
  white-space: pre-wrap;
  margin: 12px 0;
}

/* Toast */
.eas-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--eas-card);
  color: var(--eas-text);
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius-sm);
  padding: 10px 16px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.eas-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Profile-specific layout helpers */
.eas-card .row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--eas-border);
}
.eas-card .row:last-child { border-bottom: 0; }
.eas-card .row .label { color: var(--eas-muted); font-size: 13px; }
.eas-card .row .value { font-family: var(--eas-mono); font-size: 13px; }

/* v1.3.0: Open-OTP-app inline button (next to OTP input) */
.otp-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin: 8px 0;
}
.otp-row input.otp { flex: 1; margin: 0; }
.open-otp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 0 12px;
  background: var(--eas-input-bg);
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius-sm);
  font-size: 22px;
  text-decoration: none;
  color: var(--eas-accent) !important;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.open-otp-btn:hover {
  background: var(--eas-card);
  border-color: var(--eas-accent);
  text-decoration: none !important;
}
.open-otp-btn:active { transform: scale(0.95); }

/* v1.3.0: prominent OTP-app launcher (profile, full-width) */
.open-otp-launcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 14px 0;
  padding: 14px 18px;
  background: var(--eas-input-bg);
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius-sm);
  text-decoration: none;
  color: var(--eas-accent) !important;
  font-weight: 600;
  font-size: 15px;
  transition: background 0.15s ease;
}
.open-otp-launcher:hover {
  background: var(--eas-card);
  border-color: var(--eas-accent);
  text-decoration: none !important;
}
.open-otp-launcher .icon { font-size: 22px; }

/* v1.3.0: <details>/<summary> accordion ("Docker-debugger style") */
.eas-card details {
  margin: 12px 0;
  border: 1px solid var(--eas-border);
  border-radius: var(--eas-radius-sm);
  background: var(--eas-input-bg);
  overflow: hidden;
}
.eas-card details > summary {
  cursor: pointer;
  padding: 12px 16px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  color: var(--eas-text);
  user-select: none;
  transition: background 0.12s ease;
}
.eas-card details > summary::-webkit-details-marker { display: none; }
.eas-card details > summary::after {
  content: "▸";
  color: var(--eas-muted);
  transition: transform 0.18s ease;
  font-size: 13px;
}
.eas-card details[open] > summary::after { transform: rotate(90deg); }
.eas-card details > summary:hover { background: rgba(255,255,255,0.02); }
.eas-card details[open] > summary {
  border-bottom: 1px solid var(--eas-border);
  background: rgba(255,255,255,0.02);
}
.eas-card details .body {
  padding: 14px 16px;
}
.eas-card details .summary-badge {
  font-family: var(--eas-mono);
  font-size: 12px;
  padding: 2px 8px;
  background: var(--eas-card);
  border: 1px solid var(--eas-border);
  border-radius: 999px;
  color: var(--eas-muted);
  font-weight: normal;
}

/* QR display inside profile details */
.qr-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.qr-display img {
  max-width: 240px;
  background: #fff;
  padding: 8px;
  border-radius: var(--eas-radius-sm);
}
.codes-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.codes-grid code {
  font-family: var(--eas-mono);
  background: var(--eas-card);
  border: 1px solid var(--eas-border);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  text-align: center;
  user-select: all;
}

/* v1.3.4: Mobile layout — on narrow viewports (phones), don't
   vertically-center the card. With portrait phones (2400×1080,
   aspect ratio ~22:9), centering leaves 700+px of empty black space
   above a ~600px login card, which looks broken even though it's
   "correct". Top-pin with breathing room is the standard pattern
   for phone-first auth flows.

   Above 600px (tablets, laptops, desktop) we keep the centered
   layout — it works fine there. */
@media (max-width: 600px) {
  body {
    align-items: flex-start;
    padding-top: 32px;
    padding-bottom: 32px;
  }
}
