# Component Snippets
## PharmData Design System - Componentes Prontos para Uso

> **Copiar e colar**: Todos os snippets abaixo são completos e prontos para uso

---

## Índice

1. [Buttons](#buttons)
2. [Cards](#cards)
3. [Forms](#forms)
4. [Tables](#tables)
5. [Badges & Drops](#badges--drops)
6. [Alerts](#alerts)
7. [Layout](#layout)
8. [Navigation](#navigation)

---

## Buttons

### Button Primary

**Visual**: Botão sólido teal para ações principais

```html
<button class="inline-flex items-center gap-2 px-4 py-2 bg-teal-intense text-white rounded-lg font-medium hover:bg-emerald-abyss transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-teal-intense focus:ring-offset-2">
  <i class="fas fa-save"></i>
  Salvar Validação
</button>
```

**Acessibilidade**:
- Focus ring com 2px offset
- Color contrast ratio: 4.5:1 (WCAG AA)
- Support para navegação via teclado

---

### Button Secondary

**Visual**: Botão outline para ações secundárias

```html
<button class="inline-flex items-center gap-2 px-4 py-2 bg-transparent text-graphite-depth border border-soft-arctic rounded-lg font-medium hover:bg-arctic-mist transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-teal-intense focus:ring-offset-2">
  <i class="fas fa-times"></i>
  Cancelar
</button>
```

---

### Button Ghost / Text Only

**Visual**: Botão texto para ações terciárias

```html
<button class="inline-flex items-center gap-2 px-4 py-2 bg-transparent text-teal-intense rounded-lg font-medium hover:bg-teal-intense/5 transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-teal-intense focus:ring-offset-2">
  <i class="fas fa-edit"></i>
  Editar
</button>
```

---

### Button Icon Only

**Visual**: Botão circular apenas com ícone

```html
<button class="w-10 h-10 flex items-center justify-center bg-transparent text-graphite-depth rounded-full hover:bg-arctic-mist transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-teal-intense focus:ring-offset-2" aria-label="Mais opções">
  <i class="fas fa-ellipsis-v"></i>
</button>
```

**Acessibilidade**:
- `aria-label` obrigatório para screen readers
- Tamanho mínimo de 40x40px (WCAG 2.5.5)

---

### Button Group

**Visual**: Grupo de botões relacionados

```html
<div class="inline-flex rounded-lg border border-soft-arctic overflow-hidden">
  <button class="px-4 py-2 bg-white text-graphite-depth hover:bg-arctic-mist border-r border-soft-arctic transition-colors">
    <i class="fas fa-align-left"></i>
  </button>
  <button class="px-4 py-2 bg-white text-graphite-depth hover:bg-arctic-mist border-r border-soft-arctic transition-colors">
    <i class="fas fa-align-center"></i>
  </button>
  <button class="px-4 py-2 bg-teal-intense text-white" aria-current="true">
    <i class="fas fa-align-right"></i>
  </button>
</div>
```

---

### Button Loading State

**Visual**: Botão com spinner durante carregamento

```html
<button class="inline-flex items-center gap-2 px-4 py-2 bg-teal-intense text-white rounded-lg font-medium opacity-75 cursor-not-allowed" disabled>
  <svg class="animate-spin h-4 w-4" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
    <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
    <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
  </svg>
  Salvando...
</button>
```

---

## Cards

### Basic Card

**Visual**: Card branco com borda sutil

```html
<div class="bg-white rounded-lg border border-soft-arctic p-6 hover:shadow-md transition-shadow duration-300">
  <h3 class="text-h3 mb-2">Paracetamol</h3>
  <p class="text-body text-soft-steel mb-4">
    Substância ativa analgésica e antipirética
  </p>
  <div class="flex gap-2">
    <span class="token-sub">SUB-082615</span>
    <span class="token-approved">Approved</span>
  </div>
</div>
```

---

### Card with Header

**Visual**: Card com cabeçalho destacado

```html
<div class="bg-white rounded-lg border border-soft-arctic overflow-hidden hover:shadow-md transition-shadow duration-300">
  <div class="bg-gradient-to-r from-emerald-abyss to-teal-intense px-6 py-4">
    <h3 class="text-lg font-semibold text-white">Substância #SUB-082615</h3>
  </div>
  <div class="p-6">
    <div class="grid grid-cols-2 gap-4">
      <div>
        <p class="text-caption text-soft-steel mb-1">Nome</p>
        <p class="text-body font-medium">Paracetamol</p>
      </div>
      <div>
        <p class="text-caption text-soft-steel mb-1">Fórmula</p>
        <p class="text-body font-mono">C₈H₉NO₂</p>
      </div>
    </div>
  </div>
</div>
```

---

### Card with Action

**Visual**: Card clicável com ação

```html
<a href="/substances/082615" class="block bg-white rounded-lg border border-soft-arctic p-6 hover:shadow-lg hover:border-teal-intense transition-all duration-300 group">
  <div class="flex items-start justify-between mb-3">
    <h3 class="text-h3 group-hover:text-teal-intense transition-colors">Paracetamol</h3>
    <i class="fas fa-arrow-right text-teal-intense opacity-0 group-hover:opacity-100 transition-opacity"></i>
  </div>
  <p class="text-body text-soft-steel mb-4">C₈H₉NO₂</p>
  <div class="flex gap-2">
    <span class="token-complete">Complete</span>
    <span class="token-approved">Approved</span>
  </div>
</a>
```

**Acessibilidade**:
- Elemento `<a>` semântico para navegação
- Focus state visível
- Hover state claro

---

### Property Grid Card

**Visual**: Card para exibir propriedades em grade

```html
<div class="bg-white rounded-lg border border-soft-arctic p-6">
  <h3 class="text-h3 mb-4 pb-2 border-b-2 border-teal-intense">Propriedades Físico-Químicas</h3>

  <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
    <div class="flex justify-between py-2 border-b border-soft-arctic/50">
      <span class="text-label text-soft-steel">Massa Molecular</span>
      <span class="text-body font-medium">151.17 g/mol</span>
    </div>

    <div class="flex justify-between py-2 border-b border-soft-arctic/50">
      <span class="text-label text-soft-steel">Ponto de Fusão</span>
      <span class="text-body font-medium">168-172°C</span>
    </div>

    <div class="flex justify-between py-2 border-b border-soft-arctic/50">
      <span class="text-label text-soft-steel">Solubilidade</span>
      <span class="text-body font-medium">14 g/L (água, 25°C)</span>
    </div>

    <div class="flex justify-between py-2 border-b border-soft-arctic/50">
      <span class="text-label text-soft-steel">LogP</span>
      <span class="text-body font-medium">0.46</span>
    </div>
  </div>
</div>
```

---

## Forms

### Input Text

**Visual**: Campo de texto padrão

```html
<div class="space-y-2">
  <label for="substance-name" class="block text-label text-graphite-depth">
    Nome da Substância
    <span class="text-error">*</span>
  </label>
  <input
    type="text"
    id="substance-name"
    name="substance_name"
    class="w-full px-3 py-2 border border-soft-arctic rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-intense focus:border-transparent transition-all"
    placeholder="Ex: Paracetamol"
    required
    aria-required="true"
  />
  <p class="text-caption text-soft-steel">Nome oficial da substância conforme SNOMED CT</p>
</div>
```

**Acessibilidade**:
- `<label>` associado via `for`/`id`
- `aria-required` para campos obrigatórios
- Texto de ajuda com `text-caption`

---

### Select / Dropdown

**Visual**: Seletor dropdown

```html
<div class="space-y-2">
  <label for="status" class="block text-label text-graphite-depth">
    Status de Validação
  </label>
  <select
    id="status"
    name="status"
    class="w-full px-3 py-2 border border-soft-arctic rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-intense focus:border-transparent bg-white transition-all"
  >
    <option value="">Selecione...</option>
    <option value="draft">Draft</option>
    <option value="review">In Review</option>
    <option value="approved">Approved</option>
  </select>
</div>
```

---

### Textarea

**Visual**: Campo de texto multilinha

```html
<div class="space-y-2">
  <label for="notes" class="block text-label text-graphite-depth">
    Notas de Curadoria
  </label>
  <textarea
    id="notes"
    name="notes"
    rows="4"
    class="w-full px-3 py-2 border border-soft-arctic rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-intense focus:border-transparent transition-all resize-y"
    placeholder="Adicione observações sobre a validação..."
  ></textarea>
  <p class="text-caption text-soft-steel">Estas notas serão auditadas e rastreadas</p>
</div>
```

---

### Checkbox

**Visual**: Checkbox com label

```html
<div class="flex items-start gap-3">
  <input
    type="checkbox"
    id="confirmed"
    name="confirmed"
    class="mt-1 w-4 h-4 text-teal-intense border-soft-arctic rounded focus:ring-2 focus:ring-teal-intense focus:ring-offset-2"
  />
  <div>
    <label for="confirmed" class="block text-label text-graphite-depth cursor-pointer">
      Confirmo que todos os dados foram verificados
    </label>
    <p class="text-caption text-soft-steel mt-1">
      Esta validação impactará prescrições médicas
    </p>
  </div>
</div>
```

---

### Radio Group

**Visual**: Grupo de radio buttons

```html
<fieldset class="space-y-3">
  <legend class="text-label text-graphite-depth mb-3">Nível de Confiança</legend>

  <div class="flex items-start gap-3">
    <input
      type="radio"
      id="confidence-high"
      name="confidence"
      value="high"
      class="mt-1 w-4 h-4 text-teal-intense border-soft-arctic focus:ring-2 focus:ring-teal-intense focus:ring-offset-2"
    />
    <div>
      <label for="confidence-high" class="block text-body font-medium cursor-pointer">
        Validação Completa
      </label>
      <p class="text-caption text-soft-steel">Dados verificados em fontes primárias</p>
    </div>
  </div>

  <div class="flex items-start gap-3">
    <input
      type="radio"
      id="confidence-medium"
      name="confidence"
      value="medium"
      class="mt-1 w-4 h-4 text-teal-intense border-soft-arctic focus:ring-2 focus:ring-teal-intense focus:ring-offset-2"
    />
    <div>
      <label for="confidence-medium" class="block text-body font-medium cursor-pointer">
        Validação Parcial
      </label>
      <p class="text-caption text-soft-steel">Campos principais verificados</p>
    </div>
  </div>
</fieldset>
```

---

### Form Complete Example

**Visual**: Formulário completo com Progressive Disclosure

```html
<form class="space-y-6 bg-white rounded-lg border border-soft-arctic p-6">

  <!-- Layer 1: Essenciais -->
  <section>
    <h3 class="text-h3 mb-4 pb-2 border-b-2 border-teal-intense">Identificação</h3>

    <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
      <div class="space-y-2">
        <label for="name" class="block text-label text-graphite-depth">
          Nome <span class="text-error">*</span>
        </label>
        <input
          type="text"
          id="name"
          name="name"
          class="w-full px-3 py-2 border border-soft-arctic rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-intense focus:border-transparent"
          required
        />
      </div>

      <div class="space-y-2">
        <label for="formula" class="block text-label text-graphite-depth">
          Fórmula Molecular
        </label>
        <input
          type="text"
          id="formula"
          name="formula"
          class="w-full px-3 py-2 border border-soft-arctic rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-intense focus:border-transparent font-mono"
          placeholder="Ex: C₈H₉NO₂"
        />
      </div>
    </div>
  </section>

  <!-- Layer 2: Additional (Collapsible) -->
  <details class="group" open>
    <summary class="cursor-pointer text-label text-teal-intense hover:text-emerald-abyss flex items-center gap-2 mb-4">
      <i class="fas fa-chevron-right group-open:rotate-90 transition-transform"></i>
      Campos Adicionais
    </summary>

    <div class="pl-6 space-y-4">
      <div class="space-y-2">
        <label for="cas" class="block text-label text-graphite-depth">
          CAS Number
        </label>
        <input
          type="text"
          id="cas"
          name="cas"
          class="w-full px-3 py-2 border border-soft-arctic rounded-lg focus:outline-none focus:ring-2 focus:ring-teal-intense focus:border-transparent"
          placeholder="Ex: 103-90-2"
        />
      </div>
    </div>
  </details>

  <!-- Actions -->
  <div class="flex gap-3 pt-4 border-t border-soft-arctic">
    <button type="submit" class="inline-flex items-center gap-2 px-4 py-2 bg-teal-intense text-white rounded-lg font-medium hover:bg-emerald-abyss transition-all">
      <i class="fas fa-save"></i>
      Salvar Validação
    </button>
    <button type="button" class="inline-flex items-center gap-2 px-4 py-2 bg-transparent text-graphite-depth border border-soft-arctic rounded-lg font-medium hover:bg-arctic-mist transition-all">
      <i class="fas fa-times"></i>
      Cancelar
    </button>
  </div>
</form>
```

---

## Tables

### Simple Table

**Visual**: Tabela responsiva básica

```html
<div class="bg-white rounded-lg border border-soft-arctic overflow-hidden">
  <table class="w-full">
    <thead class="bg-arctic-mist">
      <tr>
        <th class="px-6 py-3 text-left text-label text-graphite-depth font-semibold">ID</th>
        <th class="px-6 py-3 text-left text-label text-graphite-depth font-semibold">Nome</th>
        <th class="px-6 py-3 text-left text-label text-graphite-depth font-semibold">Status</th>
        <th class="px-6 py-3 text-left text-label text-graphite-depth font-semibold">Qualidade</th>
      </tr>
    </thead>
    <tbody class="divide-y divide-soft-arctic">
      <tr class="hover:bg-cloud transition-colors">
        <td class="px-6 py-4">
          <span class="token-sub">SUB-082615</span>
        </td>
        <td class="px-6 py-4 text-body">Paracetamol</td>
        <td class="px-6 py-4">
          <span class="token-approved">Approved</span>
        </td>
        <td class="px-6 py-4">
          <span class="token-complete">Complete</span>
        </td>
      </tr>
      <tr class="hover:bg-cloud transition-colors">
        <td class="px-6 py-4">
          <span class="token-sub">SUB-123456</span>
        </td>
        <td class="px-6 py-4 text-body">Ibuprofeno</td>
        <td class="px-6 py-4">
          <span class="token-review">In Review</span>
        </td>
        <td class="px-6 py-4">
          <span class="token-partial">Partial</span>
        </td>
      </tr>
    </tbody>
  </table>
</div>
```

---

### Table with Actions

**Visual**: Tabela com botões de ação

```html
<div class="bg-white rounded-lg border border-soft-arctic overflow-hidden">
  <table class="w-full">
    <thead class="bg-arctic-mist">
      <tr>
        <th class="px-6 py-3 text-left text-label">Substância</th>
        <th class="px-6 py-3 text-left text-label">Status</th>
        <th class="px-6 py-3 text-right text-label">Ações</th>
      </tr>
    </thead>
    <tbody class="divide-y divide-soft-arctic">
      <tr class="hover:bg-cloud transition-colors">
        <td class="px-6 py-4">
          <div>
            <p class="text-body font-medium">Paracetamol</p>
            <p class="text-caption text-soft-steel">C₈H₉NO₂</p>
          </div>
        </td>
        <td class="px-6 py-4">
          <span class="token-approved">Approved</span>
        </td>
        <td class="px-6 py-4">
          <div class="flex justify-end gap-2">
            <button class="w-8 h-8 flex items-center justify-center text-teal-intense hover:bg-teal-intense/10 rounded transition-all" title="Visualizar">
              <i class="fas fa-eye"></i>
            </button>
            <button class="w-8 h-8 flex items-center justify-center text-graphite-depth hover:bg-arctic-mist rounded transition-all" title="Editar">
              <i class="fas fa-edit"></i>
            </button>
          </div>
        </td>
      </tr>
    </tbody>
  </table>
</div>
```

---

## Badges & Drops

Ver `pharmdata-tokens.css` para classes completas. Aqui estão os snippets de uso:

```html
<!-- Pharmaceutical Categories -->
<span class="token-dec">DEC-123456</span>
<span class="token-sub">SUB-082615</span>
<span class="token-lab">BAYER</span>
<span class="token-fofa">Comprimido</span>

<!-- Status -->
<span class="token-draft">Draft</span>
<span class="token-review">In Review</span>
<span class="token-approved">Approved</span>

<!-- Quality -->
<span class="token-complete">Complete</span>
<span class="token-partial">Partial</span>
<span class="token-missing">Missing</span>

<!-- Sources -->
<span class="token-spor">SPOR/EMA</span>
<span class="token-anvisa">ANVISA</span>
```

---

## Alerts

### Info Alert

```html
<div class="flex gap-3 p-4 bg-info-light/30 border-l-4 border-info rounded-lg">
  <i class="fas fa-info-circle text-info text-xl flex-shrink-0 mt-0.5"></i>
  <div>
    <h4 class="text-body font-semibold text-graphite-depth mb-1">Informação</h4>
    <p class="text-body text-soft-steel">Este registro será sincronizado com SPOR/EMA</p>
  </div>
</div>
```

### Success Alert

```html
<div class="flex gap-3 p-4 bg-success-light/30 border-l-4 border-success rounded-lg">
  <i class="fas fa-check-circle text-success text-xl flex-shrink-0 mt-0.5"></i>
  <div>
    <h4 class="text-body font-semibold text-graphite-depth mb-1">Sucesso!</h4>
    <p class="text-body text-soft-steel">Substância validada com sucesso</p>
  </div>
</div>
```

### Warning Alert

```html
<div class="flex gap-3 p-4 bg-warning-light/30 border-l-4 border-warning rounded-lg">
  <i class="fas fa-exclamation-triangle text-warning text-xl flex-shrink-0 mt-0.5"></i>
  <div>
    <h4 class="text-body font-semibold text-graphite-depth mb-1">Atenção</h4>
    <p class="text-body text-soft-steel">Alguns campos opcionais não foram preenchidos</p>
  </div>
</div>
```

### Error Alert

```html
<div class="flex gap-3 p-4 bg-error-light/30 border-l-4 border-error rounded-lg">
  <i class="fas fa-times-circle text-error text-xl flex-shrink-0 mt-0.5"></i>
  <div>
    <h4 class="text-body font-semibold text-graphite-depth mb-1">Erro de Validação</h4>
    <p class="text-body text-soft-steel">Fórmula molecular inválida</p>
  </div>
</div>
```

---

## Layout

### Container

```html
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
  <!-- Conteúdo -->
</div>
```

### Grid Layout (2 colunas)

```html
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
  <div class="bg-white p-6 rounded-lg border border-soft-arctic">
    <!-- Coluna 1 -->
  </div>
  <div class="bg-white p-6 rounded-lg border border-soft-arctic">
    <!-- Coluna 2 -->
  </div>
</div>
```

### Sidebar Layout

```html
<div class="grid grid-cols-1 lg:grid-cols-4 gap-6">
  <!-- Sidebar -->
  <aside class="lg:col-span-1">
    <div class="bg-white p-4 rounded-lg border border-soft-arctic sticky top-4">
      <h3 class="text-h3 mb-4">Filtros</h3>
      <!-- Filtros -->
    </div>
  </aside>

  <!-- Main Content -->
  <main class="lg:col-span-3">
    <div class="bg-white p-6 rounded-lg border border-soft-arctic">
      <!-- Conteúdo principal -->
    </div>
  </main>
</div>
```

---

## Navigation

### Header

```html
<header class="bg-emerald-abyss text-white py-4 px-6 shadow-lg sticky top-0 z-50">
  <div class="max-w-7xl mx-auto flex items-center justify-between">
    <div class="flex items-center gap-3">
      <i class="fas fa-flask-vial text-2xl text-mint-signal"></i>
      <div>
        <h1 class="text-lg font-display font-semibold">Pharm<sup>data</sup></h1>
        <p class="text-xs text-mint-signal">Curadoria de Dados</p>
      </div>
    </div>

    <nav class="flex gap-6">
      <a href="/substances" class="text-sm hover:text-mint-signal transition-colors">
        Substâncias
      </a>
      <a href="/products" class="text-sm hover:text-mint-signal transition-colors">
        Produtos
      </a>
      <a href="/profile" class="text-sm hover:text-mint-signal transition-colors">
        Perfil
      </a>
    </nav>
  </div>
</header>
```

### Breadcrumbs

```html
<nav class="flex items-center gap-2 text-sm text-soft-steel mb-6" aria-label="Breadcrumb">
  <a href="/" class="hover:text-teal-intense transition-colors">Home</a>
  <i class="fas fa-chevron-right text-xs"></i>
  <a href="/substances" class="hover:text-teal-intense transition-colors">Substâncias</a>
  <i class="fas fa-chevron-right text-xs"></i>
  <span class="text-graphite-depth font-medium">SUB-082615</span>
</nav>
```

---

**Notas de Acessibilidade**:
- Todos os componentes seguem WCAG AAA
- Focus states visíveis em todos os interativos
- Semântica HTML correta
- Aria-labels onde necessário
