/*!
 * Tema SGF — camada visual sobre o AdminLTE 3 / Bootstrap 4.
 *
 * Como funciona
 *  - Tudo fica dentro de body.sgf-theme: páginas sem a classe continuam com o visual do AdminLTE.
 *  - body.sgf-theme-layout também aplica o tema ao menu lateral e ao cabeçalho (layout global).
 *  - A ativação é feita em config/sgf.php (SGF_TEMA): "adminlte", "financeiro" ou "sgf".
 *  - Cores, fontes, raios e sombras ficam nas variáveis --sgf-* (seção 1). Para mudar o visual,
 *    altere as variáveis; para trocar o AdminLTE no futuro, as mesmas variáveis e os componentes
 *    .sgf-* (seção 6) servem de base para o novo tema.
 *
 * Seções: 1 tokens · 2 base · 3 layout (menu e cabeçalho) · 4 conteúdo · 5 componentes Bootstrap/AdminLTE
 *         · 6 componentes SGF · 7 plugins (Select2, DataTables, SweetAlert) · 8 modo escuro
 */

/* 1. Tokens ---------------------------------------------------------------------------------- */
:root {
  --sgf-font: "Plus Jakarta Sans", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  --sgf-grafite-900: #3b4249;
  --sgf-grafite-800: #4b545c;
  --sgf-grafite-700: #5f6b76;
  --sgf-grafite-600: #7a8691;
  --sgf-grafite-100: #e4e8ec;
  --sgf-grafite-050: #f1f3f5;
  --sgf-orange-500: #f0a03a;
  --sgf-orange-600: #e08a1e;
  --sgf-green-600: #1f9d63;
  --sgf-red-600: #d64545;
  --sgf-yellow-500: #e9b23a;

  --sgf-bg: #f4f5f7;
  --sgf-surface: #ffffff;
  --sgf-surface-muted: #f8f9fa;
  --sgf-border: #e4e7ea;
  --sgf-border-strong: #d0d5da;
  --sgf-text: #2f353b;
  --sgf-text-muted: #6c757d;
  --sgf-text-soft: #9aa1a8;
  --sgf-heading: #3b4249;

  /* Botões, paginação ativa e destaques. --sgf-on-primary é a cor do texto sobre o primário. */
  --sgf-primary: var(--sgf-grafite-700);
  --sgf-primary-hover: #525d67;
  --sgf-on-primary: #ffffff;
  --sgf-link: #4f5a64;
  --sgf-accent: var(--sgf-orange-500);
  --sgf-focus-ring: 0 0 0 3px rgba(95, 107, 118, .2);

  --sgf-radius-sm: 6px;
  --sgf-radius: 10px;
  --sgf-radius-lg: 14px;
  --sgf-shadow-sm: 0 1px 2px rgba(33, 37, 41, .05);
  --sgf-shadow: 0 1px 3px rgba(33, 37, 41, .06), 0 6px 18px rgba(33, 37, 41, .05);

  --sgf-sidebar-bg: var(--sgf-grafite-900);
  --sgf-sidebar-text: #c8cdd2;
  --sgf-sidebar-text-active: #ffffff;
  --sgf-sidebar-hover: rgba(255, 255, 255, .06);
  --sgf-sidebar-active: rgba(255, 255, 255, .1);
  --sgf-header-bg: #ffffff;
}

/* 2. Base ------------------------------------------------------------------------------------ */
body.sgf-theme {
  font-family: var(--sgf-font);
  color: var(--sgf-text);
  font-size: .925rem;
  -webkit-font-smoothing: antialiased;
}
body.sgf-theme .content-wrapper { background: var(--sgf-bg); }
body.sgf-theme h1, body.sgf-theme h2, body.sgf-theme h3,
body.sgf-theme h4, body.sgf-theme h5, body.sgf-theme h6 { color: var(--sgf-heading); font-weight: 700; letter-spacing: -.01em; }
body.sgf-theme a { color: var(--sgf-link); }
body.sgf-theme .text-muted { color: var(--sgf-text-muted) !important; }
body.sgf-theme hr { border-top-color: var(--sgf-border); }

