/* ==========================================================================
   Portal RH — Design System (identidade inspirada na Ipsis)
   Paleta sóbria/premium: vermelho de marca sobre grafite e branco.
   Tipografia moderna sem serifa. Mobile-first, acessível (seção 5).
   ========================================================================== */

:root {
  /* Marca */
  --ips-red: #E30613;
  --ips-red-dark: #B30410;
  --ips-ink: #1A1A1A;
  --ips-graphite: #2B2B2B;

  /* Neutros */
  --c-bg: #F4F5F7;
  --c-surface: #FFFFFF;
  --c-border: #E3E5E9;
  --c-text: #1A1A1A;
  --c-muted: #6B7280;

  /* Semânticas */
  --c-ok: #1F8A4C;
  --c-warn: #E08600;
  --c-danger: #C62828;
  --c-info: #1565C0;

  /* Kits (cor + sempre acompanhada de nome/ícone) */
  --kit-verde: #2E7D32;
  --kit-azul: #1565C0;
  --kit-amarelo: #F9A825;
  --kit-vermelho: #C62828;

  /* Métricas */
  --radius: 14px;
  --radius-sm: 10px;
  --toque: 48px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --shadow-lg: 0 10px 30px rgba(16,24,40,.12);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ips-red); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-weight: 700; letter-spacing: -.01em; margin: 0 0 .4em; }

/* ---- Marca / logotipo em texto ---- */
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--ips-ink);
}
.brand .mark {
  display: inline-block;
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--ips-red);
  position: relative;
  flex: none;
}
.brand .mark::after {
  content: "";
  position: absolute; inset: 9px;
  border-radius: 3px;
  background: #fff;
  clip-path: polygon(0 60%, 30% 60%, 50% 20%, 70% 80%, 100% 45%, 100% 100%, 0 100%);
}
.brand .name { font-size: 18px; line-height: 1; }
.brand .name small { display: block; font-size: 11px; font-weight: 600;
  color: var(--c-muted); letter-spacing: .06em; text-transform: uppercase; }

/* ==========================================================================
   Layout com sidebar recolhível
   ========================================================================== */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--ips-ink);
  color: #fff;
  display: flex;
  flex-direction: column;
  transition: width .2s ease;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .topo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar .brand .name, .sidebar .brand .name small { color: #fff; }
.sidebar .brand .name small { color: rgba(255,255,255,.6); }

.sidebar nav { padding: 12px 10px; flex: 1; overflow-y: auto; }
.sidebar .item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.82);
  min-height: var(--toque);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar .item:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar .item.ativo { background: var(--ips-red); color: #fff; }
.sidebar .item .ico { font-size: 20px; width: 24px; text-align: center; flex: none; }
.sidebar .item .txt { font-weight: 600; font-size: 15px; }

.sidebar .rodape {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 13px;
}
.sidebar .rodape .item { color: rgba(255,255,255,.7); }

/* Recolhido: só ícones */
.layout.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.layout.collapsed .sidebar .txt,
.layout.collapsed .sidebar .brand .name,
.layout.collapsed .sidebar .rodape .txt { display: none; }
.layout.collapsed .sidebar .topo { justify-content: center; }

/* Conteúdo */
.conteudo { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 12px 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .burger {
  width: 42px; height: 42px;
  border: 1px solid var(--c-border);
  background: #fff; border-radius: 10px;
  font-size: 18px; cursor: pointer; flex: none;
}
.topbar .titulo { font-size: 18px; font-weight: 700; flex: 1; }
.topbar .user {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: var(--c-muted);
}
.topbar .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--ips-red); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}

.pagina { padding: 22px; flex: 1; }

/* Em telas pequenas, a sidebar vira uma gaveta sobreposta */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; z-index: 50; left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .layout.drawer-open .sidebar { transform: translateX(0); }
  .scrim {
    display: none; position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.45);
  }
  .layout.drawer-open .scrim { display: block; }
}
@media (min-width: 821px) { .scrim { display: none; } }

