/* ============================================================================
   LinkdSys — Unified UX System (Brand v2, 2026 revamp)
   Brand-driven design tokens, fixed sidebar, bento layout, light/dark themes.
   Brand: Indigo #4F46E5 → Cyan #06B6D4. Plus Jakarta Sans + Inter + JetBrains Mono.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;600;700;800&family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design Tokens — Light (default) ──────────────────────────────────────── */
:root,
[data-theme="light"] {
  --brand:           #4F46E5;
  --brand-hover:     #4338CA;
  --brand-soft:      rgba(79, 70, 229, 0.08);
  --brand-ring:      rgba(79, 70, 229, 0.28);
  --secondary:       #6366F1;
  --accent:          #06B6D4;
  --accent-2:        #10B981;

  --ink:             #0F172A;
  --ink-soft:        #1E293B;
  --muted:           #64748B;
  --muted-2:         #94A3B8;

  --surface:         #FFFFFF;
  --surface-2:       #F8FAFC;
  --surface-3:       #F1F5F9;
  --canvas:          #F8FAFC;

  --border:          #E2E8F0;
  --border-strong:   #CBD5E1;

  --success:         #10B981;
  --warning:         #F59E0B;
  --error:           #E11D48;

  --radius-sm:       8px;
  --radius:          14px;
  --radius-lg:       20px;
  --radius-xl:       28px;

  --shadow-sm:       0 1px 2px rgba(15, 23, 42, .04), 0 1px 1px rgba(15, 23, 42, .03);
  --shadow:          0 4px 14px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg:       0 20px 40px -12px rgba(15, 23, 42, .14), 0 4px 12px rgba(15, 23, 42, .06);
  --shadow-brand:    0 10px 32px -8px rgba(79, 70, 229, .28);

  --font-head:       'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  --font-body:       'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono:       'JetBrains Mono', ui-monospace, monospace;

  --sidebar-w:       268px;
  --sidebar-w-collapsed: 72px;
  --topbar-h:        56px;
  --transition:      200ms cubic-bezier(.4, 0, .2, 1);
  --transition-slow: 320ms cubic-bezier(.4, 0, .2, 1);

  color-scheme: light;
}

/* ─── Design Tokens — Dark ─────────────────────────────────────────────────── */
[data-theme="dark"] {
  --brand:           #818CF8;
  --brand-hover:     #A5B4FC;
  --brand-soft:      rgba(129, 140, 248, 0.14);
  --brand-ring:      rgba(129, 140, 248, 0.40);
  --secondary:       #A5B4FC;
  --accent:          #22D3EE;
  --accent-2:        #34D399;

  --ink:             #F1F5F9;
  --ink-soft:        #E2E8F0;
  --muted:           #94A3B8;
  --muted-2:         #64748B;

  --surface:         #0F172A;
  --surface-2:       #131C2E;
  --surface-3:       #1B2740;
  --canvas:          #0A1020;

  --border:          #1E293B;
  --border-strong:   #334155;

  --shadow-sm:       0 1px 2px rgba(0, 0, 0, .35);
  --shadow:          0 6px 18px rgba(0, 0, 0, .35), 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-lg:       0 24px 48px -12px rgba(0, 0, 0, .55), 0 4px 12px rgba(0, 0, 0, .35);
  --shadow-brand:    0 12px 36px -8px rgba(129, 140, 248, .30);

  color-scheme: dark;
}

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

html.ux-shell, html.ux-shell body {
  margin: 0;
  padding: 0;
  background: var(--canvas) !important;
  color: var(--ink) !important;
  font-family: var(--font-body) !important;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--transition), color var(--transition);
}

html.ux-shell body { overflow-x: hidden; }

