/* ==========================================================================
   EMR - RJL · Design System v3 "Antislop Medical"
   Sistem desain klinis profesional, kontras tinggi, bebas gaya generik AI.
   Default: Dark Mode dengan dukungan Light Mode via data-theme / class .dark.
   ========================================================================== */

/* ---------- 1. FONT ---------- */
@import url("https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700;800&family=Plus+Jakarta+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&display=swap");

/* ---------- 2. TOKENS & THEMING ---------- */
:root {
  --font-display: "Outfit", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

  /* Brand Colors (Clinical Teal) */
  --brand-50: #f0fdfa;
  --brand-100: #ccfbf1;
  --brand-200: #99f6e4;
  --brand-300: #5eead4;
  --brand-400: #2dd4bf;
  --brand-500: #14b8a6;
  --brand-600: #0d9488;
  --brand-700: #0f766e;
  --brand-800: #115e59;
  --brand-900: #134e4a;

  /* Light Theme Tokens */
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;
  
  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.85);

  --btn-primary-bg: #0f766e;
  --btn-primary-hover: #115e59;
  --btn-primary-text: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.12);

  --grad-brand: linear-gradient(135deg, #0d9488 0%, #0e7490 100%);
  --grad-btn: linear-gradient(135deg, #0f766e 0%, #0e7490 100%);
  --grad-btn-hover: linear-gradient(135deg, #115e59 0%, #0f766e 100%);
}

/* Default / Dark Theme */
:root,
html.dark,
[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-surface: #101726;
  --bg-surface-elevated: #151f32;
  --bg-surface-subtle: #1a263d;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #090d16;

  --card-bg: #101726;
  --card-border: rgba(255, 255, 255, 0.08);
  --header-bg: rgba(9, 13, 22, 0.85);

  --btn-primary-bg: #0d9488;
  --btn-primary-hover: #14b8a6;
  --btn-primary-text: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 16px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 36px -6px rgba(0, 0, 0, 0.5);

  --grad-brand: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
  --grad-btn: linear-gradient(135deg, #0d9488 0%, #0e7490 100%);
  --grad-btn-hover: linear-gradient(135deg, #14b8a6 0%, #0284c7 100%);
}

/* Explicit Light Mode Override */
html:not(.dark)[data-theme="light"] {
  --bg-page: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-surface-subtle: #f1f5f9;
  --border-subtle: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;
  --text-inverse: #ffffff;

  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --header-bg: rgba(255, 255, 255, 0.88);

  --btn-primary-bg: #0f766e;
  --btn-primary-hover: #115e59;
  --btn-primary-text: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.12);

  --grad-brand: linear-gradient(135deg, #0f766e 0%, #0e7490 100%);
  --grad-btn: linear-gradient(135deg, #0f766e 0%, #0e7490 100%);
  --grad-btn-hover: linear-gradient(135deg, #115e59 0%, #0f766e 100%);
}

/* ---------- 3. BASE STYLES ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
  color-scheme: dark light;
}

html.dark {
  color-scheme: dark;
}

html:not(.dark)[data-theme="light"] {
  color-scheme: light;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  text-rendering: optimizeLegibility;
  transition: background-color 0.25s ease, color 0.25s ease;
}

body.is-shell {
  background-color: var(--bg-page);
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
.font-display {
  font-family: var(--font-display);
  letter-spacing: -0.025em;
  color: var(--text-primary);
}

.mono,
.tabular {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

::selection {
  background: var(--brand-500);
  color: #ffffff;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: var(--bg-page);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid var(--bg-page);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--brand-600);
}

/* ---------- 4. SCROLL PROGRESS ---------- */
.scroll-progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2.5px;
  z-index: 99;
  transform-origin: 0 50%;
  transform: scaleX(0);
  background: var(--brand-500);
  will-change: transform;
}

/* ---------- 5. AMBIENT BACKDROP (Antislop: tenang & tidak mencolok) ---------- */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--bg-page);
}

.aurora__mesh {
  position: absolute;
  inset: 0;
  opacity: 0.15;
  background: radial-gradient(1200px 600px at 15% 10%, rgba(20, 184, 166, 0.2), transparent 70%);
}

.aurora__grid {
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 32px 32px;
}

html:not(.dark)[data-theme="light"] .aurora__grid {
  background-image: linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
}

.orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0.06;
}
.orb--a {
  width: 320px;
  height: 320px;
  left: 0;
  top: 5%;
  background: var(--brand-500);
}
.orb--b {
  width: 360px;
  height: 360px;
  right: 0;
  top: 40%;
  background: #0284c7;
}
.orb--c {
  width: 280px;
  height: 280px;
  left: 30%;
  bottom: 0;
  background: var(--brand-600);
}

/* ---------- 6. REVEAL / MOTION (Halus & Responsif) ---------- */
[data-motion] {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease-out, transform 0.35s ease-out;
  transition-delay: var(--motion-delay, 0ms);
}
[data-motion].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  [data-motion] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}

/* ---------- 7. TEKS GRADIENT & TYPOGRAPHY ---------- */
.gradient-text,
.gradient-text--light,
.gradient-text--deep {
  color: var(--brand-400);
}

html:not(.dark)[data-theme="light"] .gradient-text,
html:not(.dark)[data-theme="light"] .gradient-text--deep {
  color: var(--brand-700);
}

.text-meta {
  color: var(--text-muted);
}

.text-on-dark {
  color: #cbd5e1;
}

/* ---------- 8. CARDS & SURFACES ---------- */
.holo-card,
.glass,
.glass--dark {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.holo-card:hover,
.glass:hover {
  border-color: var(--brand-500);
  box-shadow: var(--shadow-md);
}

/* Header blur */
[data-header] {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* ---------- 9. BUTTONS ---------- */
.btn-motion {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border-radius: 10px;
  font-weight: 600;
  transition: all 0.2s ease;
  user-select: none;
}
.btn-motion:hover {
  transform: translateY(-1px);
}
.btn-motion:active {
  transform: translateY(0);
}

.btn-primary-grad {
  background-color: var(--btn-primary-bg);
  color: var(--btn-primary-text);
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
}
.btn-primary-grad:hover {
  background-color: var(--btn-primary-hover);
  color: #ffffff;
  box-shadow: var(--shadow-md);
}

/* Ripple */
.ripple-dot {
  display: none;
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 9px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* ---------- 10. CHIPS / BADGES ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface-subtle);
  color: var(--brand-400);
}

html:not(.dark)[data-theme="light"] .chip {
  color: var(--brand-700);
  background: var(--brand-50);
  border-color: var(--brand-200);
}

.chip--light {
  border-color: var(--border-subtle);
  background: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.dot-live {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

/* ---------- 11. FORM CONTROLS ---------- */
input,
select,
textarea {
  font-family: inherit;
  color: var(--text-primary);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-strong);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

/* ---------- 12. TOAST ---------- */
.toast-motion {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* ---------- 13. FOCUS & A11Y ---------- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}

/* ---------- 14. ADAPTIVE CARDS FOR CODER & MODULES ---------- */
.menu-item {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  transition: all 0.2s ease;
}
.menu-item:hover {
  border-color: var(--brand-500);
  background: var(--bg-surface-elevated);
}

.kpi-item {
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  transition: all 0.2s ease;
}
.kpi-item:hover {
  border-color: var(--brand-500);
}
