/* Ajustes do Apolytrosis sobre o template. O visual vem de assets/css/styles.min.css. */

/* Cor primária da marca (#264e81). O template deriva dela botões, links, selos, foco e o
   gradiente do cabeçalho; por isso basta redefinir a variável, sem editar o CSS do template. */
:root {
    --primary-rgb: 38, 78, 129;
}

/* A cor primária é escura; sobre as superfícies do tema escuro, textos e botões claros
   derivados dela usam um tom mais luminoso para manter a legibilidade. */
[data-theme-mode="dark"] .btn-primary-light,
[data-theme-mode="dark"] .text-primary,
[data-theme-mode="dark"] .bg-primary-transparent,
[data-theme-mode="dark"] .page-link {
    color: rgb(157, 185, 220) !important;
}

/* ---------------------------------------------------------------- Tipografia
   Nunito Sans no lugar da Inter do template: acolhedora e de leitura fácil, com números
   tabulares nas tabelas financeiras. O corpo sobe de 13 px para 14 px, e os pesos ficam em 400
   (texto), 500 (rótulos e títulos) e 600 (só totais e saldos de destaque). */
:root {
    --default-font-family: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

    /* Tons das tabelas, como na comparação aprovada. */
    --table-head-bg: #f7f8fa;
    --table-head-border: #e9ecf1;
    --table-row-border: #f0f2f5;
    --table-foot-border: #dfe3e9;
}

[data-theme-mode="dark"] {
    --table-head-bg: rgba(255, 255, 255, 0.04);
    --table-head-border: rgba(255, 255, 255, 0.1);
    --table-row-border: rgba(255, 255, 255, 0.06);
    --table-foot-border: rgba(255, 255, 255, 0.14);
}

body {
    font-size: 0.875rem;
}

.card.custom-card .card-header .card-title,
.card-title,
.modal-header .modal-title,
.page-header-breadcrumb h4,
.btn,
.form-label,
.badge {
    font-weight: 500;
}

/* ---------------------------------------------------------------- Tabelas
   O template aplica peso 500 a todas as células e o projeto usava linhas compactas com réguas em
   todas as linhas, o que dava aspecto de planilha. Aqui, como na comparação aprovada: cabeçalho
   cinza-claro em caixa alta, linhas arejadas com réguas suaves, números alinhados e destaque só
   no rodapé de totais. */
.table {
    --bs-table-hover-bg: rgba(var(--primary-rgb), 0.04);
    font-variant-numeric: tabular-nums;
}

.table td,
.table th,
.table tbody tr th {
    font-size: 0.875rem;
    font-weight: 400;
}

.table > :not(caption) > * > * {
    padding: 0.6875rem 0.75rem;
    border-bottom-color: var(--table-row-border);
}

.table.table-sm > :not(caption) > * > * {
    padding: 0.5rem 0.75rem;
}

.table > thead > tr > th,
.table thead tr th {
    background-color: var(--table-head-bg) !important;
    color: var(--text-muted) !important;
    padding-block: 0.5625rem;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    white-space: nowrap;
    border-bottom: 1px solid var(--table-head-border);
}

/* Cabeçalhos ordenáveis são botões: herdam o estilo do cabeçalho. */
.table thead th .btn-link {
    font: inherit;
    letter-spacing: inherit;
    text-transform: inherit;
    color: inherit !important;
}

.table > tbody > tr:last-child > * {
    border-bottom-width: 0;
}

.table > tfoot > tr > * {
    font-weight: 600;
    border-top: 1px solid var(--table-foot-border);
    border-bottom-width: 0;
}

/* Selos (tipo, situação) discretos, como na comparação aprovada. */
.table .badge {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
}

.table-hover > tbody > tr:hover > * {
    background-color: rgba(var(--primary-rgb), 0.035) !important;
}

/* Tabelas dentro de cartões encostam nas bordas do cartão, como no template. */
.card .table-responsive.border {
    border-color: var(--default-border) !important;
}

/* ---------------------------------------------------------------- Modais
   Larguras maiores que as do Bootstrap (500 / 800 / 1140 px): os formulários e detalhes do
   sistema têm muitos campos e tabelas de parcelas. */
.modal {
    --bs-modal-width: 640px;
}

