/* ==========================================================================
   RELATÓRIOS E ANALYTICS — TO-DO DIAMANTE
   Métricas de Produtividade, Ranking da Equipe e Distribuição Departamental
   ========================================================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.metric-subtitle {
  font-size: 0.775rem;
  color: var(--accent-emerald);
  font-weight: 600;
}
.metric-subtitle.warning {
  color: var(--p1-color);
}

/* Gráfico de Distribuição por Departamento */
.chart-section {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.section-headline {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  color: var(--text-primary);
}

.dept-bar-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dept-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.dept-bar-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
}

.progress-track {
  height: 8px;
  background-color: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-cyan));
  border-radius: var(--radius-full);
  transition: width 0.8s ease-out;
}

/* Tabela de Ranking de Produtividade */
.leaderboard-table-wrap {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  overflow-y: hidden;
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leaderboard-table th {
  background-color: var(--bg-surface-elevated);
  padding: 0.85rem 1.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

.leaderboard-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.9rem;
}

.rank-badge {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background-color: var(--bg-surface-elevated);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.rank-badge.top-1 { background: #fbbf24; color: #78350f; }
.rank-badge.top-2 { background: #cbd5e1; color: #334155; }
.rank-badge.top-3 { background: #d97706; color: white; }

.user-cell {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ===== Tabela de Equipe: colunas fixas, chips, menu e indicadores ===== */
.team-table { min-width: 0; }
.team-table th, .team-table td { padding: 0.7rem 0.7rem; vertical-align: middle; }

/* Primeira coluna (usuário) fixa à esquerda; última (ações) fixa à direita */
.team-table th:first-child,
.team-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--bg-surface);
  min-width: 200px;
  max-width: 240px;
}
.team-table th:first-child { background-color: var(--bg-surface-elevated); z-index: 3; }
.team-table tbody tr:hover td:first-child { background-color: var(--bg-surface-elevated); }

/* Sombras só quando há conteúdo escondido por baixo das colunas fixas */
.team-table th:last-child, .team-table td:last-child { box-shadow: none; transition: box-shadow .15s; }
.leaderboard-table-wrap.has-right-shadow .team-table th:last-child,
.leaderboard-table-wrap.has-right-shadow .team-table td:last-child { box-shadow: -8px 0 8px -8px rgba(15, 23, 42, 0.3); }
.leaderboard-table-wrap.has-left-shadow .team-table th:first-child,
.leaderboard-table-wrap.has-left-shadow .team-table td:first-child { box-shadow: 8px 0 8px -8px rgba(15, 23, 42, 0.3); }

.team-user-cell { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.team-avatar-wrap { position: relative; flex-shrink: 0; display: inline-flex; }
.team-avatar-wrap img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.online-dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; background: #22c55e; border: 2px solid var(--bg-surface); }
.team-user-text { display: flex; flex-direction: column; min-width: 0; }
.team-user-name, .team-user-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-user-email { font-size: 0.78rem; color: var(--text-muted); }

.team-dept-chips { display: flex; flex-wrap: wrap; gap: 4px; max-width: 190px; }
.dept-chip { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; color: var(--text-secondary); background: var(--bg-surface-elevated); border: 1px solid var(--border-color); }
.dept-chip-more { color: var(--accent-primary); }
.team-access { font-size: 0.82rem; color: var(--text-secondary); white-space: nowrap; }
.team-access.is-online { color: #16a34a; font-weight: 700; }

.team-actions { display: flex; align-items: center; justify-content: flex-end; gap: 4px; white-space: nowrap; }
.team-icon-btn { padding: 0.3rem 0.5rem !important; }
.team-icon-btn.is-danger { color: #dc2626; }
.team-icon-btn.is-danger:hover:not(:disabled) { background: rgba(220, 38, 38, 0.1); border-color: rgba(220, 38, 38, 0.45); }
.team-icon-btn.is-success { color: #16a34a; }
.team-icon-btn.is-success:hover { background: rgba(22, 163, 74, 0.1); border-color: rgba(22, 163, 74, 0.45); }
.team-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.team-icon-btn:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 1px; }

.row-menu-popover { position: fixed; z-index: 1200; min-width: 220px; padding: 6px; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: 10px; box-shadow: 0 14px 34px rgba(15, 23, 42, 0.2); }
.row-menu-item { display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 8px 10px; border: none; border-radius: 7px; background: transparent; color: var(--text-primary); font-family: inherit; font-size: 0.88rem; font-weight: 500; text-align: left; cursor: pointer; }
.row-menu-item:hover, .row-menu-item:focus-visible { background: rgba(99, 102, 241, 0.12); color: var(--accent-primary); outline: none; }
/* Última coluna (ações) fixa à direita */
.team-table th:last-child,
.team-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 2;
  background-color: var(--bg-surface);
}
.team-table th:last-child { background-color: var(--bg-surface-elevated); z-index: 3; }
.team-table tbody tr:hover td:last-child { background-color: var(--bg-surface-elevated); }