/* ============================================================
   Aplicatipico — design system
   Tokens (PRD §7.2) + componentes. Sem framework CSS:
   apenas variáveis CSS e classes, partials via {% include %}.
   Direção: lúdico e acolhedor, com as 3 cores de marca em destaque.
   ============================================================ */

:root {
  /* Primárias (cores da marca) */
  --color-blue: #2f80ed;
  --color-blue-strong: #1b6fd1;
  --color-yellow: #f2c94c;
  --color-red: #eb5757;

  /* Apoio / neutros */
  --color-blue-soft: #e8f1fe;
  --color-yellow-soft: #fcf3d6;
  --color-red-soft: #fce9e9;

  /* Fundo claro */
  --bg-base: #f7f9fc;
  --bg-surface: #ffffff;
  --bg-muted: #eef2f7;

  /* Texto */
  --text-strong: #1f2a37;
  --text-default: #344054;
  --text-muted: #667085;

  /* Estados */
  --color-success: #27ae60;
  --color-warning: #f2994a;
  --color-danger: var(--color-red);

  /* Gradiente de marca — as três cores primárias */
  --gradient-brand: linear-gradient(120deg, var(--color-blue) 0%, var(--color-red) 52%, var(--color-yellow) 100%);

  /* Bordas e sombras */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  --shadow-card: 0 6px 20px rgba(31, 42, 55, 0.08);
  --shadow-lift: 0 10px 24px rgba(31, 42, 55, 0.14);

  /* Tipografia — Nunito (arredondada/lúdica), Inter de apoio */
  --font-base: 'Nunito', 'Inter', system-ui, -apple-system, sans-serif;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;

  /* Espaçamento (escala de 4px) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;

  /* Layout */
  --container-max: 1120px;
  --topbar-h: 64px;
}

/* Reset leve */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family: var(--font-base);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: var(--text-default);
  background: var(--bg-base);
}
h1,
h2,
h3 {
  color: var(--text-strong);
  line-height: 1.2;
}
h1 {
  font-size: var(--fs-xl);
  font-weight: 800;
}
h2 {
  font-size: var(--fs-lg);
  font-weight: 800;
}
h3 {
  font-weight: 700;
}
a {
  color: var(--color-blue);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
img,
svg {
  vertical-align: middle;
}

/* Container central (PRD §7.6) */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding-inline: var(--space-4);
}

/* Topbar (PRD §7.7) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg-surface);
  box-shadow: var(--shadow-card);
}
.topbar::after {
  content: '';
  display: block;
  height: 3px;
  background: var(--gradient-brand);
}
.topbar__inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  height: var(--topbar-h);
}
.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.topbar__brand:hover {
  text-decoration: none;
}
.topbar__logo {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--gradient-brand);
  box-shadow: var(--shadow-card);
}
.topbar__wordmark {
  font-weight: 800;
  font-size: var(--fs-lg);
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.topbar__nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.topbar__nav a:not(.btn) {
  color: var(--text-default);
  font-weight: 600;
}
.topbar__user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.topbar__toggle {
  margin-left: auto;
  display: none;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-strong);
}
.topbar form {
  margin: 0;
}

/* App shell: topbar + sidebar */
.app-shell {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
}
.app-shell__content {
  flex: 1;
  min-width: 0;
  padding-block: var(--space-6);
}
.sidebar {
  width: 240px;
  flex-shrink: 0;
  padding: var(--space-6) var(--space-4);
}
.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-default);
  font-weight: 600;
}
.sidebar__link:hover,
.sidebar__link.is-active {
  background: var(--color-blue-soft);
  color: var(--color-blue-strong);
  text-decoration: none;
}

/* Botões (PRD §7.4) — pill, lúdicos, com lift no hover */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font: 700 var(--fs-md) var(--font-base);
  border-radius: var(--radius-pill);
  padding: var(--space-3) var(--space-6);
  border: 0;
  cursor: pointer;
  transition:
    transform 0.1s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}
.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-lift);
}
.btn:active {
  transform: translateY(0);
}
.btn i,
.btn svg {
  width: 18px;
  height: 18px;
}
.btn-primary {
  background: var(--color-blue);
  color: #fff;
}
.btn-primary:hover {
  background: var(--color-blue-strong);
}
.btn-accent {
  background: var(--color-yellow);
  color: var(--text-strong);
}
.btn-secondary {
  background: var(--bg-muted);
  color: var(--text-strong);
}
.btn-ghost {
  background: transparent;
  color: var(--color-blue);
}
.btn-danger {
  background: var(--color-red);
  color: #fff;
}

