/* Wave 12 (08/05/2026) — Tasks V1 Compacta
 * Layout aprovado por Hugo (preview localhost:8765/v1-compact.html)
 * Resolve queixa Jadson: "muito poluida, sem filtros"
 * Tokens isolados em :root + [data-theme="dark"], dark mode parity, mobile responsive.
 */

:root {
  /* KPIs semantic states */
  --tv1-kpi-critical: #ef4444;
  --tv1-kpi-warn: #f59e0b;
  --tv1-kpi-ok: #10b981;
  --tv1-kpi-info: var(--text-primary, #0f172a);

  /* View tabs */
  --tv1-tab-active: var(--brand-primary, #2563eb);
  --tv1-tab-active-bg: var(--brand-primary-bg, #eff6ff);
  --tv1-tab-count-bg: #e5e7eb;
  --tv1-tab-count-fg: #475569;

  /* Filter chips */
  --tv1-chip-bg: #fff;
  --tv1-chip-border: var(--border-default, #e5e7eb);
  --tv1-chip-active-bg: var(--brand-primary, #2563eb);
  --tv1-chip-active-fg: #fff;
  --tv1-chip-hover-border: var(--brand-primary, #2563eb);

  /* Table density */
  --tv1-row-h: 44px;
  --tv1-row-h-mobile: 56px;
  --tv1-row-bg: var(--surface, #fff);
  --tv1-row-hover: #f9fafb;
  --tv1-row-aging: rgba(254, 243, 199, 0.45);
  --tv1-row-old: rgba(254, 226, 226, 0.55);

  /* Status pills */
  --tv1-status-bg: #f3f4f6;
  --tv1-status-fg: #374151;

  /* Resp tags */
  --tv1-resp-cliente-bg: #dbeafe;
  --tv1-resp-cliente-fg: #1e40af;
  --tv1-resp-agencia-bg: #fce7f3;
  --tv1-resp-agencia-fg: #9f1239;
  --tv1-resp-ambos-bg: #e0e7ff;
  --tv1-resp-ambos-fg: #3730a3;

  /* Activity panel */
  --tv1-activity-bg: var(--surface, #fff);
  --tv1-activity-time: #9ca3af;
}

[data-theme="dark"] {
  --tv1-row-aging: rgba(180, 130, 40, 0.18);
  --tv1-row-old: rgba(180, 70, 70, 0.22);
  --tv1-tab-count-bg: rgba(255,255,255,0.10);
  --tv1-tab-count-fg: #cbd5e1;
  --tv1-chip-bg: var(--surface, #0f172a);
  --tv1-status-bg: rgba(255,255,255,0.06);
  --tv1-status-fg: #cbd5e1;
  --tv1-row-bg: var(--surface, #0f172a);
  --tv1-row-hover: rgba(255,255,255,0.04);
}

/* Page header */
.tv1-page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }

/* Layout */
.tv1-layout { display: grid; grid-template-columns: 1fr 280px; gap: 16px; }
@media (max-width: 1024px) { .tv1-layout { grid-template-columns: 1fr; } .tv1-activity { display: none; } }

/* KPIs row */
.tv1-kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 14px; }
.tv1-kpi { padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-default); display: flex; flex-direction: column; gap: 2px; cursor: pointer; text-align: left; transition: border-color 120ms, transform 120ms; font: inherit; color: inherit; }
.tv1-kpi:hover { border-color: var(--brand-primary, #2563eb); }
.tv1-kpi[data-active="true"] { border-color: var(--brand-primary, #2563eb); box-shadow: 0 0 0 2px var(--brand-primary-bg, #eff6ff); }
.tv1-kpi-label { font-size: 10px; color: var(--text-tertiary, #64748b); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.tv1-kpi-value { font-size: 22px; font-weight: 700; }
.tv1-kpi[data-state="critical"] .tv1-kpi-value { color: var(--tv1-kpi-critical); }
.tv1-kpi[data-state="warn"] .tv1-kpi-value { color: var(--tv1-kpi-warn); }
.tv1-kpi[data-state="ok"] .tv1-kpi-value { color: var(--tv1-kpi-ok); }
.tv1-kpi:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
@media (max-width: 768px) { .tv1-kpis { grid-template-columns: repeat(2, 1fr); } }

/* View tabs (saved views) */
.tv1-view-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border-default); margin-bottom: 14px; overflow-x: auto; }
.tv1-view-tab { padding: 9px 14px; font-size: 13px; color: var(--text-tertiary); cursor: pointer; border-bottom: 2px solid transparent; transition: all 120ms; font-weight: 500; white-space: nowrap; background: none; border-top: none; border-left: none; border-right: none; }
.tv1-view-tab:hover { color: var(--text-primary); }
.tv1-view-tab[data-active="true"] { color: var(--tv1-tab-active); border-bottom-color: var(--tv1-tab-active); font-weight: 600; }
.tv1-view-tab .tv1-count { margin-left: 6px; font-size: 10.5px; background: var(--tv1-tab-count-bg); padding: 0 6px; border-radius: 8px; color: var(--tv1-tab-count-fg); }
.tv1-view-tab[data-active="true"] .tv1-count { background: var(--tv1-tab-active-bg); color: var(--tv1-tab-active); }
.tv1-view-tab:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: -2px; }

/* Filter chips */
.tv1-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border-default); border-radius: 10px; align-items: center; position: relative; }
.tv1-chip { padding: 6px 11px; border-radius: 999px; font-size: 12px; border: 1px solid var(--tv1-chip-border); background: var(--tv1-chip-bg); cursor: pointer; display: inline-flex; align-items: center; gap: 5px; color: var(--text-primary); transition: all 120ms; min-height: 32px; font: inherit; }
.tv1-chip:hover { border-color: var(--tv1-chip-hover-border); color: var(--brand-primary); }
.tv1-chip[data-active="true"] { background: var(--tv1-chip-active-bg); color: var(--tv1-chip-active-fg); border-color: var(--tv1-chip-active-bg); }
.tv1-chip:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.tv1-chip-arrow { font-size: 10px; opacity: 0.7; }
.tv1-chip-divider { width: 1px; background: var(--border-default); margin: 0 4px; height: 24px; align-self: center; }
.tv1-search { flex: 1; min-width: 200px; border: none; outline: none; font-size: 13px; padding: 8px 10px; background: transparent; color: var(--text-primary); border-radius: 6px; }
.tv1-search:focus { background: var(--bg-secondary); }

/* Filter dropdown panel */
.tv1-dropdown { position: absolute; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--border-default); border-radius: 10px; min-width: 220px; max-height: 340px; overflow-y: auto; box-shadow: 0 8px 24px rgba(0,0,0,0.08); padding: 8px; z-index: 50; display: none; }
.tv1-dropdown[data-open="true"] { display: block; }
.tv1-dropdown-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; user-select: none; }
.tv1-dropdown-item:hover { background: var(--bg-secondary); }
.tv1-dropdown-item input { margin: 0; width: 14px; height: 14px; }
.tv1-dropdown-divider { height: 1px; background: var(--border-default); margin: 6px 0; }
.tv1-dropdown-action { font-size: 11px; color: var(--brand-primary); cursor: pointer; padding: 4px 10px; background: none; border: none; }
.tv1-dropdown-action:hover { text-decoration: underline; }

/* Table */
.tv1-table-wrap { background: var(--surface); border: 1px solid var(--border-default); border-radius: 10px; overflow: hidden; }
.tv1-table { width: 100%; }
.tv1-table-header, .tv1-table-row { display: grid; grid-template-columns: 32px 160px 1fr 80px 130px 100px 110px; gap: 12px; padding: 9px 16px; align-items: center; border-bottom: 1px solid var(--border-default); }
.tv1-table-header { background: var(--bg-secondary); font-size: 10px; text-transform: uppercase; color: var(--text-tertiary); font-weight: 600; letter-spacing: 0.05em; cursor: default; user-select: none; }
.tv1-table-header [data-sortable="true"] { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 4px 0; border-radius: 4px; }
.tv1-table-header [data-sortable="true"]:hover { color: var(--text-primary); }
.tv1-table-header [data-sortable="true"]:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.tv1-sort-icon { opacity: 0; font-size: 9px; }
.tv1-table-header [data-sort-active="asc"] .tv1-sort-icon::before { content: '\25B2'; opacity: 1; }
.tv1-table-header [data-sort-active="desc"] .tv1-sort-icon::before { content: '\25BC'; opacity: 1; }
.tv1-table-row { transition: background 100ms; font-size: 13px; min-height: var(--tv1-row-h); cursor: pointer; }
.tv1-table-row:hover { background: var(--tv1-row-hover); }
.tv1-table-row[data-age-category="aging"] { background: var(--tv1-row-aging); }
.tv1-table-row[data-age-category="old"] { background: var(--tv1-row-old); }
.tv1-table-row[data-selected="true"] { background: var(--brand-primary-bg, #eff6ff); }
.tv1-table-row[data-focused="true"] { box-shadow: inset 0 0 0 2px var(--brand-primary, #2563eb); }
.tv1-table-row:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: -2px; }
.tv1-cell-cli { font-weight: 600; color: var(--brand-primary); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv1-cell-desc { color: var(--text-secondary); line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv1-checkbox { width: 16px; height: 16px; cursor: pointer; }

/* Status pill, resp tag */
.tv1-status-pill { font-size: 11px; padding: 3px 9px; border-radius: 6px; background: var(--tv1-status-bg); color: var(--tv1-status-fg); font-weight: 500; text-align: center; display: inline-block; }
.tv1-resp { font-size: 10px; padding: 2px 7px; border-radius: 5px; font-weight: 500; display: inline-block; text-transform: lowercase; }
.tv1-resp[data-r="cliente"] { background: var(--tv1-resp-cliente-bg); color: var(--tv1-resp-cliente-fg); }
.tv1-resp[data-r="agencia"] { background: var(--tv1-resp-agencia-bg); color: var(--tv1-resp-agencia-fg); }
.tv1-resp[data-r="ambos"] { background: var(--tv1-resp-ambos-bg); color: var(--tv1-resp-ambos-fg); }

/* Buttons mini */
.tv1-btn { font-size: 11.5px; padding: 6px 11px; border-radius: 6px; border: 1px solid var(--border-default); background: var(--surface); cursor: pointer; color: var(--text-primary); min-height: 32px; transition: transform 100ms, border-color 100ms; font: inherit; }
.tv1-btn:hover { border-color: var(--brand-primary); }
.tv1-btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.tv1-btn-primary { background: var(--brand-primary); color: white; border-color: var(--brand-primary); }
.tv1-btn-primary:hover { background: var(--brand-primary-dark, #1d4ed8); }
.tv1-actions-cell { display: flex; gap: 4px; justify-content: flex-end; }
@media (hover: none) { .tv1-btn { min-height: 44px; padding: 9px 13px; } }

/* Bulk action bar */
.tv1-bulk-bar { display: none; padding: 10px 16px; background: var(--brand-primary-bg, #eff6ff); border: 1px solid var(--border-default); border-radius: 10px; align-items: center; gap: 12px; font-size: 13px; color: var(--brand-primary, #1e40af); margin-bottom: 10px; }
.tv1-bulk-bar[data-visible="true"] { display: flex; }
.tv1-bulk-bar strong { font-weight: 600; }
.tv1-bulk-spacer { flex: 1; }

/* Pagination */
.tv1-pagination { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: 12px; color: var(--text-tertiary); }
.tv1-pagination button { font-size: 11.5px; padding: 5px 11px; border-radius: 5px; border: 1px solid var(--border-default); background: var(--surface); cursor: pointer; min-height: 32px; color: var(--text-primary); font: inherit; }
.tv1-pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* Empty state */
.tv1-empty { padding: 60px 24px; text-align: center; color: var(--text-tertiary); }
.tv1-empty .icon { font-size: 36px; opacity: 0.4; margin-bottom: 8px; }
.tv1-empty .title { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; }
.tv1-empty .hint { font-size: 12px; }
.tv1-empty button { margin-top: 12px; }

/* Loading skeleton */
.tv1-skeleton { padding: 0; }
.tv1-skel-row { display: grid; grid-template-columns: 32px 160px 1fr 80px 130px 100px 110px; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border-default); }
.tv1-skel-cell { height: 14px; border-radius: 4px; background: linear-gradient(90deg, #f1f5f9 0%, #e2e8f0 50%, #f1f5f9 100%); background-size: 200% 100%; animation: tv1-shimmer 1.4s infinite; }
[data-theme="dark"] .tv1-skel-cell { background: linear-gradient(90deg, rgba(255,255,255,0.04) 0%, rgba(255,255,255,0.10) 50%, rgba(255,255,255,0.04) 100%); background-size: 200% 100%; }
@keyframes tv1-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .tv1-skel-cell { animation: none; background: #e2e8f0; } }

/* Activity sidebar */
.tv1-activity { background: var(--surface); border: 1px solid var(--border-default); border-radius: 10px; padding: 14px 16px; height: fit-content; }
.tv1-activity h3 { font-size: 11px; text-transform: uppercase; color: var(--text-tertiary); font-weight: 700; letter-spacing: 0.06em; margin: 0 0 10px; display: flex; align-items: center; }
.tv1-activity .toggle { margin-left: auto; font-size: 11px; color: var(--brand-primary); cursor: pointer; text-transform: none; letter-spacing: 0; font-weight: 500; background: none; border: none; padding: 2px 6px; }
.tv1-activity .toggle:hover { text-decoration: underline; }
.tv1-activity .list { max-height: 480px; overflow-y: auto; }
.tv1-activity[data-collapsed="true"] .list { display: none; }

/* Results info */
.tv1-results-info { font-size: 11px; color: var(--text-tertiary); margin: 4px 4px 8px; }

/* Keyboard shortcuts hint */
.tv1-kbd { display: inline-block; padding: 1px 6px; background: var(--bg-secondary); border: 1px solid var(--border-default); border-radius: 4px; font-size: 10.5px; font-family: ui-monospace, monospace; color: var(--text-secondary); }

/* Mobile: tabela vira cards */
@media (max-width: 640px) {
  .tv1-table-header { display: none; }
  .tv1-table-row { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; min-height: var(--tv1-row-h-mobile); }
  .tv1-cell-desc { white-space: normal; }
  .tv1-actions-cell { justify-content: flex-start; }
  .tv1-skel-row { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px; }
}

/* ============================================================ */
/* Wave 12.1 (2026-05-08) — Hotfixes P0/P1                       */
/* ============================================================ */

/* P0-A: Read-only mode — esconder approve/reject buttons + bulk bar */
/* /tasks vira read-only; aprovações continuam SÓ em /approvals      */
.tv1-actions-cell,
.tv1-bulk-bar,
[data-tv1-readonly-hide="true"] { display: none !important; }
/* Esconde checkbox col (1ª) do header e da row */
.tv1-table-header > [role="columnheader"]:first-child,
.tv1-table-row > [role="cell"]:first-child { visibility: hidden; }

/* P0-B: focus-visible nos 4 elementos faltantes */
.tv1-search:focus-visible {
  outline: 2px solid var(--brand-primary, #2563eb);
  outline-offset: 2px;
  background: var(--bg-secondary, #f1f5f9);
}
.tv1-checkbox:focus-visible {
  outline: 2px solid var(--brand-primary, #2563eb);
  outline-offset: 2px;
}
.tv1-activity .toggle:focus-visible {
  outline: 2px solid var(--brand-primary, #2563eb);
  outline-offset: 2px;
  border-radius: 4px;
}
.tv1-dropdown-action:focus-visible {
  outline: 2px solid var(--brand-primary, #2563eb);
  outline-offset: 2px;
  background: var(--bg-secondary, #f1f5f9);
}

/* P0-C: Touch targets >=44px em mobile/touch devices */
@media (hover: none) {
  .tv1-chip { min-height: 44px; padding: 8px 13px; }
  .tv1-pagination button { min-height: 44px; padding: 8px 13px; }
  .tv1-view-tab { min-height: 44px; padding: 12px 14px; }
  .tv1-checkbox { width: 22px; height: 22px; }
}

/* P1-7: tabular-nums em counts/values (alinhamento de números) */
.tv1-kpi-value,
.tv1-count,
.tv1-pagination,
#tv1-results-info,
.tv1-table-row { font-variant-numeric: tabular-nums; }

/* P1-9: Dark mode resp tags (parity faltante) */
[data-theme="dark"] {
  --tv1-resp-cliente-bg: rgba(59, 130, 246, 0.18);
  --tv1-resp-cliente-fg: #93c5fd;
  --tv1-resp-agencia-bg: rgba(244, 114, 182, 0.20);
  --tv1-resp-agencia-fg: #f9a8d4;
  --tv1-resp-ambos-bg: rgba(99, 102, 241, 0.20);
  --tv1-resp-ambos-fg: #a5b4fc;
}

/* P1-11: prefers-reduced-motion em transitions */
@media (prefers-reduced-motion: reduce) {
  .tv1-kpi,
  .tv1-view-tab,
  .tv1-chip,
  .tv1-table-row,
  .tv1-btn { transition: none !important; }
}

/* P1-13: [data-loading] state em botões */
.tv1-btn[data-loading="true"] {
  pointer-events: none;
  opacity: 0.6;
}
.tv1-btn[data-loading="true"]::after { content: ' …'; }

/* P0-A complement: hint visual sutil "/approvals" */
.tv1-readonly-hint {
  font-size: 11px;
  color: var(--text-tertiary, #64748b);
  padding: 6px 12px;
  background: var(--bg-secondary, #f1f5f9);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}
.tv1-readonly-hint a {
  color: var(--brand-primary, #2563eb);
  font-weight: 500;
  text-decoration: none;
}
.tv1-readonly-hint a:hover { text-decoration: underline; }
