# Overview

import { Callout } from "fumadocs-ui/components/callout";
import { Accordion, Accordions } from "fumadocs-ui/components/accordion";
import { Step, Steps } from "fumadocs-ui/components/steps";
import { Tabs, Tab } from "fumadocs-ui/components/tabs";
import {
  Badge,
  Card,
  CardContent,
  CardHeader,
  CardTitle,
} from "@pycolors/ui";
import {
  ArrowRight,
  CheckCircle,
  Layers3,
  Layers,
  Palette,
  PenLine,
  Sparkles,
  TriangleAlert,
} from "lucide-react";
import { PreferAvoid } from '@/components/docs/prefer-avoid';
import { DocsLinks } from "@/components/docs/docs-links";
import { DocsFeatureGrid } from "@/components/docs/docs-feature-grid";

<div className="flex flex-wrap items-center gap-2">
  <Badge variant="outline">
    Design System
  </Badge>

  <Badge>
    Foundations
  </Badge>
</div>

## Design consistent products with PyColors

PyColors UI is not a collection of isolated components. It is a **system of visual decisions** designed to keep product interfaces consistent as they grow.

The design system defines the rules behind:

* reusable components
* product dashboards
* documentation pages
* settings and billing surfaces
* marketing sections
* future SaaS templates and starters

The goal is simple: components should stay small because the foundation carries the complexity.

<Callout title="Why this matters">
  Most product inconsistency does not come from one bad component. It comes from many small local decisions that slowly drift away from each other. PyColors prevents that by moving visual decisions into shared roles, tokens, and rules.
</Callout>

## What you’ll understand

<DocsFeatureGrid
  columns={3}
  tone="platform"
  items={[
  {
    title: 'System layers',
    description:
      'Understand how tokens, colors, typography, and components work together instead of competing locally.',
    icon: Layers,
  },
{
    title: 'Semantic roles',
    description: (
      <>
        Use meaning-driven utilities such as <code>bg-card</code>,{' '}
        <code>text-muted-foreground</code>, and{' '}
        <code>border-border</code>.
      </>
    ),
    icon: Palette,
  },
  {
    title: 'Product consistency',
    description:
      'Keep PyColors readable, premium, and trustworthy across docs, dashboards, and commercial pages.',
    icon: Sparkles,
  },
]}
/>

## Steps