/* Inputs e forms (PRD §7.5) */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.field > label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  background: var(--bg-surface);
  border: 2px solid var(--bg-muted);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  font-size: var(--fs-md);
  font-family: var(--font-base);
  color: var(--text-strong);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 4px var(--color-blue-soft);
}
.field--invalid input,
.field--invalid select,
.field--invalid textarea {
  border-color: var(--color-red);
}
.field__help {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}
.field .error,
.errorlist {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-red);
  font-size: var(--fs-xs);
}
.field ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.field ul li label {
  color: var(--text-default);
}

/* Cards (PRD §7.6) */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}
.card__title {
  margin-top: 0;
  margin-bottom: var(--space-3);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}
/* Topo colorido rotativo (azul / amarelo / vermelho) */
.card-grid > .card {
  border-top: 5px solid var(--bg-muted);
  transition:
    transform 0.1s ease,
    box-shadow 0.15s ease;
}
.card-grid > .card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lift);
}
.card-grid > .card:nth-child(3n + 1) {
  border-top-color: var(--color-blue);
  background: linear-gradient(180deg, var(--color-blue-soft) 0%, var(--bg-surface) 42%);
}
.card-grid > .card:nth-child(3n + 2) {
  border-top-color: var(--color-yellow);
  background: linear-gradient(180deg, var(--color-yellow-soft) 0%, var(--bg-surface) 42%);
}
.card-grid > .card:nth-child(3n + 3) {
  border-top-color: var(--color-red);
  background: linear-gradient(180deg, var(--color-red-soft) 0%, var(--bg-surface) 42%);
}

/* Telas de autenticação */
.auth {
  display: flex;
  justify-content: center;
  padding-block: var(--space-8);
}
.auth .card {
  width: 100%;
  max-width: 440px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8);
  color: var(--text-muted);
  text-align: center;
}
.empty-state i,
.empty-state svg {
  width: 40px;
  height: 40px;
  color: var(--color-blue);
}

/* Toasts */
.toasts {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-3));
  right: var(--space-4);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 240px;
  background: var(--bg-surface);
  border-left: 5px solid var(--color-blue);
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}
.toast--success {
  border-left-color: var(--color-success);
}
.toast--error,
.toast--danger {
  border-left-color: var(--color-red);
}
.toast--warning {
  border-left-color: var(--color-warning);
}
.toast__close {
  margin-left: auto;
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--text-muted);
}

/* Container de gráfico */
.chart-container {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
}
.chart-container__canvas {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

/* Relatórios — itens de linha e chips de categoria/nível */
.timeline-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--bg-muted);
  font-size: var(--fs-sm);
}
.timeline-item:last-child {
  border-bottom: 0;
}
.chip {
  display: inline-block;
  padding: 2px var(--space-3);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.chip--blue,
.chip--baixa {
  background: var(--color-blue-soft);
  color: var(--color-blue);
}
.chip--yellow,
.chip--moderada {
  background: var(--color-yellow-soft);
  color: #9a7b16;
}
.chip--red,
.chip--alta {
  background: var(--color-red-soft);
  color: var(--color-red);
}

/* Hero (home / landing) — banho de cor e blobs lúdicos */
.hero {
  position: relative;
  overflow: hidden;
  padding-block: var(--space-8);
  text-align: center;
  border-radius: var(--radius-lg);
  background: linear-gradient(150deg, var(--color-blue-soft) 0%, var(--color-yellow-soft) 100%);
}
.hero::before,
.hero::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(20px);
  z-index: 0;
}
.hero::before {
  width: 120px;
  height: 120px;
  background: var(--color-blue);
  opacity: 0.22;
  top: -28px;
  left: -16px;
}
.hero::after {
  width: 110px;
  height: 110px;
  background: var(--color-red);
  opacity: 0.28;
  bottom: -26px;
  right: 4%;
}
.hero > * {
  position: relative;
  z-index: 1;
}
.hero h1 {
  font-size: var(--fs-2xl);
}
.hero p {
  color: var(--text-default);
  font-size: var(--fs-lg);
}
.hero__actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
  margin-top: var(--space-6);
}

