/* =========================================================================
   M.A.P.A. — Sistema visual (tema claro)
   Monitoramento e Acompanhamento em Pesquisas Avançadas

   Princípios: fundo branco, tipografia calma, uma cor de marca (verde
   escuro) usada com parcimônia nos detalhes, bordas finas em vez de
   sombras e brilhos. Referência de sensação: Notion / Linear.

   Tokens (também declarados no tailwind.config em includes/head_app.php):
     brand-700  #17573A   ação primária, links, ícones ativos
     brand-800  #124630   hover da ação primária
     brand-50   #EEF6F1   fundos de destaque suave
     ink        #14201A   texto principal
     ink-2      #4B5751   texto secundário
     ink-3      #7A857F   texto auxiliar / placeholders
     ink-4      #A9B2AD   texto desabilitado
     surface    #FFFFFF   página e cartões
     surface-2  #F7F9F8   painéis, sidebar, cabeçalhos de tabela
     surface-3  #EEF2F0   hover, chips neutros
     line       #E4E9E6   bordas padrão
     line-2     #CFD7D3   bordas de inputs
   ========================================================================= */

:root {
    --brand-50: #EEF6F1;
    --brand-100: #D6EADD;
    --brand-200: #B3D6C1;
    --brand-300: #7FB898;
    --brand-500: #2E7D52;
    --brand-700: #17573A;
    --brand-800: #124630;
    --ink: #14201A;
    --ink-2: #4B5751;
    --ink-3: #7A857F;
    --ink-4: #A9B2AD;
    --surface: #FFFFFF;
    --surface-2: #F7F9F8;
    --surface-3: #EEF2F0;
    --line: #E4E9E6;
    --line-2: #CFD7D3;
    --sidebar-w: 15rem;
    --bottom-nav-h: 4rem;
}

/* ---------- Ritmo vertical ----------
   Três níveis, e só eles. Mobile primeiro; no desktop cada um sobe um degrau.
     --space-in     dentro de um bloco (rótulo → valor, itens de lista)
     --space-block  entre blocos irmãos (cartões, grupos de campos)
     --space-sect   entre seções da página                                   */
:root {
    --space-in:    0.75rem;   /* 12px */
    --space-block: 1.25rem;   /* 20px */
    --space-sect:  2.5rem;    /* 40px */
    --page-x:      1rem;
    --page-top:    1.5rem;
}
@media (min-width: 768px) {
    :root {
        --space-in:    1rem;      /* 16px */
        --space-block: 1.5rem;    /* 24px */
        --space-sect:  3.5rem;    /* 56px */
        --page-x:      2rem;
        --page-top:    2.5rem;
    }
}

/* Utilitários da escala
   .page         container: largura máxima, gutter lateral e topo
   .stack-in / .stack / .stack-sect   filhos separados pelo nível correspondente
   .sect-head    título de seção + ação opcional
   .panel        cartão neutro: borda fina, sem sombra
   .eyebrow      rótulo pequeno em caixa alta
   .stat         número grande de indicador
   .rowlist      lista de linhas separadas por filete, sem molduras           */
