/* ============================================
   ZX JOURNAL — MAIN DESIGN SYSTEM
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* --- CSS Variables --- */
:root {
  /* Base */
  --bg-base: #030e0c;
  --bg-deep: #020a09;

  /* Surfaces (Frosted Glass) */
  --surface-1: rgba(8, 28, 24, 0.72);
  --surface-2: rgba(12, 38, 32, 0.80);
  --surface-3: rgba(18, 52, 44, 0.85);
  --surface-hover: rgba(20, 62, 52, 0.90);
  --surface-active: rgba(26, 78, 64, 0.92);

  /* Borders */
  --border-dim: rgba(52, 211, 153, 0.08);
  --border-soft: rgba(52, 211, 153, 0.15);
  --border-glow: rgba(52, 211, 153, 0.35);
  --border-bright: rgba(52, 211, 153, 0.6);

  /* RGB channels — allows rgba(var(--emerald-rgb), 0.3) in component CSS */
  --emerald-rgb: 52, 211, 153;
  --teal-rgb:    45, 212, 191;
  --win-rgb:     74, 222, 128;
  --loss-rgb:    248, 113, 113;
  --warn-rgb:    251, 191, 36;

  /* Semantic */
  --text-on-accent: #021210;
  --forex:          #818cf8;
  --forex-bg:       rgba(99, 102, 241, 0.10);
  --forex-border:   rgba(99, 102, 241, 0.25);

  /* Accents */
  --emerald: #34d399;
  --emerald-bright: #6ee7b7;
  --emerald-dim: #10b981;
  --teal: #2dd4bf;
  --teal-dim: #0d9488;
  --cyan: #67e8f9;

  /* Semantic */
  --win: #4ade80;
  --win-bg: rgba(74, 222, 128, 0.1);
  --loss: #f87171;
  --loss-bg: rgba(248, 113, 113, 0.1);
  --neutral: #94a3b8;
  --warn: #fbbf24;

  /* Text */
  --text-primary: #e2fdf7;
  --text-secondary: rgba(226, 253, 247, 0.7);
  --text-muted: rgba(226, 253, 247, 0.38);
  --text-faint: rgba(226, 253, 247, 0.18);

  /* macOS Traffic Lights */
  --mac-close: #ff5f57;
  --mac-minimize: #febc2e;
  --mac-maximize: #28c840;

  /* Glows */
  --glow-emerald: 0 0 20px rgba(52, 211, 153, 0.3), 0 0 60px rgba(52, 211, 153, 0.1);
  --glow-emerald-strong: 0 0 30px rgba(52, 211, 153, 0.5), 0 0 80px rgba(52, 211, 153, 0.2);
  --glow-teal: 0 0 20px rgba(45, 212, 191, 0.3);
  --glow-card: 0 8px 32px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(52, 211, 153, 0.1) inset;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-2xl: 24px;
  --radius-pill: 999px;

  /* Transitions */
  --t-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --topbar-height: 60px;

  /* Z-index */
  --z-base: 1;
  --z-sidebar: 100;
  --z-topbar: 200;
  --z-modal-backdrop: 900;
  --z-modal: 1000;
  --z-spotlight: 2000;
  --z-toast: 3000;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  height: 100%;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Canvas particle layer */
#particles-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* App shell */
#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(var(--emerald-rgb), 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(var(--emerald-rgb), 0.4); }

/* --- Glass Utilities --- */
.glass {
  background: var(--surface-1);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-dim);
}

.glass-2 {
  background: var(--surface-2);
  backdrop-filter: blur(24px) saturate(200%);
  -webkit-backdrop-filter: blur(24px) saturate(200%);
  border: 1px solid var(--border-soft);
}

.glass-3 {
  background: var(--surface-3);
  backdrop-filter: blur(28px) saturate(220%);
  -webkit-backdrop-filter: blur(28px) saturate(220%);
  border: 1px solid var(--border-glow);
}

/* --- Typography --- */
.font-display { font-family: 'Space Grotesk', 'Inter', sans-serif; }

h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.015em; }
h3 { font-size: 1.2rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 500; }
h5 { font-size: 0.875rem; font-weight: 500; }

.text-emerald { color: var(--emerald); }
.text-teal { color: var(--teal); }
.text-muted { color: var(--text-muted); }
.text-win { color: var(--win); }
.text-loss { color: var(--loss); }

/* --- Gradient Text --- */
.gradient-text {
  background: linear-gradient(135deg, var(--emerald) 0%, var(--teal) 50%, var(--cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* --- Layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  transition: margin-left var(--t-base);
  min-height: 100vh;
  position: relative;
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}

.page-container {
  padding: var(--space-xl);
  max-width: 1600px;
}

/* --- Cards --- */
.card {
  background: var(--surface-1);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--border-dim);
  border-radius: var(--radius-lg);
  box-shadow: var(--glow-card);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
  will-change: transform, box-shadow;
  transform: translateZ(0); /* Hardware Acceleration */
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--border-soft);
  box-shadow: var(--glow-card), var(--glow-emerald);
}

.card-glow {
  border-color: var(--border-glow);
  box-shadow: var(--glow-card), var(--glow-emerald);
}

/* Animated gradient border */
.card-animated-border {
  position: relative;
  border: 1px solid transparent;
  background-clip: padding-box;
}
.card-animated-border::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(var(--animated-border-angle, 135deg),
    rgba(var(--emerald-rgb),0.6), rgba(var(--teal-rgb),0.3), rgba(var(--emerald-rgb),0.1), rgba(var(--emerald-rgb),0.6));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  mask-composite: exclude;
  animation: borderSpin 4s linear infinite;
  pointer-events: none;
}

/* --- Stat Cards --- */
.stat-card {
  padding: var(--space-lg);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -40%;
  right: -20%;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(var(--emerald-rgb),0.15) 0%, transparent 70%);
  pointer-events: none;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-long {
  background: rgba(var(--emerald-rgb), 0.12);
  color: var(--emerald);
  border: 1px solid rgba(var(--emerald-rgb), 0.25);
}

.badge-short {
  background: rgba(var(--loss-rgb), 0.12);
  color: var(--loss);
  border: 1px solid rgba(var(--loss-rgb), 0.25);
}

.badge-futures {
  background: rgba(var(--warn-rgb), 0.12);
  color: var(--warn);
  border: 1px solid rgba(var(--warn-rgb), 0.25);
}

.badge-forex {
  background: var(--forex-bg);
  color: var(--forex);
  border: 1px solid var(--forex-border);
}

.badge-win {
  background: var(--win-bg);
  color: var(--win);
  border: 1px solid rgba(var(--win-rgb), 0.25);
}

.badge-loss {
  background: var(--loss-bg);
  color: var(--loss);
  border: 1px solid rgba(var(--loss-rgb), 0.25);
}

/* --- Page transition --- */
.page-enter {
  animation: pageEnter 350ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-exit {
  animation: pageExit 200ms cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* --- Utility --- */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }
.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-md); }

/* Divider */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-soft), transparent);
  margin: var(--space-md) 0;
}
