/* ============================================================================
   fuse-seam design-system tokens (subset) — inlined so these approval frames are
   self-contained / portable. Mirrors design-system/tokens/*.css.

   THIS FILE IS THE TOKEN-DEFINITION LAYER. Per design-system-conformance, raw
   color / spacing / type values live ONLY here (the DS/`tokens` carve-out). Every
   frame HTML file references these via var(--…) and carries NO raw values.

   White-label mechanism (FF-EPIC-13):
     - THEME tokens (light/dark surfaces) are keyed by [data-theme].
     - PORTAL BRANDING tokens (accent/logo/name) are a token OVERRIDE LAYER keyed
       by [data-portal]. A portal's branding.accent is applied by re-pointing the
       semantic --accent-* tokens at that portal's brand token — layered OVER the
       theme, never a raw hex in feature code. In production PortalThemeOverride
       injects `style="--accent-color: …"` at boot from GET /api/v1/portal/context;
       here the same override is expressed statically as a [data-portal] token block
       so the reskin is demonstrable and diffable.
   ============================================================================ */

:root {
  /* ---- fuse-seam brand palette (root FuzeFront default) ---- */
  --indigo-500: #6e5cff;
  --indigo-600: #5a48e6;
  --cyan-400: #29d3e6;

  /* ---- per-portal brand palette (would come from portals.branding jsonb) ----
     Defined in the token layer; frames never inline these hex values. */
  --corpabc-accent:        #2f6df6;   /* CorpABC corporate blue  */
  --corpabc-accent-hover:  #245bd6;
  --corpabc-accent-2:      #17b0a0;   /* CorpABC teal            */
  --corpabc-accent-soft:   rgba(47, 109, 246, 0.14);

  --root-accent:           var(--indigo-500);
  --root-accent-hover:     var(--indigo-600);
  --root-accent-2:         var(--cyan-400);
  --root-accent-soft:      rgba(110, 92, 255, 0.14);

  /* ---- semantic accent tokens (DEFAULT = root FuzeFront) ----
     [data-portal="…"] below re-points these. Feature code only ever reads these. */
  --accent-color: var(--root-accent);
  --accent-hover: var(--root-accent-hover);
  --accent-2:     var(--root-accent-2);
  --accent-soft:  var(--root-accent-soft);
  --seam: linear-gradient(90deg, var(--accent-color) 0%, var(--accent-2) 100%);

  /* ---- semantic status ---- */
  --success-color: #34d399;
  --warning-color: #f5b950;
  --error-color:   #f3697f;
  --success-soft:  rgba(52, 211, 153, 0.14);
  --warning-soft:  rgba(245, 185, 80, 0.14);
  --error-soft:    rgba(243, 105, 127, 0.14);

  /* ---- type ---- */
  --font-display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --font-sans: "Inter", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;
  --text-3xl: 34px;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --tracking-wide: 0.04em;
  --tracking-display: -0.01em;

  /* ---- spacing / radii ---- */
  --space-1: 4px;  --space-2: 8px;  --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-7: 28px; --space-8: 32px;
  --space-10: 40px; --space-12: 48px; --space-16: 64px;
  --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 20px;
  --radius-pill: 999px;

  /* ---- motion / layout ---- */
  --top-bar-height: 60px;
  --side-panel-width: 240px;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --duration-fast: 120ms;
  --duration-base: 200ms;
}

/* ============================================================================
   THEME LAYER — surfaces/text by light|dark. Default (no attr) = dark.
   Branding (accent) layers OVER whichever theme is active.
   ============================================================================ */
