/* ============================================
   WealthPilot Design System
   Version: 1.0.0 — PoC
   ============================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Colors */
  --color-primary: #1A2744;
  --color-primary-light: #243458;
  --color-primary-dark: #111B30;
  --color-secondary: #2B3A67;
  --color-accent: #00C853;
  --color-accent-light: #69F0AE;
  --color-accent-dark: #00A844;
  --color-light: #F2F4F8;
  --color-lighter: #F8F9FC;
  --color-white: #FFFFFF;
  --color-error: #FF5252;
  --color-error-light: #FF8A80;
  --color-warning: #FFB74D;
  --color-warning-light: #FFE0B2;
  --color-info: #42A5F5;
  --color-info-light: #BBDEFB;
  --color-success: #00C853;
  --color-success-light: #B9F6CA;
  --color-text: #1A2744;
  --color-text-secondary: #5A6B8A;
  --color-text-muted: #8E99B0;
  --color-border: #E2E6EF;
  --color-border-light: #EEF0F5;
  --color-overlay: rgba(26, 39, 68, 0.6);

  /* Typography */
  --font-heading: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;
  --text-6xl: 3.75rem;

  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;

  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-extrabold: 800;

  /* Spacing */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* Radii */
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(26, 39, 68, 0.05);
  --shadow-sm: 0 1px 3px rgba(26, 39, 68, 0.08), 0 1px 2px rgba(26, 39, 68, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(26, 39, 68, 0.08), 0 2px 4px -2px rgba(26, 39, 68, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(26, 39, 68, 0.08), 0 4px 6px -4px rgba(26, 39, 68, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(26, 39, 68, 0.1), 0 8px 10px -6px rgba(26, 39, 68, 0.04);
  --shadow-2xl: 0 25px 50px -12px rgba(26, 39, 68, 0.2);
  --shadow-card: 0 2px 8px rgba(26, 39, 68, 0.06);
  --shadow-card-hover: 0 8px 24px rgba(26, 39, 68, 0.12);

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

  /* Z-index layers */
  --z-dropdown: 100;
  --z-sticky: 200;
  --z-fixed: 300;
  --z-modal-backdrop: 400;
  --z-modal: 500;
  --z-toast: 600;
  --z-tooltip: 700;

  /* Layout */
  --max-width: 1280px;
  --max-width-narrow: 960px;
  --sidebar-width: 260px;
  --header-height: 64px;
  --header-height-mobile: 56px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-white);
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
}

input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul, ol {
  list-style: none;
}

table {
  border-collapse: collapse;
  width: 100%;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  line-height: var(--leading-tight);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  line-height: var(--leading-relaxed);
  color: var(--color-text-secondary);
}

small {
  font-size: var(--text-sm);
}

.text-mono {
  font-family: var(--font-mono);
}

.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-error { color: var(--color-error); }
.text-success { color: var(--color-success); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-bold { font-weight: var(--weight-bold); }
.text-semibold { font-weight: var(--weight-semibold); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }

/* --- Layout Utilities --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.container-narrow {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.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-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.min-h-screen { min-height: 100vh; }

.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Spacing utilities */
.m-0 { margin: 0; }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-12 { margin-bottom: var(--space-12); }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-2 { padding: var(--space-2); }
.p-3 { padding: var(--space-3); }
.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }
.px-4 { padding-left: var(--space-4); padding-right: var(--space-4); }
.px-6 { padding-left: var(--space-6); padding-right: var(--space-6); }
.py-2 { padding-top: var(--space-2); padding-bottom: var(--space-2); }
.py-4 { padding-top: var(--space-4); padding-bottom: var(--space-4); }
.py-6 { padding-top: var(--space-6); padding-bottom: var(--space-6); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.py-12 { padding-top: var(--space-12); padding-bottom: var(--space-12); }
.py-16 { padding-top: var(--space-16); padding-bottom: var(--space-16); }
.py-20 { padding-top: var(--space-20); padding-bottom: var(--space-20); }

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--color-lighter);
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* --- Selection --- */
::selection {
  background-color: rgba(0, 200, 83, 0.15);
  color: var(--color-primary);
}

/* --- Focus visible --- */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* --- Page transition --- */
#app {
  opacity: 1;
  transition: opacity var(--transition-fast);
}

#app.page-transition {
  opacity: 0;
}

/* --- Loading screen --- */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-white);
  z-index: 9999;
  transition: opacity var(--transition-slow);
}

.loading-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.animate-fade-in { animation: fadeIn var(--transition-base) ease forwards; }
.animate-fade-in-up { animation: fadeInUp var(--transition-slow) ease forwards; }
.animate-fade-in-down { animation: fadeInDown var(--transition-base) ease forwards; }
.animate-slide-right { animation: slideInRight var(--transition-base) ease forwards; }
.animate-slide-left { animation: slideInLeft var(--transition-base) ease forwards; }
.animate-scale-in { animation: scaleIn var(--transition-base) ease forwards; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }

.delay-100 { animation-delay: 100ms; }
.delay-200 { animation-delay: 200ms; }
.delay-300 { animation-delay: 300ms; }
.delay-400 { animation-delay: 400ms; }
.delay-500 { animation-delay: 500ms; }

/* Stagger children — visible by default, animated via JS when desired */
.stagger > * { opacity: 1; }

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--color-light) 25%, var(--color-border-light) 50%, var(--color-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}

.skeleton-text {
  height: 1em;
  margin-bottom: 0.5em;
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-circle {
  border-radius: 50%;
}
