/* ============================================================
   ThriveOnDev — Keycloak login theme, layout B
   Rules and values: design/system/15-auth.md (values from
   design/system/14-workspace.md, "Values used in the reference").
   Figma: S4ZQq5jNQXRoIRZ9gv03hT, page "Auth · Keycloak".
   Dark only: the page ignores prefers-color-scheme.
   ============================================================ */

@font-face {
  font-family: "Geist";
  src: url("../fonts/geist-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

@font-face {
  font-family: "Geist Mono";
  src: url("../fonts/geist-mono-latin-wght-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: dark;

  --canvas: #0b0d11;
  --panel: #0e1015;
  --track: #14171e;
  --edge: #252933;
  --surface: #12141c;

  --text: #eceef2;
  --text-secondary: #a2a9b8;
  /* Muted is below AA for 14 px text on the canvas: use it only for
     icons, placeholders and borders-like marks, never for text. */
  --text-muted: #6a7282;

  --primary: #f2b544;
  --on-primary: #201500;
  --focus: #5e6ad2;
  --error: #eb5757;
  --success: #58c99e;

  --ball-todo: #c4c8d2;
  --ball-progress: #f2c94c;
  --ball-review: #9bd45e;
  --ball-human: #f2994a;
  --ball-done: #5e6ad2;

  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --control: 48px;
  --radius: 12px;
  --panel-width: clamp(400px, 44vw, 640px);
}

/* --- Reset ------------------------------------------------------ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
  background: var(--canvas);
}

body {
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img,
svg {
  display: block;
}

a {
  color: inherit;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* --- Page layout ---------------------------------------------- */
.page {
  display: grid;
  grid-template-columns: var(--panel-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}

.panel {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  height: 100vh;
  height: 100dvh;
  padding: 40px;
  background: var(--panel);
}

.logo {
  display: inline-flex;
  align-self: flex-start;
  text-decoration: none;
}

/* The logo SVG has wide built-in padding; 44 px gives the 22 px
   wordmark used in the workspace sidebar. */
.logo img {
  width: auto;
  height: 44px;
  margin: -6px 0 -6px -10px;
}

.panel-statement {
  display: flex;
  flex-direction: column;
  gap: 32px;
  max-width: 480px;
}

.panel-title {
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.panel-text {
  color: var(--text-secondary);
}

.track {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  height: 56px;
  padding: 0 24px;
  border: 1px solid var(--edge);
  border-radius: 28px;
  background: var(--track);
}

.ball {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.ball-todo { border: 1.5px solid var(--ball-todo); }
.ball-progress { background: var(--ball-progress); }
.ball-review { background: var(--ball-review); }
.ball-human { background: var(--ball-human); }
.ball-done { background: var(--ball-done); }

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  color: var(--text-secondary);
  font-size: 14px;
}

.footer a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer a:hover {
  color: var(--text-secondary);
}

.form-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 40px;
}

.logo-mobile,
.footer-mobile {
  display: none;
}

.auth-card {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 100%;
  max-width: 400px;
}

/* --- Heading ---------------------------------------------------- */
/* Base Keycloak templates put plain text into the header section;
   it renders as a title. */
.auth-heading {
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.auth-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.auth-title {
  font-size: 28px;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
}

.auth-subtitle strong {
  color: var(--text);
  font-weight: 500;
}

.status-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  border: 1px solid var(--edge);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
}

.status-mark svg {
  width: 24px;
  height: 24px;
}

.status-mark-error { color: var(--error); }
.status-mark-success { color: var(--success); }

.identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  margin-bottom: 16px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 16px 8px 12px;
  border: 1px solid var(--edge);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
}

.chip svg {
  flex: none;
  width: 16px;
  height: 16px;
}

.chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Forms ------------------------------------------------------ */
.auth-form,
.form-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label,
:where(.auth-card label) {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
}

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

.form-required {
  margin-left: 2px;
  color: var(--text-muted);
}

.input-wrapper {
  position: relative;
}

.form-input,
:where(.auth-card :is(input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], input:not([type]), select, textarea)) {
  width: 100%;
  height: var(--control);
  padding: 0 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

:where(.auth-card textarea) {
  height: auto;
  min-height: 96px;
  padding: 12px 16px;
}

.form-input::placeholder,
:where(.auth-card input::placeholder) {
  color: var(--text-muted);
}

.form-input:focus,
:where(.auth-card :is(input, select, textarea)):focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 1px var(--focus);
  outline: none;
}

.form-input:disabled,
.form-input[readonly] {
  color: var(--text-secondary);
  cursor: not-allowed;
}

.form-input.input-error,
.form-input[aria-invalid="true"],
.has-error .form-input {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}

.input-code {
  font-family: var(--font-mono);
  font-size: 20px;
  letter-spacing: 0.2em;
}

.field-error {
  color: var(--error);
  font-size: 14px;
}

.field-hint {
  color: var(--text-secondary);
  font-size: 14px;
}

:where(.auth-card input[type="checkbox"]),
:where(.auth-card input[type="radio"]) {
  flex: none;
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.checkbox,
:where(.auth-card :is(.checkbox, .form-check, #kc-form-options)) label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 400;
}

/* --- Buttons ---------------------------------------------------- */
.btn,
.btn-primary,
.btn-secondary,
.social-btn,
:where(.auth-card :is(button, input[type="submit"], input[type="button"])) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: var(--control);
  padding: 0 24px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms ease, background-color 120ms ease, opacity 120ms ease;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary:hover,
.social-btn:hover,
:where(.auth-card :is(button, input[type="submit"], input[type="button"])):not(.btn-primary):hover {
  border-color: var(--text-secondary);
}

:where(.auth-card :is(button, input)):disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Providers -------------------------------------------------- */
.social-section {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.social-buttons {
  order: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.separator {
  order: 2;
  display: flex;
  align-items: center;
  gap: 16px;
}

.separator-line {
  flex: 1;
  height: 1px;
  background: var(--edge);
}

.separator-text {
  color: var(--text-secondary);
  font-size: 14px;
}

.social-icon {
  flex: none;
  width: 20px;
  height: 20px;
}

.social-icon-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: var(--edge);
  font-size: 12px;
}

/* --- Text and links --------------------------------------------- */
.auth-info-text,
.auth-footer-text,
.text-row,
.auth-terms-text {
  color: var(--text-secondary);
  font-size: 14px;
}

.text-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.link,
.auth-link,
.auth-link-bold,
.forgot-password-link,
:where(.auth-card a:not([class])) {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link:hover,
.auth-link:hover,
.auth-link-bold:hover,
.forgot-password-link:hover,
:where(.auth-card a:not([class]):hover) {
  color: var(--text);
}

.legal-links {
  color: var(--text-secondary);
  font-size: 14px;
}

.detail {
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 14px;
  overflow-wrap: anywhere;
}

/* --- Messages --------------------------------------------------- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.alert-dot {
  flex: none;
  width: 8px;
  height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--focus);
}

.alert-success .alert-dot { background: var(--success); }
.alert-warning .alert-dot { background: var(--primary); }
.alert-error { border-color: var(--error); }
.alert-error .alert-dot { background: var(--error); }

/* --- Lists (organizations, consent, authenticators) ------------- */
.list,
.authenticator-list {
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  list-style: none;
}

.list > li + li,
.authenticator-list > * + * {
  border-top: 1px solid var(--edge);
}

.list-button,
.authenticator-option {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  width: 100%;
  min-height: 0;
  padding: 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.list-button:hover,
.authenticator-option:hover {
  background: var(--track);
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
}

.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--edge);
  font-size: 14px;
  font-weight: 500;
}

.list-text,
.authenticator-option-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.list-title,
.authenticator-option-title {
  font-size: 16px;
  font-weight: 500;
}

.list-sub,
.authenticator-option-desc {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
}

.list-chevron,
.authenticator-option-arrow {
  flex: none;
  width: 20px;
  height: 20px;
  margin-left: auto;
  color: var(--text-muted);
}

.list-check {
  flex: none;
  width: 20px;
  height: 20px;
  color: var(--success);
}

/* --- Two-factor ------------------------------------------------- */
.totp-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

.totp-step {
  padding-left: 4px;
}

.totp-code {
  display: flex;
  align-items: center;
  gap: 24px;
}

.totp-qr {
  flex: none;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--text);
}

.totp-qr img {
  width: 136px;
  height: 136px;
  image-rendering: pixelated;
}

.totp-manual {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.totp-secret {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

/* Recovery codes and other base pages */
:where(.auth-card :is(#kc-recovery-codes-list, ol, ul)):not(.list):not(.totp-steps):not(.authenticator-list) {
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: 14px;
}

#kc-recovery-codes-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 32px;
  padding: 24px 24px 24px 48px !important;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text) !important;
  font-family: var(--font-mono);
}

:where(.auth-card :is(h2, h3)) {
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
}

:where(.auth-card p) {
  font-size: inherit;
}

.auth-terms-text {
  max-height: 240px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
}

[hidden] {
  display: none !important;
}

/* --- Mobile: no panel ------------------------------------------- */
@media (max-width: 1023px) {
  .page {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel {
    display: none;
  }

  .form-side {
    justify-content: flex-start;
    align-items: stretch;
    gap: 40px;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 24px;
  }

  .logo-mobile {
    display: inline-flex;
  }

  .auth-card {
    max-width: 400px;
    margin: 0 auto;
  }

  .footer-mobile {
    display: flex;
    margin-top: auto;
  }

  #kc-recovery-codes-list {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 479px) {
  .totp-code {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
