/*
 * IAM 2.0 shared UI theme — single source of truth.
 *
 * Source: assets/ui/theme.css (this file).
 * Consumers vendor a synced copy at:
 *   services/iam-admin-service/internal/ui/theme.css   (served at GET /theme.css)
 *   internal/bootstrap/ui/theme.css                     (served at GET /theme.css)
 *   docs/ui-mocks/theme.css                             (linked from mocks)
 *
 * Run `make sync-theme` to propagate edits from this file to all copies.
 * Run `make verify-theme` to fail if any copy has drifted.
 */

/* ── Komm.ONE palette ─────────────────────────────────────────────────────── */
:root {
  --sapphire:   #2E4B98;
  --biscay:     #1C2E5D;
  --stone:      #0F0F0F;
  --white:      #FFFFFF;
  --prismarine: #249087;
  --anthracite: #484848;
  --grey:       #8B8B8C;
  --neutral:    #F5F6F5;
  --error:      #C0392B;
  --sunglow:    #FFCA31;

  /* Surfaces */
  --surface-card:     var(--white);
  --surface-card-alt: #FAFAFA;
  --border-soft:      #E6E7EC;
  --border-input:     #D6D8DE;

  /* Status tints */
  --tint-success-bg: #E9F4F3;
  --tint-success-fg: var(--prismarine);
  --tint-info-bg:    #EAEDF4;
  --tint-info-fg:    var(--sapphire);
  --tint-warn-bg:    #FFF7E0;
  --tint-warn-fg:    var(--anthracite);
  --tint-error-bg:   #FBECEA;
  --tint-error-fg:   var(--error);

  /* Type scale */
  --fs-xs:   11px;
  --fs-sm:   12px;
  --fs-base: 14px;
  --fs-md:   15px;
  --fs-lg:   18px;
  --fs-xl:   22px;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  24px;
  --space-6:  32px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;

  /* Shadow */
  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.06);
  --shadow-bar:  0 2px 4px rgba(0,0,0,.08);
}

/* ── Font ───────────────────────────────────────────────────────────────── */
@font-face {
  font-family: 'Source Sans 3';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('fonts/SourceSans3-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
                 U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122,
                 U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

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

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

body {
  font-family: 'Source Sans 3', system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", sans-serif;
  font-size: var(--fs-base);
  color: var(--stone);
  background: var(--neutral);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--sapphire); }
a:hover { color: var(--biscay); }

/* ── App header bar (thin, sapphire) ────────────────────────────────────── */
.app-header {
  background: var(--sapphire);
  color: var(--white);
  padding: 0 var(--space-5) 0 var(--space-3);
  height: 44px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-bar);
}
.app-header .brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  text-decoration: none;
  color: var(--white);
}
.app-header .brand-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.app-header .logo {
  font-weight: 700;
  letter-spacing: .02em;
  font-size: var(--fs-md);
}
/* Segmented control inside the header (e.g. mock scenario picker). */
.app-header .seg {
  display: inline-flex;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 2px;
  gap: 2px;
}
.app-header .seg button {
  font: inherit;
  font-size: var(--fs-xs);
  font-weight: 600;
  background: transparent;
  color: rgba(255,255,255,.7);
  border: 0;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: .02em;
}
.app-header .seg button:hover { color: var(--white); }
.app-header .seg button.active {
  background: var(--white);
  color: var(--sapphire);
}
.app-header .seg-sep {
  width: 1px;
  background: rgba(255,255,255,.18);
  margin: 4px 2px;
}
.app-header .env {
  font-size: var(--fs-sm);
  padding: 3px 8px;
  background: rgba(255,255,255,.16);
  border-radius: 12px;
  letter-spacing: .03em;
}
.app-header .spacer { flex: 1; }
.app-header a, .app-header .link {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: var(--fs-base);
}
.app-header a:hover { color: var(--white); }

