/* ============================================================
   CPlugin Identity — Design system
   Token names mirror @nuxt/ui-pro v3 (primary: blue, neutral: zinc).
   Spec: docs/superpowers/specs/2026-05-10-identity-ui-redesign-design.md
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Roboto+Flex:wght@400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

:root {
  /* Surfaces — light */
  --ui-bg:            #ffffff;
  --ui-bg-muted:      #fafafa;            /* zinc-50  — input fill, code chip on bg */
  --ui-bg-elevated:   #f4f4f5;            /* zinc-100 — brand rail */
  --ui-bg-accented:   #e4e4e7;            /* zinc-200 — code chips on rail */

  /* Text — light */
  --ui-text:               #3f3f46;
  --ui-text-muted:         #71717a;
  --ui-text-toned:         #52525b;
  --ui-text-dimmed:        #a1a1aa;
  --ui-text-highlighted:   #18181b;

  /* Borders — light */
  --ui-border:           #e4e4e7;
  --ui-border-accented:  #d4d4d8;

  /* Brand — light */
  --ui-primary:        #2563eb;            /* blue-600 */
  --ui-primary-hover:  #1d4ed8;            /* blue-700 */
  --ui-primary-fg:     #ffffff;
  --ui-primary-soft:   rgba(37,99,235,0.10);
  --ui-ring:           rgba(37,99,235,0.30);

  /* Semantic — light */
  --ui-success: #00C16A;
  --ui-warn:    #d97706;
  --ui-danger:  #dc2626;

  --ui-radius:    8px;
  --ui-radius-lg: 12px;

  --ui-font-sans: 'Roboto Flex', system-ui, -apple-system, 'Segoe UI Variable', sans-serif;
  --ui-font-mono: 'Roboto Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ui-bg:            #18181b;            /* zinc-900 */
    --ui-bg-muted:      #27272a;            /* zinc-800 — input fill */
    --ui-bg-elevated:   #27272a;            /* zinc-800 — brand rail */
    --ui-bg-accented:   #3f3f46;            /* zinc-700 — code chips */

    --ui-text:               #e4e4e7;
    --ui-text-muted:         #a1a1aa;
    --ui-text-toned:         #d4d4d8;
    --ui-text-dimmed:        #71717a;
    --ui-text-highlighted:   #fafafa;

    --ui-border:           #3f3f46;
    --ui-border-accented:  #52525b;

    --ui-primary:        #60a5fa;          /* blue-400 */
    --ui-primary-hover:  #3b82f6;          /* blue-500 */
    --ui-primary-fg:     #0a1226;
    --ui-primary-soft:   rgba(96,165,250,0.14);
    --ui-ring:           rgba(96,165,250,0.40);

    --ui-success: #00DC82;
    --ui-warn:    #f59e0b;
    --ui-danger:  #f87171;
  }
}

[data-theme="dark"] {
  --ui-bg:            #18181b;
  --ui-bg-muted:      #27272a;
  --ui-bg-elevated:   #27272a;
  --ui-bg-accented:   #3f3f46;
  --ui-text:               #e4e4e7;
  --ui-text-muted:         #a1a1aa;
  --ui-text-toned:         #d4d4d8;
  --ui-text-dimmed:        #71717a;
  --ui-text-highlighted:   #fafafa;
  --ui-border:           #3f3f46;
  --ui-border-accented:  #52525b;
  --ui-primary:        #60a5fa;
  --ui-primary-hover:  #3b82f6;
  --ui-primary-fg:     #0a1226;
  --ui-primary-soft:   rgba(96,165,250,0.14);
  --ui-ring:           rgba(96,165,250,0.40);
  --ui-success: #00DC82;
  --ui-warn:    #f59e0b;
  --ui-danger:  #f87171;
}

/* ---------- Reset + base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ui-bg);
  color: var(--ui-text);
  font-family: var(--ui-font-sans);
  font-feature-settings: 'cv11';
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

a { color: var(--ui-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, samp, pre { font-family: var(--ui-font-mono); }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }

@keyframes id-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Auth shell (split: brand rail + canvas) ---------- */
.auth-shell {
  display: grid;
  /* Rail: at least 240px (mobile-ish wide), at most 340px (so on big screens it doesn't dwarf content). */
  grid-template-columns: minmax(240px, 340px) 1fr;
  min-height: 100vh;
}
@media (max-width: 767px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-shell .brand-rail { min-height: auto; padding: 16px 20px; flex-direction: row; align-items: center; gap: 12px; border-right: 0; border-bottom: 1px solid var(--ui-border); }
  .auth-shell .brand-rail__tag, .auth-shell .brand-rail__pills, .auth-shell .brand-rail__foot { display: none; }
}

