/* ============================================================
   base.css — CSS variables, reset, typography, utilities
   FinDom Financial Management App
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  /* Colors */
  --color-bg:            #0f172a;
  --color-card:          #1e293b;
  --color-border:        #334155;
  --color-text-primary:  #f1f5f9;
  --color-text-secondary:#94a3b8;
  --color-accent:        #3b82f6;
  --color-accent-hover:  #2563eb;
  --color-success:       #22c55e;
  --color-danger:        #ef4444;
  --color-warning:       #f59e0b;
  --color-income:        #10b981;
  --color-expense:       #f43f5e;

  /* Pocket accent colors */
  --color-pocket-business: #3b82f6;
  --color-pocket-egor:     #a855f7;
  --color-pocket-nastya:   #ec4899;

  /* Surface layers */
  --color-surface-1:     #1e293b;
  --color-surface-2:     #263348;
  --color-surface-3:     #2e3d57;

  /* Overlay */
  --color-overlay:       rgba(0, 0, 0, 0.6);

  /* Typography */
  --font-family:         system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-xs:        0.75rem;   /* 12px */
  --font-size-sm:        0.875rem;  /* 14px */
  --font-size-base:      1rem;      /* 16px */
  --font-size-md:        1.125rem;  /* 18px */
  --font-size-lg:        1.25rem;   /* 20px */
  --font-size-xl:        1.5rem;    /* 24px */
  --font-size-2xl:       1.875rem;  /* 30px */
  --font-size-3xl:       2.25rem;   /* 36px */

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

  --line-height-tight:   1.25;
  --line-height-normal:  1.5;
  --line-height-relaxed: 1.75;

  /* Spacing scale (4px base) */
  --space-0:   0;
  --space-1:   0.25rem;   /* 4px */
  --space-2:   0.5rem;    /* 8px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-xl:  0 16px 40px rgba(0, 0, 0, 0.6);

  /* Transitions */
  --transition-fast:   150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow:   400ms ease;

  /* Z-index scale */
  --z-base:    0;
  --z-raised:  10;
  --z-sticky:  100;
  --z-overlay: 200;
  --z-modal:   300;
  --z-toast:   400;
}

