/* ============================================================
   PathFinance Design System
   Based on DESIGN.md tokens — all values from PathDesk reference
   ============================================================ */

/* --- Google Fonts ---
   Loaded via <link> in _Layout.cshtml and _AuthLayout.cshtml.
   Do NOT add @import here (causes duplicate request).
   ============================================================ */

/* ============================================================
   1. CSS Custom Properties (Design Tokens)
   ============================================================ */

:root {
    /* --- Brand Colors (section 2.2) --- */
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --primary-light: #EDE9FE;
    --primary-dark: #6D28D9;
    --text-primary: #141921;
    --text-secondary: #6B7280;
    --background: #F9FAFB;
    --surface: #FFFFFF;
    --border: #E5E7EB;

    /* --- Semantic Colors (section 2.2) --- */
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --success: #10B981;
    --success-light: #D1FAE5;
    --info: #3B82F6;
    --info-light: #DBEAFE;

    /* --- Sidebar (Sprint 26.2: 220->200, collapsed 56->52) --- */
    --sidebar-bg: #1E1852;
    --sidebar-width: 200px;
    --sidebar-collapsed-width: 52px;

    /* --- Spacing Tokens (section 2.4)
       Sprint 26.2 — mais 10% de reducao ancorado no feedback do usuario
       (zoom 90% ficou perfeito, entao reduzimos o restante no CSS).
    */
    --space-xs: 4px;
    --space-sm: 6px;
    --space-md: 11px;
    --space-lg: 18px;
    --space-xl: 24px;
    --space-2xl: 36px;

    /* --- Layout (Sprint 26.2: header 48->44) --- */
    --container-max-width: 1280px;
    --header-height: 44px;

    /* --- Border Radius (section 2.4) --- */
    --radius-card: 8px;
    --radius-input: 6px;
    --radius-pill: 9999px;

    /* --- Shadows (section 2.4) --- */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.08), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-modal: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    --shadow-focus-primary: 0 0 0 3px rgba(139, 92, 246, 0.15);
    --shadow-focus-danger: 0 0 0 3px rgba(239, 68, 68, 0.15);

    /* --- Transition durations --- */
    --duration-fast: 100ms;
    --duration-base: 150ms;
    --duration-slow: 250ms;
    --easing-base: ease;

    /* --- Z-index scale --- */
    --z-sticky: 100;
    --z-sidebar: 200;
    --z-dropdown: 500;
    --z-popover: 800;
    --z-modal: 1000;
    --z-modal-nested: 2000;
    --z-toast: 2200;
    --z-confirm: 2500;

    /* --- Control heights (inputs, buttons, selects) ---
       Sprint UX-1: controles padrao em 38px (confortavel).
       --control-height-sm (30px) para contextos compactos (celulas de tabela).
    */
    --control-height: 38px;
    --control-height-sm: 30px;
    --control-height-lg: 44px;

    /* --- Typography (families) --- */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

    /* --- Typography (scale) ---
       Sprint 26.2 — reducao final de mais 10% (equivalente a zoom 90%
       que o usuario validou como perfeito). Base = 12px.
       Historico:
         - v1: base 12px (zoom 75%) — pequeno demais
         - v2: base 13px (zoom 80%) — bom mas usuario ainda zoom 90%
         - v3: base 12px novamente mas com spacing/heights reduzidos
    */
    --font-xs: 10px;
    --font-sm: 11px;
    --font-base: 12px;
    --font-md: 13px;
    --font-lg: 14px;
    --font-xl: 15px;
    --font-2xl: 17px;
    --font-3xl: 20px;
    --font-4xl: 23px;

    --line-tight: 1.2;
    --line-normal: 1.5;
    --line-relaxed: 1.65;
}

/* ============================================================
   1b. Utility classes (Sprint UX-4)
   Para substituir style="display:flex;gap:...;align-items:..." inline.
   Prefixo .u- para distinguir de componentes.
   ============================================================ */

/* Flex layouts */
.u-row { display: flex; align-items: center; }
.u-row-top { display: flex; align-items: flex-start; }
.u-row-baseline { display: flex; align-items: baseline; }
.u-col { display: flex; flex-direction: column; }
.u-between { justify-content: space-between; }
.u-end { justify-content: flex-end; }
.u-center { justify-content: center; }
.u-stretch { align-items: stretch; }
.u-wrap { flex-wrap: wrap; }
.u-flex-1 { flex: 1; min-width: 0; }
.u-flex-shrink-0 { flex-shrink: 0; }