.brand-rail {
  background: var(--ui-bg-elevated);
  border-right: 1px solid var(--ui-border);
  padding: 32px 26px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100vh;
}
.brand-rail__mark { display: flex; align-items: center; gap: 10px; color: var(--ui-text-highlighted); }
.brand-rail__name { display: flex; flex-direction: column; line-height: 1.1; }
.brand-rail__name b { font-weight: 600; font-size: 14px; color: var(--ui-text-highlighted); }
.brand-rail__name span { font-size: 11px; color: var(--ui-text-muted); }
.brand-rail__tag {
  font-size: 12.5px;
  color: var(--ui-text);
  max-width: 230px;
  line-height: 1.55;
  margin: 0;
}
.brand-rail__pills { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 7px; }
.brand-rail__pills li {
  font-size: 11.5px;
  color: var(--ui-text-muted);
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px 8px;
  line-height: 1.5;
}
.brand-rail__pills li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ui-primary);
  flex-shrink: 0;
  margin-top: 7px;
}
.brand-rail__pills code {
  font-family: var(--ui-font-mono);
  font-size: 11px;
  color: var(--ui-text-highlighted);
  background: var(--ui-bg-accented);
  padding: 1px 6px;
  border-radius: 4px;
}
.brand-rail__foot {
  margin-top: auto;
  font-family: var(--ui-font-mono);
  font-size: 10.5px;
  color: var(--ui-text-dimmed);
  line-height: 1.5;
}
.brand-rail__foot strong { color: var(--ui-text-muted); font-weight: 400; display: block; }

.auth-canvas {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 32px;
  background: var(--ui-bg);
}
/* Top-right floating header for authenticated users: cross-product nav + user menu.
   Lives outside the centered flex flow so it doesn't squeeze the form-card. */
.auth-header {
  position: absolute;
  top: 16px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 10;
}
@media (max-width: 767px) {
  .auth-header { position: static; padding: 12px 16px; justify-content: flex-end; border-bottom: 1px solid var(--ui-border); }
}

/* ---------- Form card ---------- */
.form-card { width: 100%; max-width: 320px; animation: id-fade-in 220ms ease both; }
.form-card--wide { max-width: 460px; }
.form-card--xl   { max-width: 600px; }

.form-card__title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--ui-text-highlighted);
  letter-spacing: -0.01em;
}
.form-card__sub {
  font-size: 13px;
  color: var(--ui-text-muted);
  margin: 0 0 22px;
}
.form-card__sub code {
  font-family: var(--ui-font-mono);
  font-size: 12px;
  color: var(--ui-text-highlighted);
  background: var(--ui-bg-muted);
  padding: 1px 6px;
  border-radius: 4px;
}
.form-card__desc {
  font-size: 13px;
  color: var(--ui-text);
  line-height: 1.6;
  margin-bottom: 18px;
}
.form-card__foot {
  font-size: 12px;
  color: var(--ui-text-muted);
  margin-top: 18px;
  text-align: center;
}
.form-card__meta {
  font-family: var(--ui-font-mono);
  font-size: 10.5px;
  color: var(--ui-text-muted);
  margin-top: 18px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

/* ---------- Field ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field__label {
  font-size: 12px;
  color: var(--ui-text-highlighted);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.field__label a { color: var(--ui-primary); text-decoration: none; font-weight: 400; font-size: 12px; }
.field__label a:hover { text-decoration: underline; }
.field__input {
  /* width:100% so the input fills its wrapper (.field or .input-affix) instead
     of falling back to the user-agent default size — otherwise wrapped inputs
     (e.g. password+reveal) render narrower than unwrapped ones. */
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--ui-border-accented);
  border-radius: var(--ui-radius);
  background: var(--ui-bg-muted);
  color: var(--ui-text-highlighted);
  font: inherit;
  font-size: 13px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms, background 120ms;
}
.field__input:focus {
  border-color: var(--ui-primary);
  box-shadow: 0 0 0 3px var(--ui-ring);
  background: var(--ui-bg);
}
.field__input::placeholder { color: var(--ui-text-dimmed); }
.field__error { font-size: 12px; color: var(--ui-danger); margin-top: 2px; }
.field__hint  { font-size: 11px; color: var(--ui-text-muted); margin-top: 2px; }
.field__hint--loose { margin-top: 14px; }
.field__label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.field__label-row .field__label { margin-bottom: 0; }
.field__label-link { color: var(--ui-primary); text-decoration: none; font-weight: 400; font-size: 12px; }
.field__label-link:hover { text-decoration: underline; }