:root,
[data-theme="dark"] {
  --bg-primary:     #0f131c;
  --bg-secondary:   #11161f;
  --bg-tertiary:    #141a26;
  --bg-quaternary:  #1b2230;
  --border-color:   #232b3a;
  --border-strong:  #313b4d;
  --text-primary:   #e7ebf2;
  --text-secondary: #aab3c2;
  --text-tertiary:  #6b7585;
  --on-accent:      #0b0e15;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 6px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
  --skeleton: linear-gradient(90deg, #171d2a 25%, #1e2636 37%, #171d2a 63%);
}

[data-theme="light"] {
  --bg-primary:     #f6f8fb;
  --bg-secondary:   #ffffff;
  --bg-tertiary:    #ffffff;
  --bg-quaternary:  #eef2f7;
  --border-color:   #e2e8f0;
  --border-strong:  #cbd5e1;
  --text-primary:   #16202e;
  --text-secondary: #47546a;
  --text-tertiary:  #7a879b;
  --on-accent:      #ffffff;
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.06);
  --shadow-md: 0 6px 20px rgba(16,24,40,0.10);
  --shadow-lg: 0 16px 48px rgba(16,24,40,0.16);
  --skeleton: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
}

/* ============================================================================
   PORTAL BRANDING OVERRIDE LAYER — the white-label seam.
   Re-points the semantic --accent-* tokens at a portal's brand palette. This is
   the ONLY thing that changes between "root FuzeFront" and a tenant reskin — the
   shell markup is identical. In production these values arrive from
   branding.accent (GET /api/v1/portal/context) via a scoped CSS-var override.
   ============================================================================ */
[data-portal="root"] {
  --accent-color: var(--root-accent);
  --accent-hover: var(--root-accent-hover);
  --accent-2:     var(--root-accent-2);
  --accent-soft:  var(--root-accent-soft);
}
[data-portal="corpabc"] {
  --accent-color: var(--corpabc-accent);
  --accent-hover: var(--corpabc-accent-hover);
  --accent-2:     var(--corpabc-accent-2);
  --accent-soft:  var(--corpabc-accent-soft);
}

/* ============================================================================
   BASE ELEMENTS
   ============================================================================ */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}
.mono { font-family: var(--font-mono); }
a { color: var(--accent-color); }

/* ---- portal brand lockup (logo + name), shared across shell + login ---- */
.brand-lockup { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.brand-glyph {
  width: 30px; height: 30px; flex: none; border-radius: var(--radius-md);
  display: grid; place-items: center; color: var(--on-accent);
  font-family: var(--font-display); font-weight: var(--weight-bold); font-size: var(--text-md);
  background: var(--accent-color);
}
.brand-glyph.seam { background: var(--seam); }
.brand-name {
  font-family: var(--font-display); font-weight: var(--weight-semibold);
  font-size: var(--text-lg); letter-spacing: var(--tracking-display);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- shared portal-shell chrome ---- */
.shell { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  height: var(--top-bar-height); flex: none;
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-6);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  position: relative;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--seam); opacity: 0.8;
}
.topbar .spacer { flex: 1; }
.search {
  flex: 0 1 320px; display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-pill);
  background: var(--bg-primary); border: 1px solid var(--border-color);
  color: var(--text-tertiary); font-size: var(--text-sm);
}
.icon-btn {
  width: 34px; height: 34px; border-radius: var(--radius-md);
  display: grid; place-items: center; cursor: pointer;
  background: var(--bg-quaternary); border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.avatar {
  width: 32px; height: 32px; border-radius: var(--radius-pill);
  background: var(--accent-color); display: grid; place-items: center;
  font-weight: var(--weight-semibold); font-size: var(--text-sm); color: var(--on-accent);
}

.body { flex: 1; display: flex; min-height: 0; }
.side {
  width: var(--side-panel-width); flex: none;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: var(--space-4) var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-1);
  overflow-y: auto;
}
.side .section-label {
  font-family: var(--font-mono); font-size: var(--text-2xs);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--text-tertiary); margin: var(--space-4) var(--space-2) var(--space-2);
}
.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: var(--text-md); cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: var(--bg-quaternary); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-soft); color: var(--text-primary);
  box-shadow: inset 2px 0 0 var(--accent-color);
}
.nav-item .ico { width: 18px; text-align: center; }