/* Identity chip: avatar circle + username + sign-out link. */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-base);
  color: rgba(255,255,255,.9);
}
.user-chip .avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: var(--white);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: help;
}
.user-chip .user-name { font-weight: 600; }
.user-chip .source {
  font-size: var(--fs-xs);
  color: rgba(255,255,255,.55);
  margin-left: 4px;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.user-chip .sep {
  width: 1px;
  height: 16px;
  background: rgba(255,255,255,.22);
  margin: 0 var(--space-1);
}
.user-chip .signout {
  color: rgba(255,255,255,.85);
  text-decoration: none;
  font-size: var(--fs-base);
}
.user-chip .signout:hover { color: var(--white); }

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}
.card h1, .card h2, .card h3 { color: var(--biscay); }
.card h1 { font-size: var(--fs-xl); font-weight: 600; margin: 0 0 var(--space-2); }
.card h2 { font-size: var(--fs-lg); font-weight: 600; margin: var(--space-5) 0 var(--space-3); }
.card .sub { color: var(--grey); font-size: var(--fs-base); margin: 0 0 var(--space-5); }

/* ── Form controls ──────────────────────────────────────────────────────── */
label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--anthracite);
  margin: var(--space-4) 0 var(--space-1);
  letter-spacing: .02em;
}
input[type=text],
input[type=password],
input[type=email],
input[type=url],
input[type=number],
textarea,
select {
  width: 100%;
  padding: 10px 11px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--fs-base);
  background: var(--white);
  color: var(--stone);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--sapphire);
  box-shadow: 0 0 0 3px rgba(46,75,152,.18);
}
input::placeholder, textarea::placeholder { color: var(--grey); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: var(--fs-base);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
}
.btn:focus-visible {
  outline: 2px solid var(--sapphire);
  outline-offset: 2px;
}
.btn-block { width: 100%; }

.btn-primary { background: var(--sapphire); color: var(--white); }
.btn-primary:hover { background: var(--biscay); }
.btn-primary:disabled { background: var(--grey); cursor: not-allowed; }

