/* ============================================================
   DevPortal — Design Tokens
   Colorful & friendly • Very Compact Modern • Light + Dark
   ============================================================ */

:root {
  /* — Accent (overridden by Tweaks) — */
  --accent: #4f46e5;
  --accent-600: color-mix(in srgb, var(--accent) 84%, #000);
  --accent-700: color-mix(in srgb, var(--accent) 68%, #000);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, #ffffff);
  --accent-softer: color-mix(in srgb, var(--accent) 7%, #ffffff);
  --accent-ring: color-mix(in srgb, var(--accent) 38%, transparent);
  --accent-fg: #ffffff;

  /* — Radius (overridden by Tweaks: --radius-base) — */
  --radius-base: 10px;
  --r-xs: calc(var(--radius-base) * 0.4);
  --r-sm: calc(var(--radius-base) * 0.6);
  --r-md: var(--radius-base);
  --r-lg: calc(var(--radius-base) * 1.4);
  --r-xl: calc(var(--radius-base) * 1.9);
  --r-pill: 999px;

  /* — Density (overridden by [data-density]) — */
  --d: 1;                      /* density multiplier */
  --space-1: calc(4px * var(--d));
  --space-2: calc(6px * var(--d));
  --space-3: calc(8px * var(--d));
  --space-4: calc(12px * var(--d));
  --space-5: calc(16px * var(--d));
  --space-6: calc(20px * var(--d));
  --space-7: calc(28px * var(--d));
  --row-h: calc(36px * var(--d));
  --control-h: calc(32px * var(--d));

  /* — Typography (family overridden by Tweaks) — */
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --fs-2xs: 10.5px;
  --fs-xs: 11.5px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-lg: 15px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;

  /* — Semantic status — */
  --ok: #16a34a;   --ok-bg: #dcfce7;   --ok-fg: #15803d;
  --warn: #d97706; --warn-bg: #fef3c7; --warn-fg: #b45309;
  --err: #dc2626;  --err-bg: #fee2e2;  --err-fg: #b91c1c;
  --info: #2563eb; --info-bg: #dbeafe; --info-fg: #1d4ed8;

  /* — Category colors — */
  --cat-custom: #6366f1;     --cat-custom-bg: #eef2ff;
  --cat-opensource: #0d9488; --cat-opensource-bg: #ccfbf1;
  --cat-komersial: #ea580c;  --cat-komersial-bg: #ffedd5;

  /* — Sidebar nav accents (per item) — */
  --nav-dashboard: #4f46e5;
  --nav-layanan: #0891b2;
  --nav-pengaturan: #7c3aed;
}

/* — Light theme (default) — */
:root, [data-theme="light"] {
  --bg: #f4f5fa;
  --bg-grad-a: #eef0fb;
  --bg-grad-b: #f6f7fc;
  --surface: #ffffff;
  --surface-2: #f5f6fb;
  --surface-3: #eceef6;
  --border: #e4e7f0;
  --border-strong: #d4d8e6;
  --text: #1b1e2e;
  --text-2: #565b73;
  --text-3: #8b90a6;
  --text-inv: #ffffff;
  --shadow-sm: 0 1px 2px rgba(27, 30, 46, 0.06), 0 1px 1px rgba(27, 30, 46, 0.04);
  --shadow-md: 0 4px 12px rgba(27, 30, 46, 0.08), 0 2px 4px rgba(27, 30, 46, 0.04);
  --shadow-lg: 0 16px 40px rgba(27, 30, 46, 0.16), 0 4px 12px rgba(27, 30, 46, 0.08);
  --shadow-pop: 0 12px 32px rgba(27, 30, 46, 0.18);
  --overlay: rgba(20, 22, 36, 0.42);
  color-scheme: light;
}

/* — Dark theme — */
[data-theme="dark"] {
  --bg: #0d0f16;
  --bg-grad-a: #12141f;
  --bg-grad-b: #0d0f16;
  --surface: #171a24;
  --surface-2: #1d212e;
  --surface-3: #252a39;
  --border: #2a2f3e;
  --border-strong: #363c4e;
  --text: #e9ebf4;
  --text-2: #a0a6bd;
  --text-3: #6d7488;
  --text-inv: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 26%, #171a24);
  --accent-softer: color-mix(in srgb, var(--accent) 16%, #171a24);
  --ok-bg: color-mix(in srgb, var(--ok) 22%, #171a24);   --ok-fg: #4ade80;
  --warn-bg: color-mix(in srgb, var(--warn) 22%, #171a24); --warn-fg: #fbbf24;
  --err-bg: color-mix(in srgb, var(--err) 22%, #171a24);  --err-fg: #f87171;
  --info-bg: color-mix(in srgb, var(--info) 22%, #171a24); --info-fg: #60a5fa;
  --cat-custom-bg: color-mix(in srgb, var(--cat-custom) 22%, #171a24);
  --cat-opensource-bg: color-mix(in srgb, var(--cat-opensource) 22%, #171a24);
  --cat-komersial-bg: color-mix(in srgb, var(--cat-komersial) 22%, #171a24);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 18px 44px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 14px 36px rgba(0, 0, 0, 0.55);
  --overlay: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* — Density presets — */
[data-density="compact"]  { --d: 0.82; }
[data-density="regular"]  { --d: 1; }
[data-density="comfy"]    { --d: 1.22; }

/* ============================================================
   Base
   ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
#root { height: 100%; }

h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
::selection { background: var(--accent-ring); }

/* scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 999px;
  border: 2px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ============================================================
   Utilities
   ============================================================ */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum"; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.gap-5 { gap: var(--space-5); } .gap-6 { gap: var(--space-6); }
.grow { flex: 1; } .center { align-items: center; justify-content: center; }
.between { justify-content: space-between; } .wrap { flex-wrap: wrap; }

/* fade/slide animations */
/* fade/slide animations — transform-only so content is NEVER hidden by a
   frozen/throttled timeline (offscreen iframes pin animations to frame 0).
   Opacity is intentionally kept out of the resting visual. */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { transform: translateY(7px) scale(.985); } to { transform: none; } }
@keyframes slideUp { from { transform: translateY(11px); } to { transform: none; } }
@keyframes slideInRight { from { transform: translateX(100%); } to { transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }

.anim-fade { animation: slideUp .26s cubic-bezier(.3,.7,.4,1) backwards; }
.anim-pop { animation: popIn .2s cubic-bezier(.3,.7,.4,1) backwards; }
.anim-up { animation: slideUp .3s cubic-bezier(.3,.7,.4,1) backwards; }

/* Overlay/drawer entrances CAN hide content (backdrop fade, off-screen
   slide), so gate them behind html.anims — only applied once the page is
   confirmed visible with a live timeline. */
html:not(.anims) .overlay,
html:not(.anims) .drawer,
html:not(.anims) .toast {
  animation: none !important;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