/* Grid helpers */
.u-grid { display: grid; }
.u-grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
.u-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.u-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); }

/* Gaps */
.u-gap-xs { gap: var(--space-xs); }
.u-gap-sm { gap: var(--space-sm); }
.u-gap-md { gap: var(--space-md); }
.u-gap-lg { gap: var(--space-lg); }
.u-gap-xl { gap: var(--space-xl); }

/* Margins */
.u-mt-xs { margin-top: var(--space-xs); }
.u-mt-sm { margin-top: var(--space-sm); }
.u-mt-md { margin-top: var(--space-md); }
.u-mt-lg { margin-top: var(--space-lg); }
.u-mt-xl { margin-top: var(--space-xl); }
.u-mb-xs { margin-bottom: var(--space-xs); }
.u-mb-sm { margin-bottom: var(--space-sm); }
.u-mb-md { margin-bottom: var(--space-md); }
.u-mb-lg { margin-bottom: var(--space-lg); }
.u-mb-xl { margin-bottom: var(--space-xl); }

/* Text helpers */
.u-text-right { text-align: right; }
.u-text-center { text-align: center; }
.u-text-sm { font-size: var(--font-sm); }
.u-text-base { font-size: var(--font-base); }
.u-text-xs { font-size: var(--font-xs); }
.u-text-secondary { color: var(--text-secondary); }
.u-text-success { color: var(--success); }
.u-text-danger { color: var(--danger); }
.u-text-warning { color: var(--warning); }
.u-text-primary { color: var(--primary); }
.u-text-bold { font-weight: 700; }
.u-text-semibold { font-weight: 600; }
.u-text-nowrap { white-space: nowrap; }
.u-text-mono { font-family: var(--font-mono); }
.u-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Width */
.u-w-full { width: 100%; }
.u-min-w-0 { min-width: 0; }

/* Visibility */
.u-hidden { display: none; }

/* ============================================================
   2. CSS Reset & Base Styles
   ============================================================ */

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

html {
    font-size: var(--font-md);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--font-base);
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--background);
}

/* ============================================================
   3. Typography (section 2.3)
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    color: var(--text-primary);
}

h1 {
    font-size: var(--font-2xl);
    font-weight: 700;
}

h2 {
    font-size: var(--font-xl);
    font-weight: 600;
}

h3 {
    font-size: var(--font-md);
    font-weight: 600;
}

p {
    margin-bottom: var(--space-md);
}

/* --- Links --- */
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 150ms ease;
}

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

a:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Foco visivel global em elementos interativos (a11y padrao) */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[role="button"]:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
/* Inputs ja tem box-shadow focus proprio — nao duplicar outline */
.form-input:focus-visible,
.searchable-select__trigger:focus-visible {
    outline: none;
}

/* --- Labels (section 2.3) --- */
label {
    font-size: var(--font-base);
    font-weight: 500;
    color: var(--text-secondary);
}

/* --- Small / secondary text --- */
small,
.text-secondary {
    color: var(--text-secondary);
    font-size: var(--font-base);
}

/* ============================================================
   3b. Skip Navigation (Accessibility)
   ============================================================ */

.skip-nav {
    position: absolute;
    top: -100%;
    left: var(--space-md);
    z-index: 9999;
    padding: var(--space-sm) var(--space-md);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: var(--font-base);
    border-radius: var(--radius-card);
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-nav:focus {
    top: var(--space-md);
}

/* ============================================================
   4. Money Display Utilities (section 2.3 / 2.6)
   ============================================================ */

.money-value {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: var(--font-base);
    white-space: nowrap;
}

.money-positive {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: var(--font-base);
    color: var(--success);
    white-space: nowrap;
}

.money-negative {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: var(--font-base);
    color: var(--danger);
    white-space: nowrap;
}

/* ============================================================
   5. Utility Classes
   ============================================================ */

.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;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }

.mt-xs  { margin-top: var(--space-xs); }
.mt-sm  { margin-top: var(--space-sm); }
.mt-md  { margin-top: var(--space-md); }
.mt-lg  { margin-top: var(--space-lg); }
.mt-xl  { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-xs  { margin-bottom: var(--space-xs); }
.mb-sm  { margin-bottom: var(--space-sm); }
.mb-md  { margin-bottom: var(--space-md); }
.mb-lg  { margin-bottom: var(--space-lg); }
.mb-xl  { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

.gap-xs  { gap: var(--space-xs); }
.gap-sm  { gap: var(--space-sm); }
.gap-md  { gap: var(--space-md); }
.gap-lg  { gap: var(--space-lg); }