html.ux-shell h1, html.ux-shell h2, html.ux-shell h3, html.ux-shell h4 {
  font-family: var(--font-head);
  color: var(--ink);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

html.ux-shell a { color: var(--brand); text-decoration: none; transition: color var(--transition); }
html.ux-shell a:hover { color: var(--brand-hover); }

html.ux-shell :focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR (fixed, collapsible, with mega menu)
═══════════════════════════════════════════════════════════════════════════ */
.ux-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 90;
  transition: width var(--transition-slow), transform var(--transition-slow), background var(--transition);
  overflow: hidden;
}

html.ux-sidebar-collapsed .ux-sidebar {
  width: var(--sidebar-w-collapsed);
}

.ux-sidebar__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}

.ux-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.ux-sidebar__brand-mark {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: var(--shadow-brand);
}

html.ux-sidebar-collapsed .ux-sidebar__brand-text,
html.ux-sidebar-collapsed .ux-sidebar__group-label,
html.ux-sidebar-collapsed .ux-sidebar__item-label,
html.ux-sidebar-collapsed .ux-sidebar__chevron,
html.ux-sidebar-collapsed .ux-sidebar__badge,
html.ux-sidebar-collapsed .ux-sidebar__cta,
html.ux-sidebar-collapsed .ux-sidebar__sub { display: none !important; }

.ux-sidebar__theme-btn,
.ux-sidebar__collapse-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all var(--transition);
}

.ux-sidebar__theme-btn:hover,
.ux-sidebar__collapse-btn:hover {
  background: var(--brand-soft);
  border-color: var(--brand-ring);
  color: var(--brand);
}

.ux-sidebar__theme-btn .icon-sun,
.ux-sidebar__theme-btn .icon-moon { transition: opacity var(--transition), transform var(--transition); }
[data-theme="light"] .ux-sidebar__theme-btn .icon-moon,
[data-theme="dark"] .ux-sidebar__theme-btn .icon-sun {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
  position: absolute;
}

.ux-sidebar__nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.ux-sidebar__nav::-webkit-scrollbar { width: 6px; }
.ux-sidebar__nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }

.ux-sidebar__section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-2);
  padding: 14px 12px 6px;
  white-space: nowrap;
}
html.ux-sidebar-collapsed .ux-sidebar__section-title { visibility: hidden; height: 8px; padding: 4px 0; }

/* Top-level item (single link) */
.ux-sidebar__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  position: relative;
  text-decoration: none;
  min-height: 40px;
}
.ux-sidebar__item:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.ux-sidebar__item.is-active,
.ux-sidebar__item[aria-current="page"] {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.ux-sidebar__item.is-active::before {
  content: '';
  position: absolute;
  left: -8px; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.ux-sidebar__icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}
.ux-sidebar__icon svg { width: 18px; height: 18px; stroke-width: 2; }

/* Group toggle (top-level expandable) */
.ux-sidebar__group { margin: 1px 0; }

.ux-sidebar__group-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 9px 12px;
  border-radius: 10px;
  color: var(--ink-soft);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  min-height: 40px;
}
.ux-sidebar__group-toggle:hover {
  background: var(--brand-soft);
  color: var(--brand);
}
.ux-sidebar__group-label { flex: 1; min-width: 0; white-space: nowrap; }

.ux-sidebar__chevron {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform var(--transition);
  color: var(--muted);
}
.ux-sidebar__group.is-open > .ux-sidebar__group-toggle .ux-sidebar__chevron {
  transform: rotate(90deg);
  color: var(--brand);
}

.ux-sidebar__sub {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--transition-slow);
  overflow: hidden;
}
.ux-sidebar__group.is-open > .ux-sidebar__sub {
  grid-template-rows: 1fr;
}

.ux-sidebar__sub-inner {
  min-height: 0;
  padding: 2px 0 6px 8px;
  margin-left: 18px;
  border-left: 1px dashed var(--border);
}

