/* ============================================================================
   GR Marketing — estilos dos dashboards
   ============================================================================
   Consome os tokens de theme.css. NAO escreva cor em hex aqui: use var(--...).
   Se faltar um token para o que voce precisa, crie o token la, nao a cor aqui.
   ========================================================================= */

body {
  font-family: var(--font-body);
  background-color: var(--surface-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* Titulos e marca usam a fonte de display do site institucional. */
h1, h2, h3, .font-display {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

/* ── barra superior (navy da marca) ──────────────────────────────────────
   E a unica superficie escura da aplicacao: carrega a marca sem invadir a
   area de dados. Para voltar a um cabecalho claro, basta trocar
   --surface-header em theme.css.                                          */
.app-header {
  height: 72px;
  background-color: var(--surface-header);
  border-bottom: 1px solid var(--border-on-dark);
}

.app-brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--text-on-dark);
}

.app-brand-divider {
  color: var(--text-on-dark-faint);
  font-weight: 300;
}

.app-page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 17px;
  color: var(--text-on-dark-muted);
}

.app-header-label {
  font-size: 14px;
  color: var(--text-on-dark-muted);
}

/* Controles dentro do cabecalho escuro: brancos e solidos, para a data
   continuar legivel -- e uma ferramenta de dados, nao uma landing page. */
.header-control {
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: box-shadow 0.12s, border-color 0.12s;
}

.header-control:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn-primary {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--gr-navy-900);
  background-color: var(--accent-bright);
  border-radius: var(--radius-sm);
  padding: 7px 18px;
  transition: background-color 0.12s, transform 0.06s;
}

.btn-primary:hover {
  background-color: var(--accent-soft);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-primary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  background-color: var(--surface-card);
  border-right: 1px solid var(--border);
}

.sidebar-section-title {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: background-color 0.12s, color 0.12s;
}

.sidebar-nav-item:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.sidebar-nav-active {
  background-color: var(--accent-wash);
  color: var(--accent);
  border-left-color: var(--accent-bright);
  font-weight: 600;
}

.sidebar-link {
  font-size: 12px;
  color: var(--accent);
  transition: color 0.12s;
}

.sidebar-link:hover {
  color: var(--accent-hover);
}

/* ── filtro multisselecao retratil (multiselect.js) ──────────────────────
   Dropdown fechado por padrao, com busca. Usado no filtro de contas; pensado
   para ser reaproveitado em outras listas conforme a plataforma cresce. */
.ms-filter {
  position: relative;
}

.ms-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  cursor: pointer;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.ms-trigger:hover {
  border-color: var(--accent);
}

.ms-trigger[aria-expanded="true"] {
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.ms-trigger-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ms-chevron {
  flex-shrink: 0;
  margin-left: 6px;
  color: var(--text-faint);
  transition: transform 0.12s;
}

.ms-trigger[aria-expanded="true"] .ms-chevron {
  transform: rotate(180deg);
}

.ms-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 30;
  background-color: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: 8px;
}

.ms-panel.hidden {
  display: none;
}

.ms-search-wrap {
  position: relative;
  margin-bottom: 6px;
}

.ms-search-icon {
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

.ms-search {
  width: 100%;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--surface-page);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px 6px 28px;
}

.ms-search:focus {
  outline: none;
  border-color: var(--accent-bright);
}

.ms-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 8px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.ms-action {
  font-size: 12px;
  color: var(--accent);
  transition: color 0.12s;
}

.ms-action:hover {
  color: var(--accent-hover);
}

.ms-action-sep {
  color: var(--border-strong);
  font-size: 12px;
}

.ms-options {
  max-height: 220px;
  overflow-y: auto;
}

.ms-option {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 14px;
  color: var(--text-muted);
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  line-height: 1.35;
}

.ms-option:hover {
  background-color: var(--surface-hover);
  color: var(--text-primary);
}

.ms-option-checkbox {
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 2px;
}

.ms-empty {
  font-size: 13px;
  font-style: italic;
  color: var(--text-faint);
  text-align: center;
  padding: 10px 0 4px;
}

/* ── cards de grafico ────────────────────────────────────────────────── */
.chart-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