@media (min-width: 992px) {
    .modal-lg,
    .modal-xl {
        --bs-modal-width: 960px;
    }
}

@media (min-width: 1200px) {
    .modal-xl {
        --bs-modal-width: 1200px;
    }
}

.modal-body {
    padding: 1.5rem;
}

/* O template capitaliza cada palavra dos títulos de cartão, o que não se aplica ao português. */
.card.custom-card .card-header .card-title,
.card-title {
    text-transform: none;
}

.header-logo img,
.authentication .desktop-logo,
.authentication .desktop-dark {
    height: 2rem;
}

.validation-message {
    display: block;
}

/* Aviso de reconexão do circuito interativo: os estados são classes aplicadas pelo Blazor. */
.apolytrosis-reconnect {
    display: none;
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 2000;
    max-width: 22rem;
}

.apolytrosis-reconnect.components-reconnect-show,
.apolytrosis-reconnect.components-reconnect-failed,
.apolytrosis-reconnect.components-reconnect-rejected {
    display: block;
}

.apolytrosis-reconnect .reconnect-failed,
.apolytrosis-reconnect.components-reconnect-failed .reconnect-retrying,
.apolytrosis-reconnect.components-reconnect-rejected .reconnect-retrying,
.apolytrosis-reconnect.components-reconnect-failed .reconnect-spinner,
.apolytrosis-reconnect.components-reconnect-rejected .reconnect-spinner {
    display: none;
}

.apolytrosis-reconnect.components-reconnect-failed .reconnect-failed,
.apolytrosis-reconnect.components-reconnect-rejected .reconnect-failed {
    display: block;
}

/* Impressão dos relatórios (e "Salvar como PDF"): só o conteúdo, sem menu, cabeçalho e filtros. */
@media print {
    .app-sidebar,
    .app-header,
    .page-header-breadcrumb,
    .footer,
    .no-print,
    .scrollToTop {
        display: none !important;
    }

    .main-content.app-content,
    .app-content {
        margin: 0 !important;
        padding: 0 !important;
    }

    body {
        background: #fff !important;
        font-size: 11px;
    }

    .card.custom-card {
        box-shadow: none !important;
        border: 0 !important;
    }

    .table > :not(caption) > * > * {
        padding: .25rem .5rem;
    }

    .print-only {
        display: block !important;
    }

    .statement-block {
        break-inside: avoid;
    }
}

.print-only {
    display: none;
}

/* Campos com botões do template (data, período, mês): mesma altura dos demais campos. */
.field-group > .btn,
.field-group > .input-group-text {
    padding-top: 0;
    padding-bottom: 0;
    line-height: 1;
}

.field-group > .input-group-text {
    border-color: var(--input-border, #dee2e6);
}

.field-group .form-control[readonly] {
    background-color: var(--custom-white, #fff);
    cursor: pointer;
}

/* Calendário acima dos modais do template. */
.flatpickr-calendar {
    z-index: 1090;
}

/* Listas pesquisáveis (Choices.js) com a altura dos demais campos. */
.search-select .choices {
    margin-bottom: 0;
}

.search-select .choices__inner {
    min-height: calc(1.5em + .75rem + 2px);
    padding: .25rem .5rem;
    font-size: inherit;
}

.search-select-sm .choices__inner {
    min-height: calc(1.5em + .5rem + 2px);
    padding: .125rem .375rem;
    font-size: .8125rem;
}

.search-select .choices__list--single {
    padding: .125rem 1.5rem .125rem .25rem;
}

.search-select .choices__list--dropdown,
.search-select .choices__list[aria-expanded] {
    z-index: 1060;
}

/* Tela inicial. */
.dashboard-hero {
    background: linear-gradient(120deg, rgb(var(--primary-rgb)) 0%, rgba(var(--primary-rgb), .85) 60%, rgba(var(--primary-rgb), .65) 100%);
    border: 0;
}

.dashboard-hero::after {
    content: "";
    position: absolute;
    right: -60px;
    top: -60px;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .08);
    pointer-events: none;
}

.dashboard-kpi {
    transition: transform .15s ease, box-shadow .15s ease;
}

.dashboard-kpi:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1.25rem rgba(var(--dark-rgb, 0, 0, 0), .08);
}

.dashboard-chart {
    min-height: 320px;
}