/* Chips de ícone coloridos */
.icon-chip {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-3);
}
.icon-chip i,
.icon-chip svg {
  width: 26px;
  height: 26px;
}
.icon-chip--blue {
  background: var(--color-blue-soft);
  color: var(--color-blue);
}
.icon-chip--yellow {
  background: var(--color-yellow-soft);
  color: #9a7b16;
}
.icon-chip--red {
  background: var(--color-red-soft);
  color: var(--color-red);
}

/* Seção de destaques (home) */
.features {
  padding-block: var(--space-8);
}
.features h3 {
  margin: var(--space-2) 0;
}

/* Linha (rótulo + conteúdo) */
.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.row--spread {
  justify-content: space-between;
}

/* Lista de membros da equipe */
.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.badge-role {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-blue-soft);
  color: var(--color-blue-strong);
  font-size: var(--fs-xs);
  font-weight: 700;
}

/* Avatar (inicial do aprendiz) */
.avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: var(--gradient-brand);
}

/* Chip de ícone pequeno (timeline) */
.icon-chip--sm {
  width: 40px;
  height: 40px;
  margin-bottom: 0;
}
.icon-chip--sm i,
.icon-chip--sm svg {
  width: 20px;
  height: 20px;
}

/* Timeline de eventos */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}
.timeline__item {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--bg-muted);
}
.timeline__item:last-child {
  border-bottom: 0;
}
.timeline__time {
  min-width: 48px;
  color: var(--text-muted);
  font-weight: 700;
  font-size: var(--fs-sm);
}
.timeline__body {
  flex: 1;
}
.timeline__cat {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.timeline__actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.timeline__actions .btn {
  padding: var(--space-2);
}

/* Mídia na timeline */
.media-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}
.media-thumb img {
  display: block;
  max-height: 120px;
  border-radius: var(--radius-md);
}
.media-list audio {
  max-width: 320px;
}
.media-video {
  max-height: 200px;
  border-radius: var(--radius-md);
}

/* Selo de nível de comportamento */
.level {
  display: inline-flex;
  align-items: center;
  margin-top: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.level--baixa {
  background: #e7f6ed;
  color: var(--color-success);
}
.level--moderada {
  background: #fdeede;
  color: var(--color-warning);
}
.level--alta {
  background: var(--color-red-soft);
  color: var(--color-red);
}

/* Seletor de aprendiz */
.switcher {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.switcher a {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  color: var(--text-default);
  font-weight: 700;
}
.switcher a:hover {
  text-decoration: none;
}
.switcher a.is-active {
  background: var(--color-blue);
  color: #fff;
}

/* Banner de prévia */
.preview-banner {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-yellow-soft);
  color: #8a6d1a;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: var(--fs-sm);
}
.preview-banner i {
  width: 16px;
  height: 16px;
}

/* Utilitários */
.stack > * + * {
  margin-top: var(--space-4);
}
.muted {
  color: var(--text-muted);
}

/* Tabela */
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: var(--space-3);
  border-bottom: 1px solid var(--bg-muted);
  font-size: var(--fs-sm);
}
.table th {
  color: var(--text-muted);
  font-weight: 700;
}
.table tbody tr:hover {
  background: var(--bg-base);
}

/* Barra de progresso (ativação) */
.bar {
  height: 10px;
  border-radius: var(--radius-pill);
  background: var(--bg-muted);
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--gradient-brand);
}

/* Métrica destacada */
.metric {
  margin: var(--space-1) 0;
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--text-strong);
}

/* Selo de demonstração */
.badge-demo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-yellow-soft);
  color: #8a6d1a;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.badge-demo i,
.badge-demo svg {
  width: 16px;
  height: 16px;
}

/* ===================== Responsividade (PRD §7.6) ===================== */
/* Tablet (≤ 1024px) */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
}
/* Mobile (≤ 640px) */
@media (max-width: 640px) {
  .topbar__toggle {
    display: inline-flex;
  }
  .topbar__nav {
    position: fixed;
    inset: calc(var(--topbar-h) + 3px) 0 auto 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
    background: var(--bg-surface);
    padding: var(--space-4);
    box-shadow: var(--shadow-card);
  }
  .topbar__nav.is-open {
    display: flex;
  }
  .app-shell {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    padding-block: var(--space-3);
  }
  .hero h1 {
    font-size: var(--fs-xl);
  }
}
