/*
 * Card #64: tema escuro (preto e cinza) do sistema dos clientes. Ativo com body.theme-dark, que o
 * index.html só coloca fora das rotas de impressão, e só para tela: PDF e admin não mudam.
 * Cores de destaque dos indicadores (laranja, azul, verde...) continuam as mesmas.
 */
@media screen {
    html:has(body.theme-dark), body.theme-dark { background-color: #121417 !important; color: #e6e9ec; }
    .theme-dark .wrap-content, .theme-dark .container { background-color: transparent; }

    /* Header, menu lateral e cabeçalhos das telas */
    .theme-dark .main-header, .theme-dark .second-header, .theme-dark .campaign-header {
        background-color: #1a1d21 !important; color: #e6e9ec; border-color: #2c3238 !important;
    }
    /* Logo (#793): versão para fundo escuro, letras claras e pino vermelho mantido (cabeçalho e rodapé do detalhe) */
    .theme-dark .main-header__brand--logo { background-image: url("../img/svg/original/infooh-dark.svg"); }
    .theme-dark .logo-infooh--light { display: none; }
    .theme-dark .logo-infooh--dark { display: inline; }
    .theme-dark .main-header__user, .theme-dark .main-header__link,
    .theme-dark .second-header__title, .theme-dark .second-header * { color: #e6e9ec; }
    .theme-dark .main-aside { background-color: #1a1d21 !important; border-right: 1px solid #2c3238; }
    .theme-dark .main-aside .n-menu-active { background-color: #F52F42 !important; }

    /* Cards */
    .theme-dark .n-div-card, .theme-dark .top-card .n-div-card, .theme-dark .panel,
    .theme-dark .well, .theme-dark .list-group-item {
        background-color: #1e2227 !important; color: #e6e9ec; border-color: #2c3238 !important;
        box-shadow: none;
    }
    .theme-dark .n-card-label-value, .theme-dark .n-div-card-title, .theme-dark h1, .theme-dark h2,
    .theme-dark h3, .theme-dark h4 { color: #f0f3f6 !important; }
    .theme-dark .n-card-label-title, .theme-dark .n-div-card-subtitle, .theme-dark .n-font-legenda-xl,
    .theme-dark label { color: #aeb8c2; }
    .theme-dark .n-border-title, .theme-dark .n-border-inside, .theme-dark .n-border-cp,
    .theme-dark hr { border-color: #2c3238 !important; }

    /* Tabelas */
    .theme-dark table, .theme-dark .table { color: #e6e9ec; background-color: transparent; }
    .theme-dark .table > thead > tr > th, .theme-dark .table > tbody > tr > td,
    .theme-dark td, .theme-dark th { border-color: #2c3238 !important; }
    .theme-dark .table-striped > tbody > tr:nth-of-type(odd), .theme-dark .n-table-tr:nth-child(odd),
    .theme-dark .mp-audtable tbody tr:nth-child(odd) { background-color: #23282e !important; }
    .theme-dark .mp-audtable td.mp-aud-val, .theme-dark .mp-audtable tbody th { color: #e6e9ec !important; }
    /* Mídia Programática: subtítulos, rótulos das tabelas e separadores */
    .theme-dark .midia-prog-container .n-div-card-subtitle { color: #aeb8c2 !important; }
    .theme-dark .mp-audtable tbody th, .theme-dark .mp-audtable tbody td:first-child { color: #aeb8c2 !important; }
    .theme-dark .mp-audtable th, .theme-dark .mp-audtable td { border-color: #2c3238 !important; }
    .theme-dark [style*="border-top: 1px solid #E4E9E8" i], .theme-dark .mp-sec-im,
    .theme-dark .campaign-detail-compact .midia-prog-container > .mp-sec-im { border-top-color: #2c3238 !important; }
    .theme-dark .mp-audtable { border-color: #2c3238 !important; }
    .theme-dark .mp-audtable tbody th { background-color: #23282e !important; }

    /* Comparativo e demais tabelas do detalhe: linhas alternadas em cinza, texto claro */
    .theme-dark .n-table-comparativo thead th, .theme-dark .n-table-comparativo tbody tr,
    .theme-dark .n-table-comparativo td, .theme-dark .n-table-comparativo th {
        background-color: #1e2227 !important; border-color: #2c3238 !important;
    }
    .theme-dark .n-table-comparativo tbody tr:nth-child(even) td,
    .theme-dark .n-table-comparativo tbody tr:nth-child(even) th { background-color: #23282e !important; }
    .theme-dark .n-table-comparativo td, .theme-dark .n-table-td { color: #e6e9ec !important; }
    .theme-dark .n-table-comparativo th { color: #aeb8c2; }

    /* Tabela "Detalhes da campanha" (#792): texto claro nas linhas e na mensagem de nenhum resultado
       (o .n-table td do tema claro força #2d3b42 com !important) e destaque legível com o mouse.
       Restrito a .n-table-tr; a tabela de locais da criação/edição (sem .n-table-tr) tem bloco próprio (#807). */
    .theme-dark .n-table .n-table-tr td { color: #e6e9ec !important; }
    .theme-dark .n-table-tr:hover, .theme-dark .n-table-tr:nth-child(odd):hover { background-color: #2f363e !important; }

    /* Perfil social: tabelas de faixas etárias e de faixas horárias (#795). Linhas alternadas em cinza
       escuro (o th global pinta #f2f2f2), números/total claros, rótulos cinza (#677C85 inline) mais
       claros e célula selecionada com texto claro. Rótulos coloridos (faixas, classes, dias) não mudam. */
    .theme-dark .n-table-social tr:nth-child(odd) { background-color: #23282e !important; }
    .theme-dark .n-table-social th { background-color: transparent !important; }
    .theme-dark .n-table-social td { color: #e6e9ec !important; border-color: #2c3238 !important; }
    .theme-dark .n-table-social td:hover { background-color: #2a3036; }
    .theme-dark .n-table-social [style*="color:#677C85" i],
    .theme-dark .n-table-social [style*="color: #677C85" i] { color: #aeb8c2 !important; }
    .theme-dark .n-table-social .fa-eye { filter: brightness(1.7); }
    .theme-dark [class*="n-table-selected-"], .theme-dark .n-24h-selected,
    .theme-dark .n-24h-partial { color: #f0f3f6 !important; }

    /* Cabeçalho das tabelas de locais (#795): "Detalhes da campanha" (inclui a aba Perfil Social) e,
       pela mesma classe, a tabela de locais da criação/edição. Fundo escuro e títulos claros. */
    .theme-dark .n-table > thead > tr, .theme-dark .n-table > thead > tr > th,
    .theme-dark .n-table-campaign > thead > tr, .theme-dark .n-table-campaign > thead > tr > th {
        background-color: #1e2227 !important;
    }
    .theme-dark .n-table > thead > tr > th, .theme-dark .n-table-campaign > thead > tr > th { color: #aeb8c2 !important; }
    .theme-dark .n-table, .theme-dark .n-table-campaign { border-color: #2c3238 !important; }

    /* Tabela de locais da criação/edição (#807): painel, zebra, hover e textos no mesmo padrão da
       "Detalhes da campanha". Escopado em .n-form-cities (não altera a tabela do detalhe). O texto claro
       vale para td, span e label (coluna Código); o tooltip do endereço mantém o branco sobre #555.
       Quadradinho do checkbox (sprite opaco: branco desmarcado, vermelho marcado) não muda. */
    .theme-dark .n-form-cities { background-color: #1e2227 !important; box-shadow: none !important; }
    .theme-dark .n-form-cities .n-table > tbody > tr { background-color: transparent; }
    .theme-dark .n-form-cities .n-table > tbody > tr:nth-child(odd) { background-color: #23282e !important; }
    .theme-dark .n-form-cities #cities-table:hover,
    .theme-dark .n-form-cities #cities-table:nth-child(odd):hover { background-color: #2f363e !important; }
    .theme-dark .n-form-cities .n-table td, .theme-dark .n-form-cities .n-table td span:not(.tooltiptext),
    .theme-dark .n-form-cities .n-table td label { color: #e6e9ec !important; }
    .theme-dark .n-form-cities .checkbox-skin .see_more { color: #aeb8c2; }
    /* Botão "Limpar lista" e aba lateral recolhida "Locais / Locais Selecionadas" (#807);
       botão vermelho da aba não muda (cor de destaque) */
    .theme-dark .n-select-clean { background-color: #2a3036 !important; color: #e6e9ec !important; border: 1px solid #3a414a; }
    .theme-dark .n-select-clean:hover, .theme-dark .n-select-clean:focus { background-color: #2f363e !important; }
    .theme-dark .main-nav__helper { background-color: #1e2227 !important; box-shadow: -2px 0 15px -3px rgba(0, 0, 0, 0.5); }
    .theme-dark .main-nav__helper .n-color-navtext { color: #aeb8c2; }

    /* Abas do detalhe da campanha (#792): ativa e inativas legíveis; o sublinhado da ativa usa currentColor */
    .theme-dark .n-card-tabbed-item { color: #aeb8c2; }
    .theme-dark .n-card-tabbed-item-active { color: #f0f3f6; }

    /* Lista de campanhas, carregamento e calendário */
    .theme-dark .campaign-header__title { background-color: transparent !important; color: #f0f3f6 !important; }
    .theme-dark .campaign-header__form, .theme-dark .n-form-search { background-color: #24292f !important; }
    .theme-dark .campaign-header__form input { background-color: transparent !important; }
    .theme-dark article.card, .theme-dark .card { background-color: #1e2227 !important; border-color: #2c3238 !important; box-shadow: none; }
    .theme-dark .card__title { color: #f0f3f6 !important; }
    .theme-dark .card__info, .theme-dark .card__date { color: #aeb8c2 !important; }
    .theme-dark .block-ui-overlay { background-color: rgba(18, 20, 23, 0.6) !important; }
    .theme-dark .flatpickr-calendar, .theme-dark .flatpickr-months .flatpickr-month,
    .theme-dark .flatpickr-weekdays, .theme-dark span.flatpickr-weekday {
        background: #1e2227 !important; color: #e6e9ec !important; fill: #e6e9ec;
    }
    .theme-dark .flatpickr-day { color: #e6e9ec; }
    .theme-dark .flatpickr-day.flatpickr-disabled, .theme-dark .flatpickr-day.prevMonthDay,
    .theme-dark .flatpickr-day.nextMonthDay { color: #5c6670; }

    /* Campos, dropdowns e modais */
    .theme-dark input, .theme-dark select, .theme-dark textarea, .theme-dark .form-control,
    .theme-dark .mp-select, .theme-dark .mp-inp, .theme-dark .n-div-search,
    .theme-dark .special-searchable-dropdown, .theme-dark .input-group-addon {
        background-color: #24292f !important; color: #e6e9ec !important; border-color: #3a414a !important;
    }
    .theme-dark .mp-inp input { background-color: transparent !important; }
    .theme-dark .dropdown-menu, .theme-dark .modal-content, .theme-dark .popover {
        background-color: #1e2227 !important; color: #e6e9ec; border-color: #2c3238 !important;
    }
    .theme-dark .dropdown-menu > li > a, .theme-dark .dropdown-menu a { color: #e6e9ec !important; }
    .theme-dark .dropdown-menu > li > a:hover, .theme-dark .searchable-option:hover { background-color: #2a3036 !important; }
    .theme-dark .btn-default { background-color: #2a3036; color: #e6e9ec; border-color: #3a414a; }
    .theme-dark .close { color: #e6e9ec; }

    /* Fundos e textos escuros que estavam inline no HTML */
    .theme-dark [style*="background-color: white" i], .theme-dark [style*="background: white" i],
    .theme-dark [style*="background-color: #fff" i], .theme-dark [style*="background: #fff" i],
    .theme-dark [style*="background-color:#fff" i], .theme-dark [style*="background:#fff" i],
    .theme-dark [style*="background: #fafafa" i], .theme-dark [style*="background-color: #f5f5f5" i],
    .theme-dark [style*="background: #f5f5f5" i], .theme-dark [style*="background-color: #f6fff8" i] {
        background-color: #1e2227 !important;
    }
    .theme-dark [style*="color: #253B42" i], .theme-dark [style*="color:#253B42" i],
    .theme-dark [style*="color: #2D3B42" i], .theme-dark [style*="color:#2D3B42" i],
    .theme-dark [style*="color: #333" i], .theme-dark [style*="color:#333" i] { color: #e6e9ec !important; }

    /* Setas de período/desconto e divisórias dos cards (CPM, investimento, perfil) */
    .theme-dark .discount__button { background: #24292f !important; }
    .theme-dark .discount__button i { color: #c3ccd5; }
    .theme-dark .n-border-right-target, .theme-dark .n-border-right-card { border-right-color: #2c3238 !important; }
    .theme-dark .n-border-frota, .theme-dark .n-border-investimento { border-color: #2c3238 !important; }

    /* Números das classes sociais e barras de rolagem horizontais */
    .theme-dark .n-span-seg-number:not(.n-span-seg-number-2) { color: #f0f3f6; }
    .theme-dark [style*="overflow-x: auto"], .theme-dark .scroll-wrapper { scrollbar-color: #4a525b #1e2227; }

    /* Criação/edição de campanha: seletores com moldura própria (.select-skin), lista "Cidade"
       (fundo com seta em imagem) e painel lateral dos locais escolhidos (reteste #763, R04) */
    .theme-dark .select-skin { background-color: #24292f !important; border-color: #3a414a !important; }
    .theme-dark .select-skin__value, .theme-dark .select-skin .select-arrow { color: #e6e9ec !important; }
    .theme-dark .select-skin::after { filter: invert(0.88) hue-rotate(180deg); }
    .theme-dark .special-searchable-dropdown { background-image: none !important; position: relative; }
    .theme-dark .special-searchable-dropdown::after {
        content: ''; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -6px;
        border-right: 2px solid #c3ccd5; border-bottom: 2px solid #c3ccd5; transform: rotate(45deg); pointer-events: none;
    }
    .theme-dark .main-nav__content { background-color: #1e2227 !important; border-color: #2c3238 !important; }
    .theme-dark .main-nav__content td, .theme-dark .main-nav__content th,
    .theme-dark .main-nav__content li, .theme-dark .main-nav__content span { color: #e6e9ec; border-color: #2c3238 !important; }
    .theme-dark .main-nav__content .n-color-places { color: #e6e9ec !important; }

    /* Busca e mapa (card #59) */
    .theme-dark mark.search-hit { background: #6b5a00; color: #fff3a3; }
    .theme-dark .map-heat-legend { background: rgba(30, 34, 39, 0.92); color: #e6e9ec; }
    .theme-dark .map-heat-legend-labels { color: #aeb8c2; }
    /* Janelas de informação do mapa (pin, busca no mapa, local de interesse, via): o Google mantém
       a janela branca, então o texto volta a ser escuro dentro dela (#792) */
    .theme-dark .gm-style .gm-style-iw-c { color: #333; }

    /* Busca de locais na criação/edição (#792): linha já adicionada com fundo escuro esverdeado
       (o ng-style grava rgb(), que o seletor de #f6fff8 não pega) e textos secundários legíveis */
    .theme-dark .addr-suggest .addr-added { background-color: #1c2a22 !important; }
    .theme-dark .addr-suggest [style*="color: #888" i], .theme-dark .addr-suggest [style*="color: #666" i] { color: #aeb8c2 !important; }
    .theme-dark .addr-suggest [style*="border-bottom" i] { border-bottom-color: #2c3238 !important; }
    /* Lista SEGMENTOS do detalhe (#807): linha marcada em azul escuro (o ng-style grava rgb(240, 247, 255),
       que nenhum seletor [style*=...] pega). Links e ícones #417690 ficam como cor de destaque. */
    .theme-dark .seg-row-selected { background-color: #1f3347 !important; }

    /* Paginação (Bootstrap) da lista de campanhas e da busca de locais (#795): botões escuros,
       página atual no azul de destaque, desabilitados acinzentados e legíveis */
    .theme-dark .pagination > li > a, .theme-dark .pagination > li > span {
        background-color: #24292f; color: #e6e9ec; border-color: #3a414a;
    }
    .theme-dark .pagination > li > a:hover, .theme-dark .pagination > li > a:focus,
    .theme-dark .pagination > li > span:hover, .theme-dark .pagination > li > span:focus {
        background-color: #2a3036; color: #f0f3f6; border-color: #3a414a;
    }
    .theme-dark .pagination > .active > a, .theme-dark .pagination > .active > span,
    .theme-dark .pagination > .active > a:hover, .theme-dark .pagination > .active > a:focus,
    .theme-dark .pagination > .active > span:hover, .theme-dark .pagination > .active > span:focus {
        background-color: #337ab7; color: #fff; border-color: #337ab7;
    }
    .theme-dark .pagination > .disabled > a, .theme-dark .pagination > .disabled > span,
    .theme-dark .pagination > .disabled > a:hover, .theme-dark .pagination > .disabled > a:focus,
    .theme-dark .pagination > .disabled > span:hover, .theme-dark .pagination > .disabled > span:focus {
        background-color: #24292f; color: #8b96a1; border-color: #3a414a;
    }

    /* Botão de tema no header */
    .theme-toggle { cursor: pointer; margin: 0 14px; font-size: 16px; color: #677C85; }
    .theme-dark .theme-toggle { color: #FFBD24; }
}