/* Estado vazio. */
.empty-state {
    padding: 2.5rem 1rem;
}

/* Login no estilo "cover" do template. */
.login-cover {
    position: relative;
    background:
        radial-gradient(circle at 85% 15%, rgba(255, 255, 255, .14) 0, rgba(255, 255, 255, 0) 40%),
        radial-gradient(circle at 10% 90%, rgba(255, 255, 255, .10) 0, rgba(255, 255, 255, 0) 35%),
        linear-gradient(150deg, rgb(var(--primary-rgb)) 0%, rgba(var(--primary-rgb), .82) 100%);
}

.login-features li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .45rem 0;
    opacity: .92;
}

.login-features i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: .5rem;
    background: rgba(255, 255, 255, .15);
    font-size: 1rem;
}

/* Avisos flutuantes. */
.app-toasts {
    z-index: 1100;
    margin-top: 4.5rem;
}

.app-toasts .toast {
    min-width: 300px;
    max-width: 420px;
    overflow: hidden;
    backdrop-filter: blur(6px);
    background-color: var(--custom-white, #fff);
    box-shadow: 0 .75rem 2rem rgba(0, 0, 0, .12);
    animation: app-toast-in .25s ease-out;
}

.app-toast-progress {
    height: 3px;
    opacity: .6;
    transform-origin: left;
    animation-name: app-toast-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

@keyframes app-toast-in {
    from { opacity: 0; transform: translateY(-.5rem); }
    to { opacity: 1; transform: none; }
}

@keyframes app-toast-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

/* Mensagens de lista vazia já existentes com o mesmo visual do EmptyState. */
.text-center.text-muted.py-5 > i.fs-1.d-block {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 4rem;
    height: 4rem;
    margin: 0 auto .85rem !important;
    border-radius: 50%;
    font-size: 1.75rem !important;
    color: rgb(var(--primary-rgb));
    background-color: rgba(var(--primary-rgb), .1);
}

.text-center.text-muted.py-5 > i.fs-1.d-block + p,
.text-center.text-muted.py-5 > i.fs-1.d-block + p.mb-0 {
    color: var(--default-text-color);
    font-weight: 600;
}

/* A lista pesquisável dentro de tabelas não pode ser cortada pela rolagem horizontal. */
.table-responsive:has(.search-select .choices.is-open) {
    overflow: visible;
}

.table .search-select {
    min-width: 16rem;
}

.dashboard-hero-avatar {
    color: #fff;
    background-color: rgba(255, 255, 255, .2);
    border: 2px solid rgba(255, 255, 255, .35);
}

/* Lista lateral de caixas e contas bancárias. */
.treasury-account {
    border-inline-start: 3px solid transparent;
    transition: background-color .15s ease;
}

.treasury-account:hover {
    background-color: rgba(var(--primary-rgb), .04);
}

.treasury-account.is-selected {
    border-inline-start-color: rgb(var(--primary-rgb));
    background-color: rgba(var(--primary-rgb), .08);
}

.account-insights .border {
    border-color: var(--default-border, #f1f1f1) !important;
}

/* Cartões das contas na visão geral da tesouraria. */
.treasury-card {
    display: block;
    transition: transform .15s ease, box-shadow .15s ease;
}

.treasury-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 .5rem 1.25rem rgba(0, 0, 0, .08);
}

.treasury-sparkline {
    min-height: 48px;
    margin: .5rem -.25rem 0;
}

/* Área de arrastar e soltar arquivos. */
.file-drop {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
    height: 100%;
    min-height: 88px;
    margin: 0;
    padding: 1rem 1.25rem;
    border: 2px dashed rgba(var(--primary-rgb), .35);
    border-radius: .5rem;
    background-color: rgba(var(--primary-rgb), .03);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.file-drop:hover,
.file-drop:focus-within {
    border-color: rgb(var(--primary-rgb));
    background-color: rgba(var(--primary-rgb), .07);
}

.file-drop.has-file {
    border-style: solid;
    border-color: rgba(var(--success-rgb), .5);
    background-color: rgba(var(--success-rgb), .05);
}

.file-drop-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Transferências. */
.transfer-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    color: rgb(var(--primary-rgb));
    background-color: rgba(var(--primary-rgb), .1);
}

.transfer-preview {
    background-color: rgba(var(--primary-rgb), .04);
    border: 1px dashed rgba(var(--primary-rgb), .25);
}

/* Texto procurado por uma regra do extrato. */
.rule-match {
    display: inline-flex;
    align-items: center;
    padding: .15rem .5rem;
    border-radius: .35rem;
    font-family: var(--bs-font-monospace);
    font-size: .8rem;
    color: rgb(var(--primary-rgb));
    background-color: rgba(var(--primary-rgb), .08);
}

.kpi-clickable {
    cursor: pointer;
}

.kpi-clickable:focus-visible {
    outline: 2px solid rgb(var(--primary-rgb));
    outline-offset: 2px;
}

/* Linha do tempo dos meses contábeis. */
.period-timeline {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: .4rem;
}

@media (max-width: 991.98px) {
    .period-timeline {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }
}

.period-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .1rem;
    padding: .5rem .25rem;
    border-radius: .5rem;
    border: 1px solid var(--default-border, #f1f1f1);
    font-size: .75rem;
    color: var(--text-muted, #8c9097);
}

.period-tile i {
    font-size: 1rem;
}

.period-tile .period-name {
    font-weight: 600;
}

.period-tile.is-active {
    color: rgb(var(--success-rgb));
    background-color: rgba(var(--success-rgb), .08);
    border-color: rgba(var(--success-rgb), .3);
}

.period-tile.is-settled {
    color: rgb(var(--info-rgb));
    background-color: rgba(var(--info-rgb), .08);
    border-color: rgba(var(--info-rgb), .3);
}

.period-tile.is-closed {
    color: rgb(var(--primary-rgb));
    background-color: rgba(var(--primary-rgb), .1);
    border-color: rgba(var(--primary-rgb), .35);
}

/* Central de relatórios: cartões com a cor do grupo e um destaque ao passar o mouse. */
.report-card {
  height: calc(100% - 1.5rem);
  border-top: 3px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.report-card:hover,
.report-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.08);
}

.report-card-primary:hover, .report-card-primary:focus-visible { border-top-color: rgb(var(--primary-rgb)); }
.report-card-info:hover, .report-card-info:focus-visible { border-top-color: rgb(var(--info-rgb)); }
.report-card-success:hover, .report-card-success:focus-visible { border-top-color: rgb(var(--success-rgb)); }
.report-card-warning:hover, .report-card-warning:focus-visible { border-top-color: rgb(var(--warning-rgb)); }
.report-card-secondary:hover, .report-card-secondary:focus-visible { border-top-color: rgb(var(--secondary-rgb)); }

.report-card-open {
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  transform: translateX(-4px);
}

.report-card:hover .report-card-open,
.report-card:focus-visible .report-card-open {
  opacity: 1;
  transform: none;
}

/* Barra de participação nas tabelas dos relatórios (ex.: resultado por centro de custo). */
.report-share {
  height: 6px;
  min-width: 4rem;
}

/* Alinhamento das tabelas: um dado por coluna, células centradas na vertical, cabeçalhos sem
   quebra e algarismos de largura fixa, para que valores, datas e números fiquem alinhados. */
.table > :not(caption) > * > * {
  vertical-align: middle;
}

.table > thead th {
  white-space: nowrap;
}

.table td,
.table th {
  font-variant-numeric: tabular-nums;
}

.table .font-monospace {
  font-size: 0.8125rem;
}

.table-percent {
  min-width: 2.75rem;
  text-align: right;
}

/* Diário: a linha do lançamento destaca-se das partidas. */
.journal-entry-head > td {
  background-color: rgba(var(--light-rgb), 0.6);
}

/* Colunas de texto livre (descrição, histórico, observações) não se espremem a uma palavra por
   linha quando a tabela tem muitas colunas; a tabela rola na horizontal se precisar. */
.table td.text-wrap {
  min-width: 11rem;
}

/* Centros de custo em acordeão: cada grupo abre e fecha com os filhos dentro; todas as linhas
   usam a mesma grade, para as colunas ficarem alinhadas em qualquer nível. */
.cc-tree-scroll {
  overflow-x: auto;
}

.cc-tree {
  min-width: 58rem;
}

.cc-grid {
  display: grid;
  grid-template-columns: minmax(16rem, 1fr) 7.5rem 7rem minmax(8rem, 12rem) 7rem 12.5rem;
  align-items: center;
  column-gap: 1rem;
  padding: 0.55rem 1rem;
}

.cc-head {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 0;
}

.cc-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cc-accordion .cc-item {
  border: 1px solid var(--default-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.cc-row.cc-root {
  background-color: rgba(var(--primary-rgb), 0.04);
}

.cc-children .cc-row {
  border-top: 1px dashed var(--default-border);
}

.cc-row:hover {
  background-color: rgba(var(--primary-rgb), 0.06);
}

.cc-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

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

.cc-toggle,
.cc-toggle-space {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
}

.cc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 0.375rem;
  background: rgba(var(--primary-rgb), 0.1);
  color: rgb(var(--primary-rgb));
  padding: 0;
}

.cc-toggle i {
  font-size: 1.1rem;
  transition: transform 0.15s ease;
}

.cc-toggle.open i {
  transform: rotate(90deg);
}

/* Demonstrações em acordeão: o grupo mostra o total e abre ou recolhe as contas. Na impressão
   tudo aparece aberto. */
.statement-accordion .statement-section > th {
  --bs-table-bg: rgba(var(--primary-rgb), 0.06);
  --bs-table-accent-bg: rgba(var(--primary-rgb), 0.06);
  background-color: rgba(var(--primary-rgb), 0.06) !important;
  cursor: pointer;
  user-select: none;
}

.statement-accordion .statement-section:hover > th {
  background-color: rgba(var(--primary-rgb), 0.12) !important;
}

.statement-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  margin-right: 0.375rem;
  border-radius: 0.25rem;
  background: rgba(var(--primary-rgb), 0.12);
  color: rgb(var(--primary-rgb));
}

.statement-chevron i {
  transition: transform 0.15s ease;
}

.statement-block.open .statement-chevron i {
  transform: rotate(90deg);
}

.statement-block.collapsed .statement-line {
  display: none;
}

.notes-accordion .accordion-body p:last-child {
  margin-bottom: 0;
}

@media print {
  .statement-block.collapsed .statement-line {
    display: table-row !important;
  }

  .statement-chevron {
    display: none;
  }

  .notes-accordion .collapse {
    display: block !important;
  }
}

/* Caixas e contas bancárias em tabela: a linha escolhida fica marcada e abre o livro abaixo. */
.treasury-accounts tr.treasury-account {
  cursor: pointer;
  border-inline-start: 0;
}

.treasury-accounts tr.treasury-account.is-selected > td {
  background-color: rgba(var(--primary-rgb), 0.08) !important;
}

.treasury-accounts tr.treasury-account.is-selected > td:first-child {
  box-shadow: inset 3px 0 0 rgb(var(--primary-rgb));
}

/* Ações das linhas em posições fixas: quando um botão não se aplica, um espaço vazio do mesmo
   tamanho ocupa o lugar, para os botões ficarem alinhados de linha a linha. */
.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.25rem;
}

.table-action-slot {
  display: inline-block;
  width: 1.75rem;
  height: 1.75rem;
}

.table-action-text {
  min-width: 5.5rem;
}

/* Demonstrações: colunas de valores com a mesma largura em todas as tabelas, para os números
   ficarem um sob o outro; a seta e o código têm colunas próprias e estreitas. */
.statement-table {
  table-layout: fixed;
  width: 100%;
}

.statement-table .statement-col-toggle {
  width: 2.75rem;
}

.statement-table .statement-col-code {
  width: 7.5rem;
}

.statement-table .statement-col-value,
.statement-table col.statement-col-value {
  width: 11.5rem;
}

.statement-table td,
.statement-table th {
  overflow-wrap: anywhere;
}

.statement-table td.text-end,
.statement-table th.text-end {
  white-space: nowrap;
}

/* Dados tabulares em caixa alta, por padrão, em todas as tabelas (inclusive as linhas do
   acordeão de centros de custo). Campos de digitação e listas de seleção dentro das tabelas
   mantêm o texto como foi digitado. */
.table > tbody > tr > td,
.table > tbody > tr > th,
.table > tfoot > tr > td,
.table > tfoot > tr > th,
.cc-row {
  text-transform: uppercase;
}

.table input,
.table textarea,
.table select,
.table .choices,
.table .form-control,
.table .form-select {
  text-transform: none;
}