.chart-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.chart-control {
  font-size: 14px;
  font-family: var(--font-body);
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.chart-control:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── tabela (Tabulator) ──────────────────────────────────────────────── */
.tabulator {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background-color: var(--surface-card);
  font-size: 15px;
  font-family: var(--font-body);
  color: var(--text-primary);
  box-shadow: var(--shadow-card);
}

/* Numeros alinhados verticalmente: em tabela de metricas isso e requisito
   de leitura, nao enfeite. */
.tabulator .tabulator-cell,
.tabulator .tabulator-calcs-bottom .tabulator-cell {
  font-variant-numeric: tabular-nums;
}

/* Cabecalho com leve tinta (nao branco puro, para se distinguir das linhas
   de dado) e texto mais escuro que o corpo, para ter presenca de titulo. */
.tabulator .tabulator-header {
  background-color: var(--surface-sunken);
  border-bottom: 2px solid var(--border-strong);
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.tabulator .tabulator-header .tabulator-col {
  background-color: var(--surface-sunken);
  border-right: none;
}

/* Mais altura no cabecalho (o padrao do Tabulator e 4px, apertado demais
   para o peso visual da fonte de display). */
.tabulator .tabulator-header .tabulator-col-content {
  padding-top: 10px;
  padding-bottom: 10px;
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
  background-color: var(--surface-hover);
}

/* Colunas arrastaveis: deixa claro que o cabecalho e manipulavel. */
.tabulator .tabulator-header .tabulator-col.tabulator-moving {
  background-color: var(--surface-active);
  border: 1px solid var(--accent-bright);
}

.tabulator .tabulator-tableholder {
  background-color: var(--surface-card);
}

.tabulator .tabulator-row {
  background-color: var(--surface-card);
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.tabulator .tabulator-row:hover {
  background-color: var(--surface-hover);
}

.tabulator .tabulator-row .tabulator-cell {
  border-right: none;
  padding: 5px 6px;
}

/* ── hierarquia de linhas ────────────────────────────────────────────────
   Google: conta > campanha (2 niveis). Meta: conta > campanha > conjunto >
   anuncio (4 niveis).

   A profundidade se le por DOIS canais que nao custam legibilidade:
     1. fundo, clareando em direcao ao branco conforme desce
     2. peso da fonte, 700 -> 600 -> 500 -> 400

   A COR DO TEXTO fica em --text-primary nos quatro niveis, de proposito.
   A primeira versao disto clareava tambem a cor (chegava a text-faint 13px
   no anuncio) e os niveis fundos ficavam ilegiveis. Peso e fundo distinguem
   sem tirar contraste -- e a diferenca entre "hierarquia visivel" e "texto
   apagado".

   A conta ainda leva uma borda superior mais forte, que separa um grupo do
   seguinte quando varios estao abertos ao mesmo tempo.                    */
.tabulator .account-row {
  background-color: var(--surface-sunken);
  border-top: 2px solid var(--border-strong);
}

.tabulator .account-row .tabulator-cell {
  font-weight: 700;
}

.tabulator .campaign-row {
  background-color: color-mix(in srgb, var(--surface-sunken) 55%, var(--surface-card));
}

.tabulator .campaign-row .tabulator-cell {
  font-weight: 600;
}

.tabulator .adset-row {
  background-color: color-mix(in srgb, var(--surface-sunken) 26%, var(--surface-card));
}

.tabulator .adset-row .tabulator-cell {
  font-weight: 500;
}

.tabulator .ad-row {
  background-color: var(--surface-card);
}

.tabulator .ad-row .tabulator-cell {
  font-weight: 400;
}

/* Terceiro nivel do dashboard do Google: grupo de anuncios ou de recursos.
   Mesma profundidade visual que .adset-row usa no Meta, de proposito -- as
   duas telas devem parecer a mesma familia. */
.tabulator .group-row {
  background-color: color-mix(in srgb, var(--surface-sunken) 26%, var(--surface-card));
}

.tabulator .group-row .tabulator-cell { font-weight: 500; }

.celula-residuo { cursor: help; }

/* Forca do anuncio (PMax). Etiqueta pequena ao lado do nome do grupo. */
.forca-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 9px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  cursor: help;
}

.forca-boa   { background: var(--state-ok-bg);  color: var(--state-ok-text); }
.forca-media { background: var(--state-off-bg); color: var(--warn-text); }
.forca-fraca { background: var(--state-err-bg); color: var(--state-err-text); }

/* nos quatro niveis o texto mantem o mesmo contraste */
.tabulator .account-row .tabulator-cell,
.tabulator .campaign-row .tabulator-cell,
.tabulator .group-row .tabulator-cell,
.tabulator .adset-row .tabulator-cell,
.tabulator .ad-row .tabulator-cell {
  color: var(--text-primary);
}

/* Linha do que a campanha gastou e nenhum grupo reivindicou. Discreta: e um
   acerto de contas, nao um grupo de verdade. */
.tabulator .residuo-row .tabulator-cell {
  font-style: italic;
  color: var(--text-muted);
}

.tabulator .account-row:hover,
.tabulator .campaign-row:hover,
.tabulator .adset-row:hover,
.tabulator .ad-row:hover {
  background-color: var(--surface-hover);
}

/* ── linha de totais ─────────────────────────────────────────────────── */
.tabulator .tabulator-calcs-bottom {
  border-top: 2px solid var(--border-strong);
}

.tabulator .tabulator-calcs-bottom .tabulator-cell {
  font-weight: 700;
  background-color: var(--surface-sunken);
  color: var(--text-primary);
}

/* ── seta da arvore ──────────────────────────────────────────────────── */
.tabulator .tabulator-data-tree-control {
  color: var(--accent);
}

.tabulator .tabulator-data-tree-control:hover {
  color: var(--accent-bright);
}

/* o destaque da linha em cross-filter e aplicado por estilo inline no JS
   (estilo inline sobrevive ao hover do Tabulator; classe CSS nao) */

/* ── aviso de resultados mistos (Meta) ───────────────────────────────── */
.cell-warn {
  color: var(--warn-text);
}

/* ── tooltip do grafico comparativo ──────────────────────────────────── */
#comp-tooltip {
  display: none;
  position: fixed;
  z-index: 200;
  pointer-events: none;
  background: var(--gr-navy-900);
  color: var(--text-on-dark);
  border: 1px solid var(--border-on-dark);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-dark);
  font-family: var(--font-body);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  min-width: 170px;
}