.btn-ghost { background: transparent; color: var(--sapphire); border-color: var(--sapphire); }
.btn-ghost:hover { background: #EAEDF4; }

.btn-danger { background: var(--error); color: var(--white); }
.btn-danger:hover { background: #A93226; }
.btn-danger:disabled { background: var(--grey); cursor: not-allowed; }

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-3);
  color: var(--grey);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .12em;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-soft);
}

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
}
.alert-error { background: var(--tint-error-bg); color: var(--tint-error-fg); border-color: #F3CFCA; }
.alert-info  { background: var(--tint-info-bg);  color: var(--tint-info-fg);  border-color: #CFD6E8; }
.alert-warn  { background: var(--tint-warn-bg);  color: var(--tint-warn-fg);  border-color: #F3E2A8; }
.alert-ok    { background: var(--tint-success-bg); color: var(--tint-success-fg); border-color: #BCDFDA; }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; }
.badge-success { background: var(--tint-success-bg); color: var(--tint-success-fg); }
.badge-success .dot { background: var(--tint-success-fg); }
.badge-info    { background: var(--tint-info-bg);    color: var(--tint-info-fg); }
.badge-info    .dot { background: var(--tint-info-fg); }
.badge-warn    { background: var(--tint-warn-bg);    color: var(--tint-warn-fg); }
.badge-warn    .dot { background: var(--sunglow); }
.badge-error   { background: var(--tint-error-bg);   color: var(--tint-error-fg); }
.badge-error   .dot { background: var(--tint-error-fg); }
.badge-neutral { background: var(--neutral);         color: var(--grey); }
.badge-neutral .dot { background: var(--grey); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .55; transform: scale(1.15); }
}
.badge .dot.pulse { animation: pulse 1.2s ease-in-out infinite; }

/* ── Layout helpers ─────────────────────────────────────────────────────── */
.center-card {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}
.center-card .card { width: 100%; max-width: 380px; }

.muted { color: var(--grey); }
.small { font-size: var(--fs-sm); }
.spacer { flex: 1; }

/* Inline phase hint — used where an action used to live, signalling the
   next required step without offering a button (action is elsewhere). */
.phase-hint {
  display: inline-block;
  font-size: var(--fs-sm);
  font-weight: 500;
  font-style: italic;
  color: var(--grey);
}

/* Tree view — human-friendly alternative to raw JSON.
   Uses <details>/<summary> for native collapse with +/- toggle markers. */
.tree-view { font-size: var(--fs-base); color: var(--stone); }
.tree-row { display: flex; gap: 12px; padding: 3px 0 3px 22px; align-items: baseline; }
.tree-key {
  color: var(--anthracite);
  font-weight: 600;
  min-width: 200px;
  flex-shrink: 0;
}
.tree-key.tree-key-mono {
  font-family: 'SFMono-Regular', 'Consolas', 'Menlo', monospace;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--biscay);
}
.attr-map-header {
  display: flex;
  gap: 12px;
  padding: 4px 0 4px 22px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-soft);
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey);
}
.attr-map-header > span:first-child { min-width: 200px; }
.tree-val { color: var(--stone); word-break: break-all; }
.tree-val.null  { color: var(--grey); font-style: italic; }
.tree-val.bool  { color: var(--sapphire); font-weight: 600; }
.tree-val.num   { color: #A04A00; }
.tree-val.str   {
  font-family: 'SFMono-Regular', 'Consolas', 'Menlo', monospace;
  font-size: var(--fs-sm);
}
.tree-val.date  { color: var(--prismarine); }
/* Status-like values get a colored, semi-bold pill-less highlight. */
.tree-val.status-good { color: var(--prismarine); font-weight: 600; }
.tree-val.status-warn { color: #B58400;          font-weight: 600; }
.tree-val.status-bad  { color: var(--error);     font-weight: 600; }
.status-good  { color: var(--prismarine); font-weight: 600; }
.status-warn  { color: #B58400;          font-weight: 600; }
.status-bad   { color: var(--error);     font-weight: 600; }
.status-muted { color: var(--grey);      font-weight: 600; }
.tree-nest {
  border-left: 2px solid var(--border-soft);
  margin-left: 8px;
  padding-left: 12px;
  margin-top: 2px;
  margin-bottom: 4px;
}
/* Collapsible group (object / array item). */
.tree-view details.tree-group, .tree-view details.tree-item {
  margin: 1px 0;
}
.tree-view summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 3px 0;
}
.tree-view summary::-webkit-details-marker { display: none; }
.tree-view .tree-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border: 1px solid var(--border-input);
  border-radius: 3px;
  background: var(--surface-card);
  color: var(--grey);
  font-weight: 700;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
  user-select: none;
  transition: color .12s, border-color .12s;
}
.tree-view details > summary .tree-caret::before { content: '+'; }
.tree-view details[open] > summary .tree-caret::before { content: '−'; }
.tree-view summary:hover .tree-caret {
  color: var(--sapphire);
  border-color: var(--sapphire);
}
.tree-view .tree-group > summary .tree-key { color: var(--biscay); }
.tree-view .tree-summary-text {
  color: var(--biscay);
  font-weight: 600;
}
.tree-view .count {
  color: var(--grey);
  font-weight: 400;
  font-size: var(--fs-sm);
}
.tree-view .tree-summary-meta {
  color: var(--grey);
  font-weight: 400;
  font-size: var(--fs-sm);
  margin-left: 6px;
}
.view-toggle {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--space-2);
  font-size: var(--fs-sm);
}
.view-toggle .seg-inline {
  display: inline-flex;
  background: var(--surface-card-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 2px;
}
.view-toggle .seg-inline button {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  background: transparent;
  color: var(--grey);
  border: 0;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: .02em;
}
.view-toggle .seg-inline button:hover { color: var(--anthracite); }
.view-toggle .seg-inline button.active {
  background: var(--white);
  color: var(--sapphire);
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}