/* 3. Layout global (menu lateral e cabeçalho) — somente com body.sgf-theme-layout --------------- */
body.sgf-theme-layout .main-sidebar,
body.sgf-theme-layout .main-sidebar .brand-link { background: var(--sgf-sidebar-bg) !important; }
body.sgf-theme-layout .main-sidebar .brand-link { border-bottom-color: rgba(255, 255, 255, .08) !important; }
body.sgf-theme-layout .main-sidebar .user-panel {
  border-bottom: 0;
  margin: .75rem .5rem !important;
  padding: .6rem .5rem !important;
  border-radius: var(--sgf-radius);
  background: rgba(255, 255, 255, .05);
  border: 1px solid rgba(255, 255, 255, .07);
}
body.sgf-theme-layout .main-sidebar .user-panel a { color: #fff; font-weight: 600; font-size: .85rem; }
body.sgf-theme-layout .nav-sidebar .nav-header {
  color: #8f979e;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
body.sgf-theme-layout .nav-sidebar .nav-link {
  color: var(--sgf-sidebar-text) !important;
  font-size: .86rem;
  border-radius: var(--sgf-radius-sm);
  margin: 1px .25rem;
}
body.sgf-theme-layout .nav-sidebar .nav-link:hover { background: var(--sgf-sidebar-hover); color: #fff !important; }
body.sgf-theme-layout .nav-sidebar > .nav-item.menu-open > .nav-link,
body.sgf-theme-layout .nav-sidebar > .nav-item > .nav-link.active {
  background: var(--sgf-sidebar-active) !important;
  color: var(--sgf-sidebar-text-active) !important;
  box-shadow: none !important;
}
body.sgf-theme-layout .nav-treeview > .nav-item > .nav-link { font-size: .82rem; padding-left: 1.6rem; }
body.sgf-theme-layout .nav-treeview > .nav-item > .nav-link .nav-icon { font-size: .45rem; vertical-align: middle; }
body.sgf-theme-layout .nav-treeview > .nav-item > .nav-link.active {
  background: rgba(240, 160, 58, .12) !important;
  color: #fff !important;
  box-shadow: inset 3px 0 0 var(--sgf-accent) !important;
}
body.sgf-theme-layout .main-header.navbar {
  background: var(--sgf-header-bg);
  border-bottom: 1px solid var(--sgf-border);
  box-shadow: none;
}
body.sgf-theme-layout .main-header .nav-link { color: var(--sgf-text-muted); }
body.sgf-theme-layout .main-header .nav-link:hover { color: var(--sgf-heading); }

/* 4. Conteúdo (cabeçalho da página) ----------------------------------------------------------- */
body.sgf-theme .content-header { padding: 1.1rem .5rem .6rem; }
body.sgf-theme .content-header h1,
body.sgf-theme .content-header h1.lead { font-size: 1.45rem; font-weight: 600; color: var(--sgf-heading); }
body.sgf-theme .content-header .breadcrumb { background: transparent; font-size: .85rem; margin: 0; padding: .35rem 0; }
body.sgf-theme .content-header .breadcrumb.lead { font-size: .85rem; }
body.sgf-theme .content-header .breadcrumb-item,
body.sgf-theme .content-header .breadcrumb-item a { color: var(--sgf-text-muted); }
body.sgf-theme .content-header .breadcrumb-item.active,
body.sgf-theme .content-header .breadcrumb-item.active a { color: var(--sgf-heading); font-weight: 600; }

/* 5. Componentes Bootstrap / AdminLTE ----------------------------------------------------------- */

/* Cards */
body.sgf-theme .card {
  border: 1px solid var(--sgf-border);
  border-radius: var(--sgf-radius);
  box-shadow: var(--sgf-shadow-sm);
  background: var(--sgf-surface);
}
body.sgf-theme .card.card-outline { border-top: 1px solid var(--sgf-border) !important; }
body.sgf-theme .card > .card-header {
  background: transparent;
  border-bottom: 1px solid var(--sgf-border);
  padding: .9rem 1.15rem;
}
body.sgf-theme .card:not(.card-outline-tabs) > .card-header { border-radius: var(--sgf-radius) var(--sgf-radius) 0 0; }
body.sgf-theme .card-title { font-size: .98rem; font-weight: 700; color: var(--sgf-heading); }
body.sgf-theme .card-title > i:first-child,
body.sgf-theme .card-title > .fas:first-child,
body.sgf-theme .card-title > .far:first-child { color: var(--sgf-primary); }
body.sgf-theme .card-body { padding: 1.15rem; }
body.sgf-theme .card-footer { background: var(--sgf-surface-muted); border-top-color: var(--sgf-border); }
body.sgf-theme .card-primary:not(.card-outline) > .card-header,
body.sgf-theme .card-info:not(.card-outline) > .card-header {
  background: var(--sgf-surface);
  color: var(--sgf-heading);
  box-shadow: inset 0 3px 0 var(--sgf-primary);
}
body.sgf-theme .card-primary:not(.card-outline) > .card-header .card-title,
body.sgf-theme .card-info:not(.card-outline) > .card-header .card-title { color: var(--sgf-heading); }
body.sgf-theme .card-primary:not(.card-outline) > .card-header .btn-tool,
body.sgf-theme .card-info:not(.card-outline) > .card-header .btn-tool { color: var(--sgf-text-muted); }
body.sgf-theme .card-with-border { border: 1px solid var(--sgf-border); border-radius: var(--sgf-radius); }

/* Abas (card-outline-tabs) */
body.sgf-theme .card-outline-tabs > .card-header { padding: 0 .75rem; border-bottom: 1px solid var(--sgf-border); }
body.sgf-theme .card-outline-tabs > .card-header .nav-tabs { border-bottom: 0; }
body.sgf-theme .card-outline-tabs > .card-header .nav-link,
body.sgf-theme .nav-tabs .nav-link {
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0;
  color: var(--sgf-text-muted);
  font-weight: 600;
  font-size: .86rem;
  padding: .85rem 1rem .75rem;
  margin-bottom: -1px;
  background: transparent;
}
body.sgf-theme .card-outline-tabs > .card-header .nav-link:hover,
body.sgf-theme .nav-tabs .nav-link:hover { color: var(--sgf-heading); }
body.sgf-theme .card-outline-tabs > .card-header .nav-link.active,
body.sgf-theme .nav-tabs .nav-link.active {
  color: var(--sgf-heading) !important;
  border-bottom-color: var(--sgf-accent) !important;
  background: transparent !important;
}

/* Formulários */
body.sgf-theme label:not(.form-check-label):not(.custom-file-label):not(.custom-control-label) {
  font-size: .8rem;
  font-weight: 600;
  color: var(--sgf-heading);
  margin-bottom: .3rem;
}
body.sgf-theme .form-control,
body.sgf-theme .custom-select {
  border: 1px solid var(--sgf-border-strong);
  border-radius: var(--sgf-radius-sm);
  font-size: .88rem;
  color: var(--sgf-text);
  background-color: var(--sgf-surface);
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
body.sgf-theme .form-control:not(textarea):not([multiple]):not(.form-control-sm):not(.form-control-lg) { height: calc(2.35rem + 2px); }
body.sgf-theme .form-control::placeholder { color: var(--sgf-text-soft); }
body.sgf-theme .form-control:focus,
body.sgf-theme .custom-select:focus { border-color: var(--sgf-primary); box-shadow: var(--sgf-focus-ring); }
body.sgf-theme .form-control[readonly],
body.sgf-theme .form-control:disabled { background: var(--sgf-surface-muted); }
body.sgf-theme .input-group-text {
  background: var(--sgf-surface-muted);
  border-color: var(--sgf-border-strong);
  color: var(--sgf-text-muted);
  font-size: .85rem;
}
body.sgf-theme .input-group > .input-group-prepend > .input-group-text { border-radius: var(--sgf-radius-sm) 0 0 var(--sgf-radius-sm); }
body.sgf-theme .form-text { font-size: .76rem; }
body.sgf-theme .custom-file-label { border-color: var(--sgf-border-strong); border-radius: var(--sgf-radius-sm); font-size: .86rem; }

/* Botões */
body.sgf-theme .btn { border-radius: var(--sgf-radius-sm); font-weight: 600; font-size: .86rem; }
body.sgf-theme .btn-sm, body.sgf-theme .btn-group-sm > .btn { font-size: .8rem; }
body.sgf-theme .btn-xs { font-size: .74rem; border-radius: 4px; }
body.sgf-theme .btn-primary { background: var(--sgf-primary); border-color: var(--sgf-primary); color: var(--sgf-on-primary); }
body.sgf-theme .btn-primary:hover, body.sgf-theme .btn-primary:focus { background: var(--sgf-primary-hover); border-color: var(--sgf-primary-hover); color: var(--sgf-on-primary); }
body.sgf-theme .btn-success { background: var(--sgf-green-600); border-color: var(--sgf-green-600); }
body.sgf-theme .btn-success:hover { background: #198553; border-color: #198553; }
body.sgf-theme .btn-outline-primary { color: var(--sgf-primary); border-color: var(--sgf-primary); }
body.sgf-theme .btn-outline-primary:hover { background: var(--sgf-primary); color: var(--sgf-on-primary); }
body.sgf-theme .btn:focus, body.sgf-theme .btn.focus { box-shadow: var(--sgf-focus-ring); }

/* Tabelas */
body.sgf-theme .table { color: var(--sgf-text); font-size: .86rem; }
body.sgf-theme .table thead th {
  border-bottom: 1px solid var(--sgf-border-strong);
  border-top: 0;
  color: var(--sgf-text-muted);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
body.sgf-theme .table td, body.sgf-theme .table th { border-top-color: var(--sgf-border); vertical-align: middle; }
body.sgf-theme .table-striped tbody tr:nth-of-type(odd) { background: var(--sgf-surface-muted); }
body.sgf-theme .table-hover tbody tr:hover,
body.sgf-theme .table tbody tr:hover { background: var(--sgf-grafite-050); }
body.sgf-theme .table-bordered, body.sgf-theme .table-bordered td, body.sgf-theme .table-bordered th { border-color: var(--sgf-border); }

/* Selos, alertas, modais */
body.sgf-theme .badge { font-weight: 600; border-radius: 999px; padding: .32em .65em; }
body.sgf-theme .alert { border-radius: var(--sgf-radius); border-width: 1px; font-size: .88rem; }
body.sgf-theme .alert-warning { background: #fff7e8; border-color: #f5d79e; color: #7a5410; }
body.sgf-theme .alert-danger { background: #fdeeee; border-color: #f2c2c2; color: #8a2424; }
body.sgf-theme .alert-info { background: var(--sgf-grafite-050); border-color: var(--sgf-grafite-100); color: var(--sgf-grafite-800); }
body.sgf-theme .alert-secondary { background: var(--sgf-surface-muted); border-color: var(--sgf-border); color: var(--sgf-text-muted); }
body.sgf-theme .modal-content { border: 0; border-radius: var(--sgf-radius-lg); box-shadow: 0 20px 50px rgba(33, 37, 41, .25); }
body.sgf-theme .modal-header, body.sgf-theme .modal-footer { border-color: var(--sgf-border); }
body.sgf-theme .modal-title { font-weight: 700; color: var(--sgf-heading); font-size: 1.05rem; }

/* Small-box (indicadores) */
body.sgf-theme .small-box {
  border-radius: var(--sgf-radius);
  box-shadow: var(--sgf-shadow-sm);
  overflow: hidden;
}
body.sgf-theme .small-box > .inner h3 { font-weight: 700; letter-spacing: -.02em; color: inherit; }
body.sgf-theme .small-box > .inner p { font-weight: 500; font-size: .85rem; }
body.sgf-theme .small-box .icon > i { opacity: .25; }
body.sgf-theme .small-box.bg-info { background: var(--sgf-grafite-600) !important; color: #fff !important; }
body.sgf-theme .small-box.bg-primary { background: var(--sgf-grafite-700) !important; color: #fff !important; }
body.sgf-theme .small-box.bg-success { background: var(--sgf-green-600) !important; }
body.sgf-theme .small-box.bg-warning { background: var(--sgf-orange-500) !important; color: #3d2706 !important; }
body.sgf-theme .small-box.bg-danger { background: var(--sgf-red-600) !important; }
body.sgf-theme .small-box.bg-secondary { background: #6c757d !important; }

/* 6. Componentes SGF (usar em telas novas) ------------------------------------------------------ */

/* Seção de formulário: título forte, descrição curta e divisória, como no SGC. */
body.sgf-theme .sgf-section { padding-bottom: 1.25rem; margin-bottom: 1.25rem; border-bottom: 1px solid var(--sgf-border); }
body.sgf-theme .sgf-section:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
body.sgf-theme .sgf-section-title { font-size: .95rem; font-weight: 700; color: var(--sgf-heading); margin: 0; }
body.sgf-theme .sgf-section-desc,
body.sgf-theme .sgf-card-desc { display: block; font-size: .76rem; font-weight: 400; color: var(--sgf-text-muted); margin: .15rem 0 0; letter-spacing: 0; }
@media (min-width: 992px) {
  body.sgf-theme .sgf-col-divider { border-left: 1px solid var(--sgf-border); }
}

/* Rótulo pequeno em caixa alta, usado acima de títulos. */
.sgf-eyebrow { display: inline-block; font-size: .7rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--sgf-primary); }

/* Área de anexos tracejada. */
body.sgf-theme .sgf-dropzone {
  border: 2px dashed var(--sgf-border-strong);
  border-radius: var(--sgf-radius);
  background: var(--sgf-surface-muted);
  padding: 1.5rem;
  text-align: center;
  color: var(--sgf-text-muted);
}

/* 7. Plugins ------------------------------------------------------------------------------------ */
body.sgf-theme .select2-container--bootstrap4 .select2-selection {
  border-color: var(--sgf-border-strong);
  border-radius: var(--sgf-radius-sm);
  font-size: .88rem;
}
body.sgf-theme .select2-container--bootstrap4.select2-container--focus .select2-selection { border-color: var(--sgf-primary); box-shadow: var(--sgf-focus-ring); }
body.sgf-theme .select2-container--bootstrap4 .select2-results__option--highlighted { background: var(--sgf-primary); color: var(--sgf-on-primary); }
body.sgf-theme .dataTables_wrapper .dataTables_filter input,
body.sgf-theme .dataTables_wrapper .dataTables_length select { border-radius: var(--sgf-radius-sm); border-color: var(--sgf-border-strong); }
/*
 * Paginação: números na cor do texto; a página atual usa o primário com número branco.
 * Seletores com .page-item para vencer o modo escuro do AdminLTE; !important porque sgc-custom.css
 * força a cor dos números (color: #444 / inherit !important) e pinta de azul/verde no modo escuro.
 */
body.sgf-theme .page-item .page-link { color: var(--sgf-text) !important; background: var(--sgf-surface) !important; border: 1px solid var(--sgf-border) !important; border-radius: var(--sgf-radius-sm); font-weight: 600; }
body.sgf-theme .page-item .page-link:hover { color: var(--sgf-heading) !important; background: var(--sgf-grafite-100) !important; border-color: var(--sgf-border-strong) !important; }
body.sgf-theme .page-item.active .page-link,
body.sgf-theme .page-item.active .page-link:hover,
body.sgf-theme .page-item.active .page-link:focus { color: var(--sgf-on-primary) !important; background: var(--sgf-primary) !important; border-color: var(--sgf-primary) !important; }
body.sgf-theme .page-item.disabled .page-link { color: var(--sgf-text-soft) !important; background: var(--sgf-surface) !important; border-color: var(--sgf-border) !important; }
body.sgf-theme .dt-buttons .btn { font-size: .78rem; }
body.sgf-theme .swal2-popup { font-family: var(--sgf-font); border-radius: var(--sgf-radius-lg); }
body.sgf-theme .swal2-title { color: var(--sgf-heading); font-size: 1.35rem; }

/* 8. Modo escuro ------------------------------------------------------------------------------- */
body.sgf-theme.dark-mode {
  --sgf-bg: #1f2327;
  --sgf-surface: #2a2f34;
  --sgf-surface-muted: #32383e;
  --sgf-border: #3e454c;
  --sgf-border-strong: #4f575f;
  --sgf-text: #e3e6e9;
  --sgf-text-muted: #b0b8bf;
  --sgf-text-soft: #8c949c;
  --sgf-heading: #f3f4f6;
  --sgf-grafite-050: rgba(255, 255, 255, .05);
  --sgf-grafite-100: rgba(255, 255, 255, .1);
  --sgf-grafite-800: #d5dade;
  /* No escuro o botão primário é cinza claro com texto escuro, para não sumir no fundo. */
  --sgf-primary: #9aa5af;
  --sgf-primary-hover: #b0b9c1;
  --sgf-on-primary: #1c2024;
  --sgf-link: #c7ced5;
  --sgf-focus-ring: 0 0 0 3px rgba(154, 165, 175, .3);
  --sgf-header-bg: #2a2f34;
  --sgf-sidebar-bg: #24292d;
}
body.sgf-theme.dark-mode .content-wrapper { background: var(--sgf-bg); }
body.sgf-theme.dark-mode .card,
body.sgf-theme.dark-mode .modal-content { background: var(--sgf-surface); }
body.sgf-theme.dark-mode .form-control,
body.sgf-theme.dark-mode .custom-select { background-color: var(--sgf-surface-muted); color: var(--sgf-text); }
body.sgf-theme.dark-mode .alert-warning { background: rgba(240, 160, 58, .12); border-color: rgba(240, 160, 58, .35); color: #f6cf8e; }
body.sgf-theme.dark-mode .alert-danger { background: rgba(214, 69, 69, .12); border-color: rgba(214, 69, 69, .35); color: #f3b0b0; }
body.sgf-theme.dark-mode .alert-info { background: rgba(173, 181, 189, .1); border-color: rgba(173, 181, 189, .25); color: #dee2e6; }
body.sgf-theme.dark-mode .small-box.bg-info { background: #4f5a64 !important; }
body.sgf-theme.dark-mode .small-box.bg-primary { background: #5f6b76 !important; }

/* 9. Ajustes de páginas existentes ------------------------------------------------------------- */

/*
 * Cartões dentro de cartões viram seções separadas por uma linha fina, como no SGC:
 * título forte + descrição curta (.sgf-card-desc) + campos, sem caixas aninhadas.
 */
body.sgf-theme .card-outline-tabs > .card-body > .tab-content > .tab-pane > .card {
  border: 0 !important;
  box-shadow: none;
  background: transparent;
}
body.sgf-theme .card-outline-tabs > .card-body > .tab-content > .tab-pane > .card > .card-header,
body.sgf-theme .card-outline-tabs > .card-body > .tab-content > .tab-pane > .card > .card-body { padding-left: 0; padding-right: 0; }
body.sgf-theme .card .card-body .card {
  border: 0 !important;
  border-top: 1px solid var(--sgf-border) !important;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  margin-bottom: 0;
}
body.sgf-theme .card .card-body .card-outline-tabs > .card { border-top: 0 !important; }
body.sgf-theme .card .card-body .card > .card-header {
  border-bottom: 0;
  padding: 1.1rem 0 .25rem;
}
body.sgf-theme .card .card-body .card > .card-body { padding: .75rem 0 .5rem; }
body.sgf-theme .card .card-body .card .card-title { font-size: .95rem; }
