/* RedirectPro · camada de acabamento (carregada por último em todas as telas do painel).
   Regras globais de consistência, celular e acessibilidade. Não muda lógica nenhuma. */

/* ---------- Tokens extras ---------- */
:root {
  --rp-ok: #16a34a; --rp-ok-soft: color-mix(in srgb, #22c55e 12%, transparent);
  --rp-warn: #d97706; --rp-warn-soft: color-mix(in srgb, #f59e0b 14%, transparent);
  --rp-bad: #dc2626; --rp-bad-soft: color-mix(in srgb, #ef4444 12%, transparent);
  --rp-tap: 44px;
}
html[data-theme="dark"] { --rp-ok: #4ade80; --rp-warn: #fbbf24; --rp-bad: #f87171; }

/* ---------- Tipografia e foco ---------- */
html body h1 { font-size: clamp(26px, 2.6vw + 14px, 38px) !important; line-height: 1.12; overflow-wrap: anywhere; }
html body h2 { overflow-wrap: anywhere; }
html body :focus-visible { outline: 2px solid var(--brand-bright); outline-offset: 2px; border-radius: 6px; }
html body .btn:focus-visible, html body a:focus-visible { outline-offset: 3px; }
html body button, html body [role="button"], html body summary { -webkit-tap-highlight-color: transparent; }
html body summary { cursor: pointer; }

/* ---------- Alertas ---------- */
html body .alert.warning { background: var(--rp-warn-soft); border-color: color-mix(in srgb, var(--rp-warn) 30%, var(--line)); color: var(--rp-warn); }
html body .alert { margin-bottom: 16px; }

/* ---------- Dashboard: cartão largo só em tela grande ---------- */
.gf-span2 { grid-column: auto; }
@media (min-width: 1180px) { .gf-span2 { grid-column: span 2; } }

/* ---------- Menu lateral: ordem pela própria página (sem "order" do CSS antigo) ---------- */
html body .topbar.gf-nav nav > :is(a, button, details) { order: 0 !important; }
html body .topbar.gf-nav nav > a.nav-cta { margin-top: 0 !important; }
html body .topbar.gf-nav nav > a.nav-cta::before { display: none !important; }
html body .topbar.gf-nav nav > a.nav-hire { margin-top: 6px !important; }

/* Tema: só o ícone (sol ou lua), como os outros itens do menu. */
html body .rp-theme-link { appearance: none; background: none; border: 0; width: 100%; font: inherit; font-weight: 700; color: inherit; text-align: left; cursor: pointer; }
html body .rp-theme-link .ic-sun { display: none; }
html[data-theme="dark"] body .rp-theme-link .ic-sun { display: block; }
html[data-theme="dark"] body .rp-theme-link .ic-moon { display: none; }


html body .rp-appbar-brand { display: none; }

/* ---------- Tabelas: nunca estouram a largura ---------- */
html body .table-card, html body .gf-table-wrap, html body .cx-scroll, html body .rp-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
html body .table-card > table, html body .gf-table-wrap > table { min-width: 560px; }

/* ---------- Celular ---------- */
@media (max-width: 780px) {
  /* Barra superior fixa que dá apoio ao botão do menu (antes ele flutuava solto sobre o conteúdo). */
  body::before {
    /* Começa bem acima da tela e com fundo sólido: no iPhone o conteúdo não aparece mais atrás da hora/bateria. */
    content: ""; position: fixed; left: 0; right: 0; top: -200px; height: calc(260px + env(safe-area-inset-top, 0px));
    background: var(--surface);
    border-bottom: 1px solid var(--line); z-index: 300; pointer-events: none;
  }
  body.gf-mobile-menu-open::before { display: none; }
  /* Gaveta já começa fechada (sem piscar o menu antigo antes do script carregar). */
  html body .topbar.gf-nav:not(.gf-mobile-open) { position: fixed; left: 0; top: 0; bottom: 0; width: min(300px, 86vw); transform: translateX(-105%); }
  html body .rp-appbar-brand {
    display: flex; position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); z-index: 310;
    display: flex; align-items: center; gap: 8px; height: 40px; pointer-events: none; text-decoration: none;
    font-family: var(--rp-disp); font-weight: 700; font-size: 17px; letter-spacing: -.03em; color: var(--text); text-transform: lowercase;
  }
  html body .rp-appbar-brand img { width: 30px; height: 30px; border-radius: 8px; }
  html body .rp-appbar-brand strong { background: var(--brand-bright); color: #fff; border-radius: 6px; padding: 0 6px 2px; font-size: .86em; line-height: 1.3; }
  /* Gaveta aberta: uma marca só, na mesma linha do X, e o fundo escuro cobre também a área da hora. */
  html body.gf-mobile-menu-open .rp-appbar-brand { display: none !important; }
  html body .topbar.gf-nav { top: -200px !important; height: calc(100dvh + 200px) !important; min-height: calc(100dvh + 200px) !important; padding-top: calc(206px + env(safe-area-inset-top, 0px)) !important; }
  html body .topbar.gf-nav .brand { padding-left: 52px !important; margin-bottom: 14px !important; }
  html body .gf-mobile-menu-toggle { top: calc(8px + env(safe-area-inset-top, 0px)) !important; left: 12px !important; z-index: 320 !important; border: 0 !important; box-shadow: none !important; background: transparent !important; }
  html body .gf-mobile-menu-toggle:not([aria-expanded="true"]) { color: var(--text) !important; }
  html body .gf-mobile-menu-toggle span { background: currentColor !important; }
  html body .container, html body main.container.dashboard-container { padding: calc(78px + env(safe-area-inset-top, 0px)) 16px calc(40px + env(safe-area-inset-bottom, 0px)) !important; }

  /* iPhone dá zoom em campo menor que 16px. Alvos de toque de no mínimo 44px. */
  html body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]), html body select, html body textarea { font-size: 16px !important; }
  html body .field input, html body .field select, html body .field textarea:not([rows]), html body input[type="search"], html body input[type="date"], html body input[type="datetime-local"], html body input[type="number"], html body select { min-height: var(--rp-tap) !important; }
  html body .btn { min-height: var(--rp-tap); }
  html body .btn.compact { min-height: 40px; }
  html body summary, html body .rd-menu summary, html body .rd-more, html body .rd-ic, html body .op-seg button, html body .op-seg a, html body .rp-periods a, html body .wz-filter button, html body .rp-ibtn, html body .lp-ibtn, html body .cx-tg, html body .mt-acc-bar button, html body .of-chips a, html body .vt-chips a, html body .gf-settings-tabs a, html body .rp-tabs a, html body .rp-addtabs a { min-height: 40px; }
  html body .rd-ic, html body .rp-ibtn, html body .lp-ibtn, html body .cx-tg, html body .rd-more { min-width: 40px; }
  html body .gp-camp select { height: var(--rp-tap) !important; font-size: 16px !important; }

  /* Cabeçalhos de página e ações ocupam a largura toda. */
  html body .page-head, html body .gf-page-head, html body .gf-dashboard-head, html body .op-head, html body .of-head { flex-direction: column; align-items: stretch !important; gap: 12px; }
  /* Em coluna, o texto do topo não pode herdar a largura mínima de 340px como altura (abria um buraco). */
  html body .page-head > *, html body .gf-page-head > *, html body .gf-dashboard-head > *, html body .op-head > *, html body .of-head > * { flex: 0 0 auto !important; min-width: 0; }
  html body .op-head .gf-period-wrap, html body .gf-dashboard-head .gf-period-wrap { width: 100% !important; margin-left: 0 !important; }
  html body .op-head .gf-period-menu, html body .op-head .gf-period-menu > summary { width: 100% !important; }
  html body .op-head .gf-period-list { left: 0; right: 0; width: auto; }
  html body .op-head .op-seg { align-self: flex-start; max-width: 100%; overflow-x: auto; }
  html body .gf-page-actions, html body .op-head-actions { margin-left: 0 !important; width: 100%; }
  html body .gf-page-actions .btn, html body .op-head-actions .btn { flex: 1 1 auto; justify-content: center; }
  html body .of-kpis { width: 100%; display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  html body .of-kpi { min-width: 0; padding: 10px 12px; }
  html body .of-kpi b { font-size: 18px; }

  /* Abas de Configurações: uma por linha quando não cabem. */
  html body .gf-settings-tabs { grid-auto-flow: row !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }

  /* Gráficos de barras por dia não empurram a largura (linha de membros). */
  html body .mb-div, html body .mb-mini { gap: 0 !important; min-width: 0; overflow: hidden; }
  html body .mb-heat { overflow-x: auto; }

  /* Cards e pills não deixam o texto vazar. */
  html body .card { min-width: 0; }
  html body .card b, html body .card strong { overflow-wrap: anywhere; }

  /* Barras fixas no rodapé respeitam a área segura do iPhone. */
  html body .of-save, html body .gs-bar { bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 560px) {
  html body .container, html body main.container.dashboard-container { padding-left: 14px !important; padding-right: 14px !important; }
  html body .of-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  html body .of-kpi small { font-size: 10.5px; }
}

/* Ponteiro grosso (toque): mais respiro em qualquer tamanho de tela. */
@media (pointer: coarse) {
  html body .btn.compact { min-height: 40px; }
  html body summary { min-height: 40px; }
}


/* ---------- Submenu: itens nunca passam da largura do menu (o nome comprido cortava a borda) ---------- */
html body .topbar.gf-nav .rp-nav-sub { min-width: 0; max-width: 100%; grid-template-columns: minmax(0, 1fr); }
html body .topbar.gf-nav .rp-nav-sub > .nav-link { min-width: 0 !important; max-width: 100% !important; width: auto; box-sizing: border-box !important; }
html body .topbar.gf-nav .rp-nav-sub > .nav-link > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Formulários: botão de salvar sozinho na linha não estica na largura toda ---------- */
html body .form-grid .field.full:has(> .btn:only-child) { display: flex; flex-direction: row; justify-content: flex-end; align-items: center; }
html body .form-grid .field.full > .btn:only-child { width: auto !important; min-width: 160px; padding-left: 22px; padding-right: 22px; }

/* Peças do menu que só aparecem no visual Lux. */
html:not(.lux) .topbar :is(.lx-sec, .lx-me, .lx-sub, .lx-snd) { display: none !important; }