#comp-tooltip.visible {
  display: block;
}

.comp-tooltip-date {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  color: var(--text-on-dark-faint);
  margin-bottom: 7px;
  letter-spacing: 0.06em;
}

#comp-tooltip table {
  border-collapse: collapse;
  width: 100%;
}

.comp-tooltip-dot {
  font-size: 14px;
  line-height: 1;
  padding-right: 6px;
  vertical-align: middle;
}

.comp-tooltip-name {
  padding-right: 14px;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text-on-dark-muted);
}

.comp-tooltip-val {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text-on-dark);
}

#comp-tooltip tr + tr td {
  padding-top: 4px;
}

/* ── overlay de carregamento ─────────────────────────────────────────── */
.loading-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  color: var(--text-muted);
}

/* ── nota de rodape / legenda auxiliar ───────────────────────────────── */
.table-note {
  font-size: 12px;
  color: var(--text-faint);
}

/* ── tela de login ───────────────────────────────────────────────────── */
.login-label {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.login-input {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.login-input::placeholder {
  color: var(--text-faint);
}

.login-input:focus {
  outline: none;
  border-color: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ── cadastro de clientes: celulas editaveis ─────────────────────────────
   A tabela de clientes ESCREVE, diferente das de dashboard. O affordance
   precisa ser visivel: sem isso o usuario nao descobre que da para clicar. */
.tabulator .cell-editable {
  cursor: text;
}

.tabulator .tabulator-row .cell-editable:hover {
  background-color: var(--surface-hover);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.tabulator .tabulator-row .cell-editable.tabulator-editing {
  box-shadow: inset 0 0 0 2px var(--accent-bright);
  background-color: var(--surface-card);
}

.row-delete {
  color: var(--text-faint);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s;
}

.row-delete:hover {
  color: var(--warn-text);
}

/* ── formularios simples (geracao de relatorio) ──────────────────────── */
.form-label {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.row-action {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  margin-right: 12px;
}

.row-action:hover { color: var(--accent-hover); text-decoration: underline; }

/* ── formulario flutuante (modal) ────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(10, 23, 48, 0.45);
}

.modal-backdrop.hidden { display: none; }

.modal {
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-close {
  font-size: 22px;
  line-height: 1;
  color: var(--text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 4px;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body {
  padding: 16px 18px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

.field { margin-bottom: 14px; }
.field:last-of-type { margin-bottom: 0; }

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 4px;
}

.modal-error {
  margin-top: 14px;
  font-size: 13px;
  color: var(--warn-text);
  background: #FEF6EC;
  border: 1px solid #F6DFC0;
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

.modal-error.hidden { display: none; }

.btn-secondary {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 16px;
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

/* ── integracoes e agendador ─────────────────────────────────────────────
   Duas telas de operacao (nao de analise): o que importa e o estado atual
   ser legivel de relance. Pilula de estado + bloco de log monoespacado. */
.int-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0 18px;
  margin-bottom: 14px;
}

.state-pill {
  display: inline-block;
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  border-radius: var(--radius-pill);
  padding: 4px 11px;
  border: 1px solid var(--state-off-border);
  background: var(--state-off-bg);
  color: var(--state-off-text);
}

.state-ok   { color: var(--state-ok-text);   background: var(--state-ok-bg);   border-color: var(--state-ok-border); }
.state-err  { color: var(--state-err-text);  background: var(--state-err-bg);  border-color: var(--state-err-border); }
.state-busy { color: var(--state-busy-text); background: var(--state-busy-bg); border-color: var(--state-busy-border); }

/* Saida de comando. Fonte monoespacada porque dbt alinha a saida em colunas;
   com fonte proporcional a tabela de modelos do dbt fica ilegivel. */
.log-output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-secondary);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  max-height: 52vh;
  overflow-y: auto;
  margin: 0;
}

/* Modal de execucao: mais largo que o padrao, a saida do dbt e larga. */
.modal-wide { max-width: 860px; }

.job-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
}

.job-row .field { margin-bottom: 0; }

.time-input { width: 68px; text-align: center; }

/* Parametros com que o job dispara sozinho. Recolhido por padrao: quem abre a
   tela normalmente quer ver horario e historico, nao reconfigurar a carga. */
.sched-params {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.sched-params > summary {
  cursor: pointer;
  user-select: none;
}

.sched-params > summary:hover { color: var(--text-primary); }

.sched-params [data-role="params-fields"] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.sched-params [data-role="params-fields"] .field { margin-bottom: 0; }

/* Aviso de sucesso de uma acao que voltou por redirecionamento (ex.: retorno
   do OAuth). O par de erro ja existe em .modal-error. */
.banner-ok {
  font-size: 13px;
  color: var(--state-ok-text);
  background: var(--state-ok-bg);
  border: 1px solid var(--state-ok-border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}