/* ==========================================================================
   Componentes
   ========================================================================== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--toque);
  padding: 12px 18px;
  font-size: 16px; font-weight: 700;
  border: none; border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
.btn:active { transform: scale(.99); }
.btn-primary { background: var(--ips-red); color: #fff; }
.btn-primary:hover { filter: brightness(.95); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--ips-ink); border: 1px solid var(--c-border); }
.btn-danger { background: #fff; color: var(--c-danger); border: 2px solid var(--c-danger); }
.btn-ok { background: var(--c-ok); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 14px; }

.input {
  width: 100%;
  min-height: var(--toque);
  padding: 12px 14px;
  font-size: 16px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: #fff;
}
.input:focus { outline: 2px solid var(--ips-red); border-color: var(--ips-red); }
label.campo { display: block; font-size: 14px; font-weight: 600;
  color: var(--c-muted); margin: 14px 0 6px; }

/* Chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  background: #EEF0F3; color: #374151;
}
.chip.ok { background: #E6F4EA; color: var(--c-ok); }
.chip.warn { background: #FEF3E2; color: var(--c-warn); }
.chip.danger { background: #FDECEA; color: var(--c-danger); }

/* Etiqueta de cor do kit: cor + nome + ícone (regra de acessibilidade).
   .kit é o alias usado pelo PWA; ambos compartilham a mesma receita. */
.kit-tag, .kit {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: #fff;
  padding: 3px 10px; border-radius: 999px;
}

/* Sino de notificações (base.html) */
.notif-sino {
  position: relative; background: none; border: none; cursor: pointer;
  font-size: 20px; line-height: 1;
}
.notif-badge {
  position: absolute; top: -4px; right: -6px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: var(--ips-red); color: #fff;
  font-size: 11px; line-height: 16px; font-weight: 700; text-align: center;
}
.notif-dropdown {
  position: absolute; top: 52px; right: 16px;
  width: 320px; max-height: 70vh; overflow: auto;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 40;
}
.notif-sair-form { margin: 0; }
.notif-sair {
  width: 100%; background: none; border: none;
  cursor: pointer; text-align: left;
}
.notif-vazio, .notif-mais { margin: 0; color: var(--c-muted); }
.notif-vazio { padding: 16px; }
.notif-mais { padding: 10px 14px; font-size: 12px; }
.notif-item { padding: 12px 14px; border-bottom: 1px solid var(--c-border); }
.notif-item-titulo { font-weight: 700; font-size: 13px; }
.notif-item-msg { font-size: 12px; color: var(--c-muted); margin: 2px 0 6px; }
.notif-marcar {
  background: none; border: none; color: var(--ips-red);
  cursor: pointer; font-size: 12px; padding: 0;
}

/* Barra de progresso */
.progresso { height: 10px; background: #E6E8EC; border-radius: 6px; overflow: hidden; }
.progresso > span { display: block; height: 100%; background: var(--ips-red); transition: width .3s; }

.vazio { text-align: center; color: var(--c-muted); padding: 40px 10px; }

/* Paginador (ui/paginacao.js) */
.paginacao {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 18px 0 4px;
}
.paginacao-info { color: var(--c-muted); font-size: 14px; }
.paginacao-ctl { display: flex; align-items: center; gap: 10px; }
.paginacao-pos { font-size: 14px; font-weight: 600; min-width: 112px; text-align: center; }
.paginacao .btn[disabled] { opacity: .45; cursor: not-allowed; }
@media (max-width: 520px) {
  .paginacao { justify-content: center; }
  .paginacao-pos { min-width: 0; }
}

/* Grade de métricas */
.grade { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }

.metric { font-size: 34px; font-weight: 800; line-height: 1; letter-spacing: -.02em; }
.metric.ok { color: var(--c-ok); }
.metric.warn { color: var(--c-warn); }
.metric.bad { color: var(--c-danger); }

dialog {
  border: none; border-radius: var(--radius);
  padding: 22px; width: 92%; max-width: 440px;
  box-shadow: var(--shadow-lg);
}
dialog::backdrop { background: rgba(16,24,40,.5); }

.evidencia-mini {
  width: 48px; height: 48px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--c-border);
}