<Steps>
  <Step>
    ### Start with roles, not raw values

    Components should consume semantic roles instead of hardcoded visual values.

    ```tsx title="components/product-card.tsx"
    export function ProductCard() {
      return (
        <article className="rounded-2xl border border-border bg-card p-6 text-card-foreground">
          <p className="text-sm text-muted-foreground">
            Production-shaped SaaS foundation
          </p>
          <h2 className="mt-2 text-xl font-semibold tracking-tight">
            Starter Pro
          </h2>
        </article>
      );
    }
    ```

    This keeps the component stable when the theme evolves. The component does not need to know the exact color, radius, or contrast value. It only needs to know the role it should express.

    | Use                     | Avoid                   |
    | ----------------------- | ----------------------- |
    | `bg-card`               | hardcoded hex values    |
    | `text-muted-foreground` | one-off opacity values  |
    | `border-border`         | local border colors     |
    | shared radius tokens    | arbitrary corner values |
  </Step>

  <Step>
    ### Keep one source of truth

    Global visual decisions should be made once, then reused everywhere.

    That includes:

    * radius
    * shadows
    * color roles
    * typography hierarchy
    * focus states
    * product surface density

    ```css title="styles/globals.css"
    @theme inline {
      --color-background: var(--background);
      --color-foreground: var(--foreground);
      --color-card: var(--card);
      --color-card-foreground: var(--card-foreground);
      --color-primary: var(--primary);
      --color-border: var(--border);
    }
    ```

    <Callout type="info" title="Implementation note">
      A design system becomes valuable when changing one token updates many surfaces coherently. That is the difference between a theme and a collection of local styles.
    </Callout>
  </Step>

  <Step>
    ### Build small primitives on strong foundations

    PyColors primitives stay intentionally small because the system underneath already defines the visual behavior.

    <Tabs items={["Mental model", "Example"]}>
      <Tab value="Mental model">
        <div className="rounded-2xl border border-border/60 bg-card p-6">
          <div className="grid gap-4 md:grid-cols-3">
            <div>
              <div className="text-sm font-medium text-foreground">
                Tokens
              </div>

              <div className="mt-2 text-sm leading-6 text-muted-foreground">
                Define geometry, elevation, spacing direction, and future visual scales.
              </div>
            </div>

            <div>
              <div className="text-sm font-medium text-foreground">
                Roles
              </div>

              <div className="mt-2 text-sm leading-6 text-muted-foreground">
                Define meaning for surfaces, text, borders, states, and actions.
              </div>
            </div>

            <div>
              <div className="text-sm font-medium text-foreground">
                Components
              </div>

              <div className="mt-2 text-sm leading-6 text-muted-foreground">
                Compose roles into reusable UI primitives and product patterns.
              </div>
            </div>
          </div>
        </div>
      </Tab>

      <Tab value="Example">
        ```tsx title="components/settings-panel.tsx"
        export function SettingsPanel() {
          return (
            <section className="rounded-2xl border border-border bg-card p-6">
              <h2 className="text-lg font-semibold tracking-tight">
                Workspace settings
              </h2>
              <p className="mt-2 text-sm leading-6 text-muted-foreground">
                Manage product configuration from a consistent surface.
              </p>
            </section>
          );
        }
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

### System layers

PyColors is organized as a layered system. Each layer has a clear responsibility and should not replace the layer below it.

| Layer            | Responsibility          | Example                                   |
| ---------------- | ----------------------- | ----------------------------------------- |
| Tokens           | Atomic visual decisions | radius, shadows, future scales            |
| Colors           | Semantic color roles    | `background`, `card`, `primary`, `muted`  |
| Typography       | Readable hierarchy      | headings, body text, labels, metadata     |
| UI components    | Reusable primitives     | buttons, cards, inputs, dialogs           |
| Product patterns | Composed flows          | dashboards, settings, billing, onboarding |

<Callout title="Why this matters">
  When every layer has a clear responsibility, components become easier to reason about. You know where to change the system instead of patching the symptom locally.
</Callout>

## Decision guide

Use the design system when:

* a visual decision appears in more than one place
* a component needs to support light and dark mode
* a page must feel coherent with the rest of the product
* a pattern will be reused in docs, starters, or commercial pages
* the decision affects trust, readability, or product polish

Avoid local overrides when:

* the value is purely decorative
* the same exception already exists elsewhere
* the change weakens semantic meaning
* the override makes theming harder
* the code becomes harder to maintain than the system rule

<PreferAvoid
  prefer={[
  'semantic roles over raw values',
  'tokens for repeated visual decisions',
  'small primitives with predictable behavior',
  'centralized color and typography rules',
  'documentation that explains system intent',
]}
  avoid={[
  'hardcoded colors inside reusable components',
  'one-off radius and shadow values',
  'local typography scales per page',
  'using chart colors as interface states',
  'duplicating visual decisions in product areas',
]}
/>

## Reading path

Follow this order to understand the system from the foundation to implementation.

<DocsLinks
  variant="steps"
  tone="platform"
  items={[
  {
    title: 'Tokens',
    href: '/docs/design-system/tokens',
    description:
      'Start with the atomic decisions that power the visual system.',
  },
  {
    title: 'Radius',
    href: '/docs/design-system/tokens/radius',
    description:
      'Learn how corner geometry keeps surfaces and controls consistent.',
  },
  {
    title: 'Shadows',
    href: '/docs/design-system/tokens/shadows',
    description:
      'Understand elevation rules for calm, predictable depth.',
  },
  {
    title: 'Colors',
    href: '/docs/design-system/colors',
    description:
      'Use semantic roles for surfaces, text, states, and theming.',
  },
  {
    title: 'Typography',
    href: '/docs/design-system/typography',
    description:
      'Define hierarchy, rhythm, labels, and readable product structure.',
  },
]}
/>

### Where this fits

PyColors is structured in product layers:

| Product layer | Purpose                                                                     |
| ------------- | --------------------------------------------------------------------------- |
| Design System | Rules, tokens, roles, and visual foundations                                |
| UI Components | Reusable primitives built on top of the system                              |
| Patterns      | Composition guidance for real product surfaces                              |
| Starter Free  | Product-shaped UX for validation                                            |
| Starter Pro   | Production-shaped SaaS foundation with auth, billing, backend, and delivery |

The design system is the deepest layer in that stack. It protects consistency before product complexity increases.

<Callout title="Ready to turn the system into a launch foundation?">
  Continue from visual foundations to product implementation with Starter Pro. → `/docs/starter-pro`
</Callout>

## Common questions

<Accordions type="single">
  <Accordion title="Is PyColors UI only a component library?">
    No. The components are one visible layer. The design system underneath defines the semantic roles, visual rules, and consistency model that make the components scalable.
  </Accordion>

  <Accordion title="Should every visual decision become a token?">
    No. Only repeated, meaningful, or system-level decisions should become tokens. A token is useful when it improves consistency, theming, or reuse.
  </Accordion>

  <Accordion title="Can I customize the system?">
    Yes. Customize the token layer and keep components consuming semantic roles. That gives you flexibility without losing structural consistency.
  </Accordion>
</Accordions>

## Next steps

<DocsLinks
  variant="grid"
  tone="platform"
  items={[
  {
    title: 'Tokens',
    href: '/docs/design-system/tokens',
    description:
      'Start with the atomic visual decisions behind PyColors UI.',
    icon: Layers3,
  },
  {
    title: 'Colors',
    href: '/docs/design-system/colors',
    description:
      'Learn how semantic colors keep surfaces, text, and states coherent.',
    icon: Palette,
  },
  {
    title: 'Typography',
    href: '/docs/design-system/typography',
    description:
      'Review hierarchy, labels, density, and readable product copy.',
    icon: PenLine,
  },
  {
    title: 'UI Components',
    href: '/docs/ui',
    description:
      'Move from foundations to reusable primitives built with PyColors UI.',
    icon: Sparkles,
  },
]}
/>