﻿/* ==========================================================
   PÁGINA
========================================================== */

.alteracoes-page {

    display: flex;

    flex-direction: column;

    gap: 24px;
}

/* ==========================================================
   KPI + CHART TOGGLE
========================================================= */

.btn-toggle-kpi {
    white-space: nowrap;
}

.kpi-chart-section {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-top: 24px;
}

/* ==========================================================
   CABEÇALHO
========================================================== */

.page-header {

    display: flex;

    justify-content: space-between;

    align-items: center;

    gap: 20px;
}

.page-header-info {

    display: flex;

    flex-direction: column;

    gap: 6px;
}

.page-header-info h2 {

    font-size: 28px;

    font-weight: 700;

    color: var(--title, var(--text));
}

.page-header-info p {

    color: var(--text-dim);

    font-size: 14px;
}

.data-atualizacao {

    color: var(--text-dim);

    font-size: 12px;

    font-style: italic;
}

/* ==========================================================
   ABAS DSGov (br-tab) — Dashboard / Dados
   O visual base (nav, item ativo, sublinhado, hover) vem do
   core do DSGov. Aqui ajustamos apenas o encaixe no layout.
   ========================================================== */

/* O espaçamento entre o box de filtros e as abas é o gap do
   .alteracoes-page; evita somar com o margin-bottom do painel. */
.alteracoes-page > .filter-panel {
    margin-bottom: 0;
}

.visao-tabs {
    width: 100%;
}

.visao-tabs .tab-content {
    padding-top: 24px;
}

.visao-tabs .tab-panel > .jornal-section,
.visao-tabs .tab-panel > .table-section {
    margin-top: 0;
}

/* ==========================================================
   KPI
========================================================== */

.kpi-section {

    display: flex;

    flex-direction: column;

    gap: 16px;
}

/* ==========================================================
   GRÁFICOS
========================================================== */

.charts-grid {

    display: grid;

    grid-template-columns: 1fr;

    gap: 20px;
}

.chart-card {

    background: var(--card-bg);

    border: 1px solid var(--border);

    border-radius: var(--radius-lg);

    padding: 20px;
}

.chart-title {

    font-size: 14px;

    font-weight: 600;

    margin-bottom: 16px;
}

/* ==========================================================
   CANVAS
========================================================== */

.chart-card canvas {

    width: 100% !important;

    height: 240px !important;
}

/* ==========================================================
   TABELA
========================================================= */

.table-section {

    display: flex;

    flex-direction: column;

    gap: 12px;
}

/* ===== Toolbar (prototype style) ===== */

.table-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 14px 22px;
    margin-bottom: 10px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-group h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.construtor-title {
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text, inherit);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--input-radius);
    padding: 4px 8px;
    width: 260px;
    outline: none;
}

.construtor-title:focus,
.construtor-title:not(:placeholder-shown) {
    border-color: var(--border);
    background: var(--bg-elevated, transparent);
}

.construtor-title::placeholder {
    font-weight: 500;
    color: var(--text-muted, #888);
    opacity: 1;
}

.font-size-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ===== Buttons (prototype style) ===== */

.btn-ghost {
    padding: 5px 12px;
    font-size: 11.5px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--card-bg);
    color: var(--text-dim);
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    white-space: nowrap;
}

.btn-ghost:hover {
    border-color: var(--primary-dim);
    color: var(--text);
}

/* ===== Botões conforme DS Gov.br — secundário pequeno (32px) ===== */

.btn-icon-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 32px;
    height: 32px;
    padding: 0 16px;
    border: 1px solid var(--primary);
    border-radius: 100em;
    background: transparent;
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.btn-icon-label:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-hover);
}

.btn-icon-label svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

/* Divisor entre ícone e rótulo (padrão de botão "médio" do DS) */

.btn-icon-label svg + span {
    border-left: 1px solid currentColor;
    margin-left: 8px;
    padding-left: 8px;
}

/* ===== Botões conforme DS Gov.br — terciário pequeno (32px) ===== */