.input-affix { position: relative; }
.input-affix .field__input { padding-right: 36px; }
.input-affix__btn {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  color: var(--ui-text-muted);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.input-affix__btn:hover { background: var(--ui-bg-accented); color: var(--ui-text-highlighted); }
.input-affix__btn:focus-visible { outline: 2px solid var(--ui-primary); outline-offset: 1px; }

/* ---------- Check / radio ---------- */
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--ui-text-muted);
  margin: 4px 0 16px;
}
.check input { accent-color: var(--ui-primary); width: 16px; height: 16px; }
.check--start { align-items: flex-start; }
.check--start input { margin-top: 2px; }

/* ---------- Button ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--ui-radius);
  font-weight: 500;
  font-size: 13px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ui-text-highlighted);
  text-decoration: none;
  transition: background-color 120ms, border-color 120ms, color 120ms, opacity 120ms;
}
.btn--primary { background: var(--ui-primary); color: var(--ui-primary-fg); width: 100%; }
.btn--primary:hover { background: var(--ui-primary-hover); }
.btn--outline { border-color: var(--ui-border-accented); color: var(--ui-text-highlighted); }
.btn--outline:hover { background: var(--ui-bg-accented); }
.btn--ghost   { color: var(--ui-text-muted); }
.btn--ghost:hover { color: var(--ui-text-highlighted); background: var(--ui-bg-accented); }
.btn--block   { width: 100%; }
.btn--sm      { height: 28px; padding: 0 8px; font-size: 11px; }
.btn-stack    { display: flex; flex-direction: column; gap: 8px; }
/* Busy state: applied while waiting for navigation/submit. Blocks repeat clicks
   (pointer-events: none + cursor: progress) and shows a small spinner glued to
   the right side of the label. Text is NOT replaced — that would erase inline
   SVG icons on .btn--primary etc. */
.btn[aria-busy="true"] {
  opacity: 0.7;
  pointer-events: none;
  cursor: progress;
}
.btn[aria-busy="true"]::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 6px;
  border-radius: 50%;
  border: 2px solid currentColor;
  border-top-color: transparent;
  animation: ui-spin 0.7s linear infinite;
  flex: 0 0 auto;
}
@keyframes ui-spin { to { transform: rotate(360deg); } }

/* ---------- Alert / validation ---------- */
.alert {
  padding: 10px 12px;
  border-radius: var(--ui-radius);
  border: 1px solid;
  font-size: 12px;
  margin-bottom: 14px;
  background: transparent;
}
.alert--danger {
  border-color: var(--ui-danger);
  color: var(--ui-danger);
  background: rgba(220,38,38,0.06);
}
.alert--danger ul { margin: 4px 0 0; padding-left: 18px; }
.alert--success {
  border-color: var(--ui-success);
  color: var(--ui-success);
  background: rgba(0,193,106,0.07);
}

