/* ============================================================
   CRM A1 / FaturAI - Design Tokens (Fase 1)
   ============================================================
   Define a fundação visual do sistema. Tokens NÃO aplicados a
   componentes ainda — Fases 2-4 fazem o consumo progressivo.

   Mudanças visuais devem alterar APENAS estes valores.
   ============================================================ */

/* -----------------------------------------------
   1. BRAND — Laranja A1 (degradê master)
   ----------------------------------------------- */
:root {
    --brand-400: #ff4d1e;   /* hover claro / topo do gradiente */
    --brand-500: #f73400;   /* primária */
    --brand-600: #cb2b00;   /* pressed / base do gradiente */
    --brand-gradient: linear-gradient(180deg, var(--brand-400) 0%, var(--brand-500) 50%, var(--brand-600) 100%);
    --brand-gradient-soft: linear-gradient(180deg, rgba(247, 52, 0, 0.04) 0%, rgba(247, 52, 0, 0.10) 100%);

    /* Tints (uso em backgrounds sutis, badges, hover de linha) */
    --brand-50:  #fff4f0;
    --brand-100: #ffe2d6;
    --brand-200: #ffc4ad;
    --brand-300: #ff8b66;

    /* Foco / outline acessível */
    --brand-ring: rgba(247, 52, 0, 0.35);

    /* -----------------------------------------------
       2. SEMÂNTICAS (idênticas em light e dark)
       ----------------------------------------------- */
    --success-500: #10b981;
    --success-50:  #ecfdf5;
    --warning-500: #f59e0b;
    --warning-50:  #fffbeb;
    --danger-500:  #ef4444;
    --danger-50:   #fef2f2;
    --info-500:    #3b82f6;
    --info-50:     #eff6ff;

    /* -----------------------------------------------
       3. TIPOGRAFIA
       ----------------------------------------------- */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-heading: 'Saira', 'Inter', sans-serif;
    --font-display: 'Saira Condensed', 'Saira', 'Inter', sans-serif;
    --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;

    --fs-xs:   0.75rem;   /* 12px */
    --fs-sm:   0.875rem;  /* 14px */
    --fs-base: 1rem;      /* 16px */
    --fs-lg:   1.125rem;  /* 18px */
    --fs-xl:   1.25rem;   /* 20px */
    --fs-2xl:  1.5rem;    /* 24px */
    --fs-3xl:  1.875rem;  /* 30px */
    --fs-4xl:  2.25rem;   /* 36px */
    --fs-5xl:  3rem;      /* 48px */

    --fw-regular:  400;
    --fw-medium:   500;
    --fw-semibold: 600;
    --fw-bold:     700;
    --fw-black:    900;

    --lh-tight:   1.2;
    --lh-snug:    1.4;
    --lh-normal:  1.5;
    --lh-relaxed: 1.65;

    --ls-tight:   -0.02em;
    --ls-normal:  0;
    --ls-wide:    0.02em;
    --ls-wider:   0.05em;

    /* -----------------------------------------------
       4. ESPAÇAMENTO (escala 4px)
       ----------------------------------------------- */
    --space-0:  0;
    --space-1:  0.25rem;   /* 4 */
    --space-2:  0.5rem;    /* 8 */
    --space-3:  0.75rem;   /* 12 */
    --space-4:  1rem;      /* 16 */
    --space-5:  1.25rem;   /* 20 */
    --space-6:  1.5rem;    /* 24 */
    --space-8:  2rem;      /* 32 */
    --space-10: 2.5rem;    /* 40 */
    --space-12: 3rem;      /* 48 */
    --space-16: 4rem;      /* 64 */
    --space-20: 5rem;      /* 80 */

    /* -----------------------------------------------
       5. RAIO
       ----------------------------------------------- */
    --radius-sm:   0.25rem;  /* 4 */
    --radius-md:   0.5rem;   /* 8 */
    --radius-lg:   0.75rem;  /* 12 */
    --radius-xl:   1rem;     /* 16 */
    --radius-2xl:  1.5rem;   /* 24 */
    --radius-full: 9999px;

    /* -----------------------------------------------
       6. LAYOUT
       ----------------------------------------------- */
    --sidebar-w:  240px;
    --navbar-h:   56px;
    --container-max: 1440px;

    /* -----------------------------------------------
       7. Z-INDEX
       ----------------------------------------------- */
    --z-base:     1;
    --z-sticky:   100;
    --z-sidebar:  200;
    --z-navbar:   300;
    --z-dropdown: 400;
    --z-modal:    1000;
    --z-toast:    1100;

    /* -----------------------------------------------
       8. TRANSITIONS
       ----------------------------------------------- */
    --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 200ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 320ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   9. TEMA CLARO (default)
   ============================================================ */
:root,
[data-theme="light"] {
    color-scheme: light;
    --bg-base:      #f1f1f3;
    --bg-surface:   #ffffff;
    --bg-elevated:  #ffffff;
    --bg-overlay:   rgba(10, 10, 12, 0.5);
    --bg-hover:     rgba(10, 10, 12, 0.04);
    --bg-active:    rgba(10, 10, 12, 0.08);

    --border-subtle: #ececef;
    --border-base:   #dcdce0;
    --border-strong: #c8c8cd;

    --text-primary:   #0a0a0c;
    --text-secondary: #52525b;
    --text-tertiary:  #71717a;
    --text-disabled:  #a1a1aa;
    --text-inverse:   #fafafa;
    --text-on-brand:  #ffffff;

    --shadow-xs: 0 1px 2px 0 rgba(10, 10, 12, 0.04);
    --shadow-sm: 0 1px 3px 0 rgba(10, 10, 12, 0.06), 0 1px 2px -1px rgba(10, 10, 12, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(10, 10, 12, 0.06), 0 2px 4px -2px rgba(10, 10, 12, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(10, 10, 12, 0.08), 0 4px 6px -4px rgba(10, 10, 12, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(10, 10, 12, 0.10), 0 8px 10px -6px rgba(10, 10, 12, 0.04);
    --shadow-inner: inset 0 2px 4px 0 rgba(10, 10, 12, 0.04);
}

/* ============================================================
   10. TEMA ESCURO
   ============================================================ */
[data-theme="dark"] {
    color-scheme: dark;
    --bg-base:      #18181b;
    --bg-surface:   #1f1f23;
    --bg-elevated:  #27272a;
    --bg-overlay:   rgba(0, 0, 0, 0.6);
    --bg-hover:     rgba(255, 255, 255, 0.05);
    --bg-active:    rgba(255, 255, 255, 0.08);

    --border-subtle: #27272a;
    --border-base:   #3f3f46;
    --border-strong: #52525b;

    --text-primary:   #fafafa;
    --text-secondary: #a1a1aa;
    --text-tertiary:  #71717a;
    --text-disabled:  #52525b;
    --text-inverse:   #18181b;
    --text-on-brand:  #ffffff;

    --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-inner: inset 0 2px 4px 0 rgba(0, 0, 0, 0.3);
}

/* ============================================================
   11. UTILITÁRIOS DE TEMA — só impacto visual quando aplicado
   ============================================================
   Estes utilitários são opt-in (precisam ser aplicados em
   componentes específicos). Não afetam o look atual em Fase 1.
   ============================================================ */

/* Tipografia opt-in (sem aplicar globalmente em Fase 1) */
.font-display { font-family: var(--font-display); letter-spacing: var(--ls-tight); }
.font-body    { font-family: var(--font-body); }
.font-mono    { font-family: var(--font-mono); }

/* Backgrounds com tokens de tema */
.bg-base      { background-color: var(--bg-base); }
.bg-surface   { background-color: var(--bg-surface); }
.bg-elevated  { background-color: var(--bg-elevated); }
.bg-brand     { background-color: var(--brand-500); color: var(--text-on-brand); }
.bg-brand-gradient { background: var(--brand-gradient); color: var(--text-on-brand); }

/* Texto */
.text-primary   { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-brand     { color: var(--brand-500); }

/* Bordas */
.border-base    { border-color: var(--border-base) !important; }
.border-subtle  { border-color: var(--border-subtle) !important; }

/* Smooth transitions quando dark/light alterna */
html, body, .card, .modal-content, .dropdown-menu, .navbar, .sidebar {
    transition: background-color var(--transition-base),
                border-color var(--transition-base),
                color var(--transition-base);
}


/* -----------------------------------------------
   ALIASES DE COMPATIBILIDADE (Onda 1)
   Tokens legados usados em ~400 lugares que nao existiam.
   Mapeiam pros oficiais e seguem claro/escuro via var() (resolve no uso).
   ----------------------------------------------- */
:root {
    --primary-color:   var(--brand-500);
    --primary:         var(--brand-500);
    --secondary-color: var(--brand-600);
    --accent:          var(--brand-500);
    --border-color:    var(--border-base);
    --text-muted:      var(--text-tertiary);
    --bg-card:         var(--bg-surface);
}

/* Aliases Onda 3: vars usadas em paginas mas nunca definidas (dashboard.php) */
:root {
    --text-base:   var(--text-primary);
    --text-strong: var(--text-primary);
}