.ux-sidebar__sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px 7px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition);
  position: relative;
  min-height: 32px;
  animation: ux-fadein 280ms cubic-bezier(.4,0,.2,1) both;
}
.ux-sidebar__sub-item .ux-sidebar__icon svg { width: 14px; height: 14px; }
.ux-sidebar__sub-item:hover {
  color: var(--brand);
  background: var(--brand-soft);
  transform: translateX(2px);
}
.ux-sidebar__sub-item.is-active,
.ux-sidebar__sub-item[aria-current="page"] {
  color: var(--brand);
  background: var(--brand-soft);
  font-weight: 600;
}
.ux-sidebar__sub-item.is-active::before {
  content: '';
  position: absolute;
  left: -1px; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--brand);
}

@keyframes ux-fadein {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

.ux-sidebar__badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ux-sidebar__badge--hot { background: linear-gradient(135deg, #F97316, #DC2626); }
.ux-sidebar__badge--pro { background: var(--brand); }

.ux-sidebar__cta {
  margin: 12px 12px 16px;
  padding: 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff;
  box-shadow: var(--shadow-brand);
}
.ux-sidebar__cta h4 { color: #fff; font-size: 14px; margin: 0 0 4px; }
.ux-sidebar__cta p  { color: rgba(255,255,255,0.85); font-size: 12px; margin: 0 0 10px; line-height: 1.4; }
.ux-sidebar__cta a {
  display: inline-block;
  background: #fff;
  color: var(--brand);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  text-decoration: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT — shifts with sidebar
═══════════════════════════════════════════════════════════════════════════ */
html.ux-shell .ux-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
  position: relative;
}
html.ux-sidebar-collapsed .ux-main {
  margin-left: var(--sidebar-w-collapsed);
}

/* ═══════════════════════════════════════════════════════════════════════════
   MOBILE TOPBAR + DRAWER
═══════════════════════════════════════════════════════════════════════════ */
.ux-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 80;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
  align-items: center;
  gap: 10px;
  min-height: var(--topbar-h);
}
.ux-topbar__hamburger,
.ux-topbar__theme {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--ink);
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: all var(--transition);
}
.ux-topbar__hamburger:hover,
.ux-topbar__theme:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: var(--brand-ring);
}
.ux-topbar__brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--ink);
  font-family: var(--font-head);
  font-weight: 700;
  flex: 1;
  font-size: 16px;
}
.ux-topbar__brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 12px;
}

.ux-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.50);
  backdrop-filter: blur(4px);
  z-index: 89;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
html.ux-drawer-open .ux-overlay {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 1024px) {
  .ux-topbar { display: flex; }
  html.ux-shell .ux-main { margin-left: 0 !important; }
  .ux-sidebar {
    width: 300px !important;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  html.ux-drawer-open .ux-sidebar {
    transform: translateX(0);
  }
  html.ux-drawer-open { overflow: hidden; }
  html.ux-sidebar-collapsed .ux-sidebar__brand-text,
  html.ux-sidebar-collapsed .ux-sidebar__group-label,
  html.ux-sidebar-collapsed .ux-sidebar__item-label,
  html.ux-sidebar-collapsed .ux-sidebar__chevron,
  html.ux-sidebar-collapsed .ux-sidebar__badge,
  html.ux-sidebar-collapsed .ux-sidebar__cta,
  html.ux-sidebar-collapsed .ux-sidebar__sub { display: revert !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BENTO LAYOUT
═══════════════════════════════════════════════════════════════════════════ */
.ux-page {
  padding: 28px clamp(16px, 4vw, 40px) 60px;
  max-width: 1440px;
  margin: 0 auto;
}

.ux-page__head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.ux-page__title { font-size: clamp(28px, 4vw, 40px); font-weight: 700; }
.ux-page__lede  { font-size: 16px; color: var(--muted); margin-top: 8px; max-width: 70ch; }

.ux-bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .ux-bento { grid-template-columns: repeat(6, 1fr); gap: 12px; }
}
@media (max-width: 560px) {
  .ux-bento { grid-template-columns: 1fr; }
}

.ux-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-decoration: none;
  color: inherit;
  position: relative;
  overflow: hidden;
  grid-column: span 12;
}

.ux-card:hover {
  box-shadow: var(--shadow-lg), var(--shadow-brand);
  transform: translateY(-2px);
  border-color: var(--brand-ring);
}

/* Card sizes inside bento */
.ux-card--sm { grid-column: span 12; }
.ux-card--md { grid-column: span 6; }
.ux-card--lg { grid-column: span 8; }
.ux-card--xl { grid-column: span 12; }
.ux-card--feature { grid-column: span 4; }
.ux-card--stat { grid-column: span 3; }

@media (max-width: 1200px) {
  .ux-card--feature { grid-column: span 6; }
  .ux-card--stat    { grid-column: span 6; }
  .ux-card--lg      { grid-column: span 12; }
  .ux-card--md      { grid-column: span 12; }
}
@media (max-width: 560px) {
  .ux-card, .ux-card--feature, .ux-card--stat, .ux-card--md, .ux-card--lg { grid-column: 1 / -1; }
}

.ux-card--brand {
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff;
  border-color: transparent;
}
.ux-card--brand h2, .ux-card--brand h3, .ux-card--brand h4 { color: #fff; }
.ux-card--brand p { color: rgba(255,255,255,0.88); }

.ux-card__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand);
  padding: 4px 10px;
  background: var(--brand-soft);
  border-radius: 999px;
  align-self: flex-start;
}