.btn-font {
    min-height: 32px;
    height: 32px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 100em;
    background: transparent;
    color: var(--text-dim);
    font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
    font-weight: 600;
    font-size: 12px;
}

.btn-font:hover {
    background: var(--primary-soft);
    border-color: transparent;
    color: var(--primary);
}

.ctrl-val {
    font-size: 11.5px;
    color: var(--text-faint);
    min-width: 20px;
    text-align: center;
    font-family: 'JetBrains Mono', 'Cascadia Code', monospace;
}

/* ===== Construtor de Tabela ===== */

.construtor-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.construtor-picker {
    position: relative;
}

.construtor-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 280px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,.3);
    overflow: hidden;
}

.construtor-panel.open {
    display: block;
}

.construtor-options {
    max-height: 260px;
    overflow-y: auto;
    padding: 0 4px 8px;
}

.construtor-table-wrap {
    max-height: 520px;
}

.construtor-table thead th,
#tabelaHead th,
.frozen-construtor-header th {
    text-align: left;
    cursor: grab;
    user-select: none;
    white-space: nowrap;
}

.construtor-table thead th:active,
#tabelaHead th:active,
.frozen-construtor-header th:active {
    cursor: grabbing;
}

.construtor-table thead th:hover,
#tabelaHead th:hover,
.frozen-construtor-header th:hover {
    color: var(--primary);
}

.construtor-table thead th.dragging,
#tabelaHead th.dragging,
.frozen-construtor-header th.dragging {
    opacity: 0.45;
}

.construtor-table thead th.drag-over,
#tabelaHead th.drag-over,
.frozen-construtor-header th.drag-over {
    box-shadow: inset 0 3px 0 var(--primary);
}

.construtor-table .col-label,
#tabelaHead .col-label,
.frozen-construtor-header .col-label {
    display: inline-block;
    vertical-align: middle;
}

.construtor-table .col-filter,
#tabelaHead .col-filter,
.frozen-construtor-header .col-filter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 3px;
    vertical-align: middle;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    flex: none;
}

.construtor-table .col-filter:hover,
#tabelaHead .col-filter:hover,
.frozen-construtor-header .col-filter:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.construtor-table .col-filter.active,
#tabelaHead .col-filter.active,
.frozen-construtor-header .col-filter.active {
    color: var(--primary);
}

.btn-limpar-construtor:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.btn-limpar-construtor:disabled {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.construtor-filter-popup {
    display: none;
    position: fixed;
    z-index: 1000;
    width: 300px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.construtor-filter-popup.open {
    display: block;
}

.filter-head {
    padding: 8px;
    border-bottom: 1px solid var(--border-soft);
}

.filter-search {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 10px;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--input-radius);
    outline: none;
}

.filter-search:focus {
    border-color: var(--primary);
}

.filter-checkall {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    border-bottom: 1px solid var(--border-soft);
    user-select: none;
}

.filter-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 6px 4px;
}

.filter-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.filter-item:hover {
    background: var(--card-bg);
}

.filter-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-faint);
    font-size: 12px;
}

.filter-actions {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px;
    border-top: 1px solid var(--border-soft);
}

/* ==========================================================
   RESUMO
========================================================== */

.resumo-box {

    background: var(--card-bg);

    border: 1px solid var(--border);

    border-radius: var(--radius-lg);

    padding: 16px;

    color: var(--text-dim);

    line-height: 1.6;
}

/* ==========================================================
   RESPONSIVO
========================================================== */

@media (max-width: 768px) {

    .page-header {

        flex-direction: column;

        align-items: flex-start;
    }

    .page-header-info h2 {
        font-size: 22px;
    }

    .page-header > div:last-child {
        width: 100%;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-group {
        flex-wrap: wrap;
    }

    .construtor-title {
        width: 100%;
        box-sizing: border-box;
    }

    .cards-grid {

        grid-template-columns: 1fr;
    }

    .chart-card canvas {

        height: 200px !important;
    }

    .construtor-table-wrap,
    .data-table-wrap {
        overflow-x: auto;
    }
}
