/* ============================================================
   PontoTrack — Tabelas do painel administrativo
   Quadro de presença, atividade ao vivo, banco de horas, equipe
   e indicadores. Usa apenas os tokens do tema (var(--...)), então
   funciona tanto no tema WorldXambioa quanto no tema escuro.
   No celular (≤ 640px) as tabelas .pt-table--stack viram listas.
   ============================================================ */

/* ── Estrutura ─────────────────────────────────────────────── */
.pt-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.pt-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pt-table-wrap.is-scroll { max-height: 560px; overflow-y: auto; }
.pt-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.pt-table th {
  position: sticky; top: 0; z-index: 1;
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-secondary); background: var(--bg-primary);
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.pt-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.pt-table tbody tr:last-child td { border-bottom: 0; }
.pt-table tbody tr:hover { background: var(--bg-card-hover); }
.pt-table tr.is-clickable { cursor: pointer; }
.pt-table tr.is-clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.pt-table .num { text-align: right; }
.pt-dim { color: var(--text-tertiary); opacity: .65; }
.pt-empty { padding: 22px !important; text-align: center !important; color: var(--text-secondary); white-space: normal !important; }
.pt-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── Pessoa (avatar + nome) ────────────────────────────────── */
.pt-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pt-avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; background: var(--primary-glow); color: var(--primary-light);
  font-size: 11px; font-weight: 700;
}
.pt-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pt-name { display: block; font-weight: 600; color: var(--text-primary); max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.pt-sub { display: block; font-size: 11.5px; color: var(--text-secondary); }

/* ── Situação e tipo de batida ─────────────────────────────── */
.pt-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pt-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pt-chip.is-working { background: var(--success-bg); color: var(--success-light); }
.pt-chip.is-lunch { background: var(--warning-bg); color: var(--warning-light); }
.pt-chip.is-ended { background: var(--primary-glow); color: var(--primary-light); }
.pt-chip.is-absent, .pt-chip.is-inactive { background: var(--bg-tertiary); color: var(--text-secondary); }
.pt-type { display: inline-flex; align-items: center; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.pt-type.is-entry { background: var(--success-bg); color: var(--success-light); }
.pt-type.is-lunch { background: var(--warning-bg); color: var(--warning-light); }
.pt-type.is-back { background: rgba(59, 179, 195, 0.14); color: var(--accent-light); }
.pt-type.is-exit { background: var(--primary-glow); color: var(--primary-light); }
.pt-type.is-service { background: var(--info-bg); color: var(--info); }
.pt-late { display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 700; color: var(--danger-light); background: var(--danger-bg); border-radius: 6px; padding: 1px 6px; }
.pt-pos { color: var(--success-light); font-weight: 700; }
.pt-neg { color: var(--danger-light); font-weight: 700; }
.pt-maplink { display: inline-flex; align-items: center; gap: 5px; color: var(--primary-light); font-size: 12px; font-weight: 500; }
.pt-maplink small { color: var(--text-secondary); font-weight: 400; }
.pt-obs { white-space: normal !important; min-width: 160px; max-width: 280px; color: var(--text-secondary); font-size: 12px; }

/* ── Ações discretas na linha ──────────────────────────────── */
.pt-actions { display: inline-flex; gap: 2px; }
.pt-icon-btn {
  width: 30px; height: 30px; display: inline-grid; place-items: center; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-secondary); cursor: pointer; font-size: 13px;
}
.pt-icon-btn:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.pt-icon-btn.is-danger:hover { background: var(--danger-bg); color: var(--danger-light); }
.pt-icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Barra de progresso (banco de horas) ───────────────────── */
.pt-bar { display: inline-block; vertical-align: middle; width: 110px; height: 6px; border-radius: 999px; background: var(--bg-tertiary); overflow: hidden; }
.pt-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.pt-bar-pct { margin-left: 6px; font-size: 11.5px; color: var(--text-secondary); }
.pt-alert { display: flex; align-items: center; gap: 8px; background: var(--warning-bg); color: var(--warning-light); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 12px; font-weight: 600; }

/* ── Filtros e busca ───────────────────────────────────────── */
.pt-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pt-filter {
  font: inherit; font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; min-height: 32px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
}
.pt-filter b { color: var(--text-primary); font-variant-numeric: tabular-nums; }
.pt-filter:hover { border-color: var(--border-light); }
.pt-filter[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.pt-filter[aria-pressed="true"] b { color: #FFFFFF; }
.pt-filter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pt-search {
  display: inline-flex; align-items: center; gap: 8px; margin-left: auto; padding: 0 10px; height: 34px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-card); color: var(--text-tertiary);
}
.pt-search input, .pt-search input:focus {
  border: 0 !important; outline: 0; background: transparent !important; box-shadow: none !important;
  padding: 0 !important; height: 100%; width: 170px; font: inherit; font-size: 12.5px; color: var(--text-primary) !important;
}
.pt-search:focus-within { border-color: var(--primary); }
.pt-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }

/* ── Indicadores do painel ─────────────────────────────────── */
.pt-kpi { background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; padding: 13px 14px; display: grid; gap: 3px; min-width: 0; }
.pt-kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pt-kpi-label { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-secondary); }
.pt-kpi-ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 13px; flex: none; }
.pt-kpi-ico.is-turq { background: rgba(59, 179, 195, 0.14); color: var(--accent-light); }
.pt-kpi-ico.is-brand { background: var(--primary-glow); color: var(--primary-light); }
.pt-kpi-ico.is-ok { background: var(--success-bg); color: var(--success-light); }
.pt-kpi-ico.is-bad { background: var(--danger-bg); color: var(--danger-light); }
.pt-kpi-val { font-size: 24px; font-weight: 700; letter-spacing: -.015em; line-height: 1.2; font-variant-numeric: tabular-nums; color: var(--text-primary); }
.pt-kpi-val small { font-size: 13px; font-weight: 500; color: var(--text-secondary); }
.pt-kpi-sub { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Relatório (visualização) ──────────────────────────────── */
.pt-timebtn {
  font: inherit; font-variant-numeric: tabular-nums; color: var(--primary-light); background: none; border: 0;
  padding: 2px 4px; margin: -2px -4px; border-radius: 6px; cursor: pointer; text-decoration: underline;
  text-decoration-color: transparent; text-underline-offset: 3px; transition: text-decoration-color .15s, background .15s;
}
.pt-timebtn:hover { text-decoration-color: currentColor; background: var(--primary-glow); }
.pt-timebtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pt-report-kpis { margin: 16px 0 14px; }
.pt-report-note { display: flex; align-items: center; gap: 6px; margin: 10px 2px 0; font-size: 12px; color: var(--text-secondary); }

/* ── Aviso de nova versão do app ───────────────────────────── */
.pt-update {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 3000;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px)); /* acima do menu inferior do funcionário */
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 32px);
  padding: 10px 10px 10px 14px; border-radius: 12px; font-size: 13px; font-weight: 500;
  background: var(--primary-dark); color: #FFFFFF; box-shadow: var(--shadow-xl);
}
.pt-update > i { color: var(--accent); }
.pt-update-btn {
  font: inherit; font-weight: 700; border: 0; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  background: var(--accent); color: #FFFFFF; min-height: 0 !important;
}
.pt-update-close { border: 0; background: transparent; color: rgba(255, 255, 255, .7); cursor: pointer; padding: 6px; min-height: 0 !important; }
.pt-update-close:hover { color: #FFFFFF; }
@media (min-width: 768px) { .pt-update { bottom: 24px; } }

/* ── Ajustes nos contêineres antigos que agora recebem tabelas ── */
#trpSummary { display: flex !important; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
#trpList { display: block !important; max-height: none !important; overflow: visible !important; margin: 0 !important; padding: 0 !important; }
#trpList .pt-table-wrap { border: 1px solid var(--border); border-radius: 10px; }
#employeesGrid { display: block !important; }
#bancoHorasList .pt-table-wrap { border: 1px solid var(--border); border-radius: 10px; }
#liveActivityList .pt-table-wrap { border: 1px solid var(--border); border-radius: 10px; }

/* ── Celular: tabela vira lista compacta ───────────────────── */
@media (max-width: 640px) {
  .pt-table--stack thead { display: none; }
  .pt-table--stack, .pt-table--stack tbody { display: block; }
  .pt-table--stack tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 11px 12px; border-bottom: 1px solid var(--border); }
  .pt-table--stack tbody tr:last-child { border-bottom: 0; }
  .pt-table--stack td { display: block; padding: 0 !important; border: 0 !important; order: 3; }
  .pt-table--stack td.pt-cell-time { order: 0; }
  .pt-table--stack td.pt-cell-main { order: 1; flex: 1 1 0; min-width: 0; }
  /* Quebra fixa: linha 1 = data/hora + pessoa + situação/saldo/ações; o resto vai para as linhas de baixo */
  .pt-table--stack tr::after { content: ""; order: 2; flex-basis: 100%; height: 0; }
  .pt-table--stack .pt-name, .pt-table--stack .pt-sub { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pt-table--stack td.pt-cell-side, .pt-table--stack td.pt-cell-actions { order: 2; margin-left: auto; }
  .pt-table--stack td.pt-cell-end { order: 4; margin-left: auto; }
  .pt-table--stack td.num { text-align: left; font-size: 12px; }
  .pt-table--stack td[data-label]::before { content: attr(data-label) " "; color: var(--text-secondary); font-weight: 500; font-size: 11px; }
  .pt-table--stack .pt-obs { flex-basis: 100%; max-width: none; min-width: 0; }
  .pt-table--stack .pt-obs:has(.pt-dim) { display: none; }
  .pt-table--stack .pt-bar { width: 70px; }
  .pt-table--stack .pt-empty { flex-basis: 100%; }
  .pt-search { margin-left: 0; flex: 1 1 100%; }
  .pt-search input, .pt-search input:focus { width: 100%; }
  /* O CSS antigo dá 44px a todo elemento clicável no celular; nos horários isso espaçava demais as linhas */
  .pt-timebtn { min-height: 28px !important; display: inline-flex; align-items: center; }
  .pt-table--stack td.pt-cell-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
  .pt-table-wrap.is-scroll { max-height: none; overflow-y: visible; } /* no celular, só a página rola */
  .pt-kpi-label { font-size: 10.5px; letter-spacing: .02em; }
  .pt-kpi-ico { width: 26px; height: 26px; font-size: 12px; }
  .pt-kpi-sub { white-space: normal; }
}
.pt-kpi-label, .pt-kpi-sub, .pt-name { word-break: normal; overflow-wrap: normal; hyphens: none; }

/* Visão do funcionário (sem coluna Funcionário): no celular a data ocupa o lugar do nome */
@media (max-width: 640px) {
  .pt-table--single td.pt-cell-time { flex: 1 1 0; }
}
/* Seletor de mês do histórico do funcionário */
.pt-month-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.pt-month-bar input[type="month"] { flex: 1; min-width: 0; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-input); color: var(--text-primary); font-size: 14px; }
.pt-month-bar .btn { min-height: 0; }
/* Modal largo (cartão de ponto do funcionário) */
.modal-content.pt-modal-wide { max-width: 900px !important; width: calc(100vw - 32px); }
@media (max-width: 640px) { .modal-content.pt-modal-wide { width: 100%; } }