.page { max-width: 72rem; margin: 0 auto; padding: var(--page-top) var(--page-x) 0; }
.page--narrow { max-width: 46rem; }
.stack-in   > * + * { margin-top: var(--space-in); }
.stack      > * + * { margin-top: var(--space-block); }
.stack-sect > * + * { margin-top: var(--space-sect); }
.sect-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: var(--space-in); }
.sect-head h2, .sect-head h3 { font-size: 1rem; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.panel { background: var(--surface); border-radius: 1.25rem; padding: 1.25rem; box-shadow: 0 1px 2px rgba(20, 32, 26, 0.04), 0 2px 8px rgba(20, 32, 26, 0.04); }
.panel--muted { background: var(--surface-2); box-shadow: none; }
.panel--dashed { background: transparent; box-shadow: none; border: 1px dashed var(--line-2); padding: 3.5rem 1.25rem; }
.panel--flush { padding: 0; }
.card-pad { padding: 1.25rem; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.card-head h3 { font-size: 1.125rem; line-height: 1.3; font-weight: 600; letter-spacing: -0.01em; color: var(--ink); }
.card-head p { font-size: 0.875rem; line-height: 1.4; color: var(--ink-3); margin-top: 0.25rem; }
.card-body { padding: 0 1.25rem 1.25rem; }
.eyebrow { font-size: 0.75rem; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-3); }
.stat { font-size: 1.75rem; line-height: 1.1; font-weight: 600; letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.fieldlist > *, .rowlist > * { padding: var(--space-in) 0; border-top: 1px solid var(--line); }
.fieldlist > *:first-child, .rowlist > *:first-child { border-top: 0; padding-top: 0; }
.fieldlist > *:last-child, .rowlist > *:last-child { padding-bottom: 0; }
.rowlist > * { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
@media (min-width: 768px) {
    .panel { padding: 1.5rem; }
    .panel--flush { padding: 0; }
    .panel--dashed { padding: 4rem 1.5rem; }
    .card-pad { padding: 1.5rem; }
    .card-body { padding: 0 1.5rem 1.5rem; }
    .stat { font-size: 2rem; }
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
html body {
    font-family: 'Inter', 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background-color: var(--surface);
    background-image: none;
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
::selection { background: var(--brand-100); color: var(--ink); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 8px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
.hide-scrollbar::-webkit-scrollbar { display: none; }
.hide-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* Inputs nativos herdam a fonte e a cor do tema */
input, select, textarea, button { font-family: inherit; }
select option { background: var(--surface); color: var(--ink); }
input[type="date"]::-webkit-calendar-picker-indicator { opacity: 0.6; cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }

/* ---------- Cartões e campos (nomes mantidos das views antigas) ---------- */
html .glass-card {
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 1px 2px rgba(20, 32, 26, 0.04);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
html .glass-card:hover {
    border-color: var(--line-2);
    box-shadow: 0 1px 3px rgba(20, 32, 26, 0.06);
}
html .glass-input {
    background: var(--surface);
    border: 1px solid var(--line-2);
    color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease;
}
html .glass-input:focus,
html .glass-input:focus:not(:read-only),
html .glass-input:focus:not(:disabled) {
    outline: none;
    background: var(--surface);
    border-color: var(--brand-500);
    box-shadow: 0 0 0 3px var(--brand-100);
}
html .glass-input:read-only { background: var(--surface-2); color: var(--ink-2); }
html .glass-input:disabled { background: var(--surface-2); color: var(--ink-4); cursor: not-allowed; opacity: 1; }

/* Toggle (switch) usado nas telas de configuração */
.toggle-label { background-color: var(--line-2); }
.toggle-checkbox { border-color: var(--line-2); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.toggle-checkbox:checked { right: 0; border-color: currentColor; }
.toggle-checkbox:checked + .toggle-label { background-color: currentColor; }

/* ---------- Estrutura: sidebar (desktop) + barra inferior (mobile) ---------- */
@media (min-width: 768px) {
    body.has-sidebar { padding-left: var(--sidebar-w); }
    body.has-sidebar .pb-dock,
    body.has-sidebar .pb-safe-dock { padding-bottom: 3rem; }
}
.pb-dock { padding-bottom: calc(var(--bottom-nav-h) + 2rem); }
.pb-safe-dock { padding-bottom: calc(var(--bottom-nav-h) + 2rem + env(safe-area-inset-bottom, 0px)); }
.bottom-nav { padding-bottom: env(safe-area-inset-bottom, 0px); }

.nav-item { color: var(--ink-2); }
.nav-item:hover { background: var(--surface-3); color: var(--ink); }
.nav-item.is-active { background: var(--surface-3); color: var(--ink); font-weight: 500; }
.nav-item.is-active svg { color: var(--brand-700); }

/* ---------- Modais ---------- */
.modal-content { transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1), opacity .2s ease; }
#actionModal .modal-content { transform: translateY(100%); }
#actionModal.active .modal-content { transform: translateY(0); }
@media (min-width: 768px) {
    #actionModal .modal-content { transform: translateY(8px); opacity: 0; }
    #actionModal.active .modal-content { transform: translateY(0); opacity: 1; }
}

/* ---------- Impressão ---------- */
@media print {
    body.has-sidebar { padding-left: 0; }
    #appSidebar, #appTopbar, .bottom-nav, #toast-container, #pwa-install-card { display: none !important; }
}