/* ---------- Consent: client header ---------- */
.client-row { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.client-row__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--ui-radius);
  background: var(--ui-primary-soft);
  color: var(--ui-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.client-row__logo img { width: 100%; height: 100%; border-radius: var(--ui-radius); object-fit: cover; }
.client-row__name { font-weight: 600; color: var(--ui-text-highlighted); font-size: 15px; line-height: 1.2; }
.client-row__sub  { font-size: 12px; color: var(--ui-text-muted); }
.client-row__sub code { font-family: var(--ui-font-mono); font-size: 11px; }

.consent-intro { font-size: 13px; color: var(--ui-text); margin: 0 0 14px; }

/* ---------- Consent: scope groups ---------- */
.scope-group { margin-bottom: 18px; }
.scope-group__title {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
  font-weight: 600;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.scope {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  margin-bottom: 6px;
  background: var(--ui-bg);
  cursor: pointer;
}
.scope:hover { border-color: var(--ui-border-accented); }
.scope input[type="checkbox"] { accent-color: var(--ui-primary); width: 16px; height: 16px; flex-shrink: 0; }
.scope__body { flex: 1; min-width: 0; }
.scope__name { font-family: var(--ui-font-mono); font-size: 12px; color: var(--ui-text-highlighted); display: block; }
.scope__desc { font-size: 11.5px; color: var(--ui-text-muted); display: block; }
.scope__tag {
  font-family: var(--ui-font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.scope__tag--req  { background: var(--ui-bg-accented); color: var(--ui-text-muted); }
.scope__tag--warn { background: rgba(245,158,11,0.15); color: var(--ui-warn); }

/* ---------- Grants: grant card variant ---------- */
.scope--grant {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 16px;
  cursor: default;
}
.scope--grant .client-row__logo { width: 48px; height: 48px; }
.scope--grant .scope__body { flex: 1; min-width: 200px; }
.scope--grant .scope__name { font-size: 14px; color: var(--ui-text-highlighted); }
.scope--grant .grant-meta { margin-top: 6px; font-family: var(--ui-font-mono); font-size: 11px; color: var(--ui-text-muted); word-break: break-word; }
.scope--grant .grant-revoke { margin-left: auto; }

/* Logo / name made into a link when Client.ClientUri is present. The hover affordance
   is subtle (border + text colour shift) — this is a settings page, not a marketing CTA. */
.client-row__logo--link { text-decoration: none; transition: border-color 120ms, transform 120ms; border: 1px solid transparent; }
.client-row__logo--link:hover { border-color: var(--ui-border-accented); }
.scope__name--link {
  text-decoration: none;
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.scope__name--link:hover { color: var(--ui-primary); }
.scope__name--link .ext-icon { opacity: 0.55; transition: opacity 120ms; }
.scope__name--link:hover .ext-icon { opacity: 1; }

/* ---------- Action row ---------- */
.actions { display: flex; gap: 8px; margin-top: 16px; }
.actions .btn { width: auto; padding: 0 18px; }
.actions .btn--primary { flex: 1; }

/* ---------- State icon (success/error pages) ---------- */
.state-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.state-icon--ok  { background: rgba(0,193,106,0.12); color: var(--ui-success); }
.state-icon--err { background: rgba(220,38,38,0.10); color: var(--ui-danger); }

/* ---------- Centered card modifier ---------- */
.form-card--center { text-align: center; }
.form-card--center .state-icon { margin: 0 auto 14px; }

/* ---------- 2FA code input ---------- */
.field__input--code {
  font-family: var(--ui-font-mono);
  letter-spacing: 0.4em;
  font-size: 18px;
  text-align: center;
}

/* ---------- Sign-out iframe (hidden, used for OIDC front-channel logout) ---------- */
.signout-iframe { display: none; width: 0; height: 0; }

/* ---------- Diagnostics + Grants tables ---------- */
.kv-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kv-table td { padding: 8px 12px; border-bottom: 1px solid var(--ui-border); vertical-align: top; }
.kv-table td:first-child {
  font-family: var(--ui-font-mono);
  font-size: 11.5px;
  color: var(--ui-text-muted);
  width: 30%;
}
.kv-table td:last-child  { font-family: var(--ui-font-mono); font-size: 11.5px; color: var(--ui-text-highlighted); word-break: break-all; }
.kv-table__section {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ui-text-muted);
  font-weight: 600;
  margin: 22px 0 8px;
}

/* ---------- Code error block ---------- */
.error-block {
  font-family: var(--ui-font-mono);
  font-size: 11.5px;
  background: var(--ui-bg-muted);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-radius);
  padding: 12px 14px;
  margin: 14px 0;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ui-text);
}

/* ---------- Cross-product nav slot (only on authenticated pages) ---------- */
.shared-nav { /* injected by the cplugin-saas-static AJAX call */ }

/* ---------- Top user menu (compact) ---------- */
.user-menu { display: flex; align-items: center; gap: 10px; padding: 10px 16px; }
.user-menu__name { font-size: 12px; color: var(--ui-text); }
.user-menu__btn  { font-size: 12px; color: var(--ui-text-muted); }
.user-menu__btn:hover { color: var(--ui-text-highlighted); }