.ux-card__icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}
.ux-card__icon svg { width: 20px; height: 20px; }
.ux-card--brand .ux-card__icon { background: rgba(255,255,255,0.18); color: #fff; }

.ux-card__title { font-size: 18px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.ux-card__desc  { font-size: 14px; color: var(--muted); line-height: 1.5; margin: 0; }
.ux-card--brand .ux-card__title { color: #fff; }
.ux-card--brand .ux-card__desc  { color: rgba(255,255,255,0.88); }

.ux-card__stat { font-family: var(--font-head); font-size: 36px; font-weight: 700; color: var(--ink); letter-spacing: -0.02em; }
.ux-card__stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

.ux-card__cta {
  margin-top: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--brand);
  font-weight: 600;
  font-size: 14px;
}
.ux-card--brand .ux-card__cta { color: #fff; }
.ux-card:hover .ux-card__cta { transform: translateX(2px); }

/* Utility buttons used in bento pages */
.ux-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  min-height: 44px;
}
.ux-btn--primary { background: var(--brand); color: #fff; }
.ux-btn--primary:hover { background: var(--brand-hover); color: #fff; box-shadow: var(--shadow-brand); transform: translateY(-1px); }
.ux-btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--border-strong); }
.ux-btn--ghost:hover { background: var(--surface-2); border-color: var(--brand); color: var(--brand); }

/* Soft-tinted section wrapper used by some pages */
.ux-section {
  margin-top: 36px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.ux-section h2 { font-size: 24px; margin-bottom: 6px; }
.ux-section p.lede { color: var(--muted); margin-bottom: 18px; }

/* No-flash before paint */
html.ux-shell.no-fouc body { visibility: hidden; }

/* Hide legacy public nav when ux-shell is active */
html.ux-shell .hp-nav,
html.ux-shell .dashboard-topbar,
html.ux-shell .dashboard-sidebar,
html.ux-shell .dashboard-bottom-nav,
html.ux-shell .sidebar-overlay,
html.ux-shell .hp-bg,
html.ux-shell .hp-gradient-mesh { display: none !important; }

/* Reset legacy page backgrounds when ux-shell is active */
html.ux-shell .dashboard-content,
html.ux-shell .hp-content { padding: 0 !important; margin: 0 !important; background: transparent !important; }
html.ux-shell body { background: var(--canvas) !important; }

.ux-sidebar__badge--soon { background: #FDE68A; color: #92400E; }