.content { flex: 1; overflow: auto; padding: var(--space-8); min-width: 0; }
.page-title {
  font-family: var(--font-display); font-size: var(--text-2xl);
  letter-spacing: var(--tracking-display); margin: 0 0 var(--space-2);
}
.page-sub { color: var(--text-secondary); margin: 0 0 var(--space-6); }

/* ---- app grid ---- */
.app-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-5);
}
.app-card {
  background: var(--bg-tertiary); border: 1px solid var(--border-color);
  border-radius: var(--radius-lg); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-3); cursor: pointer;
  transition: transform var(--duration-base) var(--ease-standard), border-color var(--duration-base);
}
.app-card:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.app-card .app-ico {
  width: 42px; height: 42px; border-radius: var(--radius-md);
  display: grid; place-items: center; font-size: 22px;
  background: var(--accent-soft); border: 1px solid var(--border-color);
}
.app-card .app-name { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.app-card .app-desc { color: var(--text-tertiary); font-size: var(--text-sm); margin: 0; }

/* ---- buttons ---- */
.btn {
  font-family: var(--font-sans); font-size: var(--text-md);
  font-weight: var(--weight-medium); border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4); cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent-color); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: var(--border-color); }
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-strong); }
.btn-block { width: 100%; text-align: center; }

/* ---- badges / pills ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: var(--text-2xs);
  padding: 2px 8px; border-radius: var(--radius-pill);
  border: 1px solid var(--border-color); color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: var(--tracking-wide);
}
.badge.ok { color: var(--success-color); border-color: rgba(52,211,153,0.4); }
.badge.warn { color: var(--warning-color); border-color: rgba(245,185,80,0.4); }
.badge.err { color: var(--error-color); border-color: rgba(243,105,127,0.4); }
.badge.accent { color: var(--accent-color); border-color: var(--accent-soft); }

/* ---- form fields (login) ---- */
.field { margin-bottom: var(--space-4); }
.field label {
  display: block; font-size: var(--text-2xs); text-transform: uppercase;
  letter-spacing: var(--tracking-wide); color: var(--text-tertiary); margin-bottom: 6px;
}
.field input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-md);
  background: var(--bg-primary); border: 1px solid var(--border-color);
  color: var(--text-primary); font-size: var(--text-sm); font-family: var(--font-sans);
}
.field input:focus { outline: none; border-color: var(--accent-color); box-shadow: 0 0 0 3px var(--accent-soft); }
.divider { display: flex; align-items: center; gap: var(--space-3); margin: var(--space-5) 0; color: var(--text-tertiary); font-size: var(--text-2xs); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border-color); }
.btn-social {
  width: 100%; padding: 10px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-md);
  cursor: pointer; background: var(--bg-primary); color: var(--text-primary); font-size: var(--text-sm);
  display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--font-sans);
}

/* ---- alert / notice ---- */
.notice {
  border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5); display: flex; gap: var(--space-3);
  background: var(--bg-tertiary); color: var(--text-secondary); font-size: var(--text-sm);
}
.notice .notice-ico { flex: none; font-size: var(--text-lg); line-height: 1.2; }
.notice.err { border-color: rgba(243,105,127,0.4); background: var(--error-soft); }
.notice.warn { border-color: rgba(245,185,80,0.4); background: var(--warning-soft); }

/* ---- skeletons ---- */
.skel {
  background: var(--skeleton); background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---- reviewer annotation (NOT part of the shipped product surface) ---- */
.reviewer-note {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-tertiary);
  opacity: 0.72; border-top: 1px dashed var(--border-color);
  padding: var(--space-3) var(--space-6); background: var(--bg-secondary);
}

/* ---- frame footer walk-nav ---- */
.frame-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding: var(--space-3) var(--space-6);
  background: var(--bg-secondary); border-top: 1px solid var(--border-color); z-index: 40;
}
.frame-nav .caption { font-size: var(--text-sm); color: var(--text-tertiary); }
.frame-nav .caption b { color: var(--text-secondary); font-weight: var(--weight-semibold); }
.frame-nav a { text-decoration: none; }