/* ── Light Theme ───────────────────────────────────────────── */
[data-theme="light"] {
  --color-bg:            #f8fafc;
  --color-card:          #ffffff;
  --color-border:        #e2e8f0;
  --color-text-primary:  #0f172a;
  --color-text-secondary:#64748b;
  --color-accent:        #2563eb;
  --color-accent-hover:  #1d4ed8;
  --color-success:       #16a34a;
  --color-danger:        #dc2626;
  --color-warning:       #d97706;
  --color-income:        #059669;
  --color-expense:       #e11d48;

  --color-surface-1:     #f1f5f9;
  --color-surface-2:     #e2e8f0;
  --color-surface-3:     #cbd5e1;

  --color-overlay:       rgba(0, 0, 0, 0.35);

  --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md:  0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-lg:  0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-xl:  0 16px 40px rgba(0, 0, 0, 0.15);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

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

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

p, h1, h2, h3, h4, h5, h6 {
  overflow-wrap: break-word;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
}

ul, ol {
  list-style: none;
}

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

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

/* ── Base Typography ───────────────────────────────────────── */
h1 {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h2 {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h3 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-tight);
  color: var(--color-text-primary);
}

h4 {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

h5, h6 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
}

p {
  color: var(--color-text-primary);
  line-height: var(--line-height-normal);
}

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

strong {
  font-weight: var(--font-weight-semibold);
}

/* ── Utility Classes ───────────────────────────────────────── */

/* Text color utilities */
.text-primary   { color: var(--color-text-primary) !important; }
.text-secondary { color: var(--color-text-secondary) !important; }
.text-success   { color: var(--color-success) !important; }
.text-danger    { color: var(--color-danger) !important; }
.text-warning   { color: var(--color-warning) !important; }
.text-accent    { color: var(--color-accent) !important; }
.text-income    { color: var(--color-income) !important; }
.text-expense   { color: var(--color-expense) !important; }

/* Text alignment */
.text-left   { text-align: left !important; }
.text-center { text-align: center !important; }
.text-right  { text-align: right !important; }

/* Font size */
.text-xs   { font-size: var(--font-size-xs) !important; }
.text-sm   { font-size: var(--font-size-sm) !important; }
.text-base { font-size: var(--font-size-base) !important; }
.text-lg   { font-size: var(--font-size-lg) !important; }
.text-xl   { font-size: var(--font-size-xl) !important; }

/* Font weight */
.font-normal   { font-weight: var(--font-weight-normal) !important; }
.font-medium   { font-weight: var(--font-weight-medium) !important; }
.font-semibold { font-weight: var(--font-weight-semibold) !important; }
.font-bold     { font-weight: var(--font-weight-bold) !important; }

/* Display */
.hidden         { display: none !important; }
.block          { display: block !important; }
.inline-block   { display: inline-block !important; }
.inline         { display: inline !important; }

/* Flexbox */
.flex           { display: flex !important; }
.flex-col       { display: flex; flex-direction: column !important; }
.flex-wrap      { flex-wrap: wrap !important; }
.flex-nowrap    { flex-wrap: nowrap !important; }
.flex-1         { flex: 1 !important; }
.flex-auto      { flex: auto !important; }
.flex-none      { flex: none !important; }
.flex-shrink-0  { flex-shrink: 0 !important; }

/* Align / Justify */
.items-start    { align-items: flex-start !important; }
.items-center   { align-items: center !important; }
.items-end      { align-items: flex-end !important; }
.items-stretch  { align-items: stretch !important; }

.justify-start   { justify-content: flex-start !important; }
.justify-center  { justify-content: center !important; }
.justify-end     { justify-content: flex-end !important; }
.justify-between { justify-content: space-between !important; }
.justify-around  { justify-content: space-around !important; }

/* Gap */
.gap-1  { gap: var(--space-1) !important; }
.gap-2  { gap: var(--space-2) !important; }
.gap-3  { gap: var(--space-3) !important; }
.gap-4  { gap: var(--space-4) !important; }
.gap-5  { gap: var(--space-5) !important; }
.gap-6  { gap: var(--space-6) !important; }
.gap-8  { gap: var(--space-8) !important; }

/* Margin top */
.mt-0  { margin-top: var(--space-0) !important; }
.mt-1  { margin-top: var(--space-1) !important; }
.mt-2  { margin-top: var(--space-2) !important; }
.mt-3  { margin-top: var(--space-3) !important; }
.mt-4  { margin-top: var(--space-4) !important; }
.mt-5  { margin-top: var(--space-5) !important; }
.mt-6  { margin-top: var(--space-6) !important; }
.mt-8  { margin-top: var(--space-8) !important; }
.mt-10 { margin-top: var(--space-10) !important; }
.mt-12 { margin-top: var(--space-12) !important; }

/* Margin bottom */
.mb-0  { margin-bottom: var(--space-0) !important; }
.mb-1  { margin-bottom: var(--space-1) !important; }
.mb-2  { margin-bottom: var(--space-2) !important; }
.mb-3  { margin-bottom: var(--space-3) !important; }
.mb-4  { margin-bottom: var(--space-4) !important; }
.mb-5  { margin-bottom: var(--space-5) !important; }
.mb-6  { margin-bottom: var(--space-6) !important; }
.mb-8  { margin-bottom: var(--space-8) !important; }
.mb-10 { margin-bottom: var(--space-10) !important; }
.mb-12 { margin-bottom: var(--space-12) !important; }

/* Margin left / right */
.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Padding */
.p-0  { padding: var(--space-0) !important; }
.p-1  { padding: var(--space-1) !important; }
.p-2  { padding: var(--space-2) !important; }
.p-3  { padding: var(--space-3) !important; }
.p-4  { padding: var(--space-4) !important; }
.p-5  { padding: var(--space-5) !important; }
.p-6  { padding: var(--space-6) !important; }
.p-8  { padding: var(--space-8) !important; }

.px-2  { padding-left: var(--space-2) !important; padding-right: var(--space-2) !important; }
.px-3  { padding-left: var(--space-3) !important; padding-right: var(--space-3) !important; }
.px-4  { padding-left: var(--space-4) !important; padding-right: var(--space-4) !important; }
.px-6  { padding-left: var(--space-6) !important; padding-right: var(--space-6) !important; }

.py-2  { padding-top: var(--space-2) !important; padding-bottom: var(--space-2) !important; }
.py-3  { padding-top: var(--space-3) !important; padding-bottom: var(--space-3) !important; }
.py-4  { padding-top: var(--space-4) !important; padding-bottom: var(--space-4) !important; }
.py-6  { padding-top: var(--space-6) !important; padding-bottom: var(--space-6) !important; }

/* Width / Height */
.w-full  { width: 100% !important; }
.h-full  { height: 100% !important; }
.min-w-0 { min-width: 0 !important; }

/* Overflow */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto   { overflow: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }

/* Position */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed    { position: fixed !important; }
.sticky   { position: sticky !important; }

/* Cursor */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }

/* Border radius */
.rounded-sm   { border-radius: var(--radius-sm) !important; }
.rounded-md   { border-radius: var(--radius-md) !important; }
.rounded-lg   { border-radius: var(--radius-lg) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

/* Truncate */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Visually hidden (accessible) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* No select */
.select-none { user-select: none !important; }

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

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary);
}

/* Selection */
::selection {
  background-color: rgba(59, 130, 246, 0.3);
  color: var(--color-text-primary);
}
