﻿/* ==============================
   PÁGINA FINANCIAMENTO CLIMÁTICO
   ============================== */

body.fin-cli-page .rb-main {
    background: transparent;
    max-width: 100%;
    margin: 0;
    padding: 0;
    flex-grow: 1;
}

/* ── WRAPPER ── */
.fc-page {
    padding: 24px 28px 40px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ── INTRO ── */
.fc-intro h2 {
    font-family: 'Sora', 'Roboto', sans-serif;
    font-size: 1.375rem;
    font-weight: 700;
    color: #101d4f;
    margin: 0 0 6px;
}

.fc-intro p {
    font-size: 0.875rem;
    color: #1a3070;
    font-style: italic;
    line-height: 1.65;
    margin: 0;
}

/* ── PAINEL (filtros + gráficos + ações) ── */
.fc-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(16,29,79,.10);
    padding: 18px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ── BARRA DE FILTROS ── */
.fc-filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    border-bottom: 1px solid #eef2f5;
    padding-bottom: 16px;
    /* Cria stacking context acima dos gráficos (flex items posteriores
       competem por z-index com o dropdown — sem isso o dropdown vai para trás) */
    position: relative;
    z-index: 10;
}

.fc-filter-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 160px;
}

.fc-filter-label {
    font-size: 0.625rem;
    font-weight: 700;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: .07em;
    white-space: nowrap;
}

/* ── MULTI-SELECT DROPDOWN COM CHECKBOXES ── */
.fc-multiselect { position: relative; }
/* Eleva o filtro ativo acima dos irmãos no mesmo flex container */
.fc-multiselect.is-open { z-index: 20; }

.fc-ms-trigger {
    width: 100%;
    padding: 6px 30px 6px 10px;
    background: #f4f8fa;
    border: 1px solid #c8dde5;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
    color: #5577aa;
    font-family: inherit;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    transition: border-color var(--transition-fast), background var(--transition-fast);
    position: relative;
}

.fc-ms-trigger:hover,
.fc-ms-trigger.open {
    border-color: var(--color-primary);
    background: #fff;
}

.fc-ms-trigger-label {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.fc-ms-trigger-label.has-selection {
    color: var(--color-primary-dark);
    font-weight: 600;
}

.fc-ms-badge {
    background: var(--color-primary);
    color: #fff;
    border-radius: 999px;
    font-size: 0.625rem;
    font-weight: 700;
    padding: 1px 6px;
    flex-shrink: 0;
}

.fc-ms-arrow {
    flex-shrink: 0;
    color: var(--color-primary);
    transition: transform var(--transition-fast);
}

.fc-ms-trigger.open .fc-ms-arrow { transform: rotate(180deg); }

.fc-ms-dropdown {
    position: absolute;
    top: calc(100% + 3px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #c8dde5;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(16,29,79,.14);
    z-index: 1000;
    display: none;
    flex-direction: column;
    max-height: 260px;
    overflow: hidden;
}

/* Dropdown abrindo para cima (quando não há espaço abaixo) */
.fc-ms-dropdown.drop-up {
    top: auto;
    bottom: calc(100% + 3px);
    box-shadow: 0 -6px 20px rgba(16,29,79,.14);
}

.fc-ms-dropdown.open { display: flex; }

/* Modo fixed (mobile) — JS sobrescreve position/left/top via inline style;
   anulamos right:0 para não conflitar com a largura calculada pelo JS */
@media (max-width: 768px) {
    .fc-ms-dropdown {
        right: auto; /* largura controlada por JS (width inline) */
        border-radius: 10px;
        box-shadow: 0 8px 32px rgba(16,29,79,.22);
    }
}

.fc-ms-search {
    padding: 7px 8px 5px;
    border-bottom: 1px solid #eef2f5;
}

.fc-ms-search input {
    width: 100%;
    padding: 4px 8px;
    font-size: 0.6875rem;
    border: 1px solid #c8dde5;
    border-radius: 4px;
    font-family: inherit;
    color: var(--color-primary-dark);
    background: #f9fbfc;
    box-sizing: border-box;
}

.fc-ms-search input:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; border-color: var(--color-primary); }

.fc-ms-actions {
    display: flex;
    gap: 4px;
    padding: 5px 8px;
    border-bottom: 1px solid #eef2f5;
    align-items: center;
}

.fc-ms-action-btn {
    font-size: 0.625rem;
    color: var(--color-primary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    font-weight: 600;
    transition: background .1s;
}

.fc-ms-action-btn:hover { background: #edf6f9; }

.fc-ms-count-label {
    font-size: 0.625rem;
    color: #9bb;
    margin-left: auto;
}

.fc-ms-options {
    overflow-y: auto;
    flex: 1;
    min-height: 0;                     /* flex items têm min-height:auto por padrão — sem isso o
                                          item expande para mostrar todo o conteúdo em vez de
                                          restringir a altura e ativar o scroll */
    -webkit-overflow-scrolling: touch; /* inércia de scroll no iOS */
    overscroll-behavior: contain;      /* impede que o overscroll da lista propague para o window,
                                          evitando que o handler de scroll feche o dropdown */
    padding: 3px 0;
    scrollbar-width: thin;
    scrollbar-color: rgba(38,69,132,.2) transparent;
}

.fc-ms-options::-webkit-scrollbar { width: 4px; }
.fc-ms-options::-webkit-scrollbar-thumb {
    background: rgba(38,69,132,.2);
    border-radius: 4px;
}

.fc-ms-option {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.6875rem;
    color: #101d4f;
    line-height: 1.4;
    transition: background .1s;
    user-select: none;
    touch-action: manipulation;          /* elimina delay de 300ms no iOS */
    -webkit-tap-highlight-color: transparent; /* remove flash azul no toque */
}

.fc-ms-option:hover { background: #f4f9fb; }
.fc-ms-option.is-checked { background: #edf6f9; }

.fc-ms-option input[type="checkbox"] {
    accent-color: var(--color-primary);
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    margin-top: 1px;
    pointer-events: none; /* todos os cliques vão para o <label> pai — evita que o iOS
                             sintetize um segundo click forwarded para o <input>,
                             que causaria duplo-toggle e zero mudança visual */
}

.fc-ms-empty {
    padding: 14px 10px;
    font-size: 0.6875rem;
    color: #9bb;
    text-align: center;
}

/* ── GRÁFICOS ── */
.fc-charts {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.fc-chart-card {
    border: 1px solid #e8f0f3;
    border-radius: 8px;
    padding: 14px 12px 10px;
    background: #fafcfd;
    display: flex;
    flex-direction: column;
}

.fc-chart-title {
    font-family: 'Sora', 'Roboto', sans-serif;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    text-align: center;
    margin-bottom: 8px;
}

.fc-chart-area {
    flex: 1;
    min-height: 260px;
    height: 280px;
}

/* ── AÇÕES ── */
.fc-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #eef2f5;
    padding-top: 14px;
}

.fc-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-family: inherit;
    transition: background var(--transition-fast), opacity var(--transition-fast);
}

.fc-btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.fc-btn-primary:hover { background: #264584; }

.fc-btn-outline {
    background: transparent;
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
}
.fc-btn-outline:hover { background: #f0f8fb; }

/* ── TABELA ── */
.fc-table-wrap {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 16px rgba(16,29,79,.10);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.fc-loader {
    position: absolute;
    inset: 0;
    background: rgba(248,252,253,.92);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.875rem;
    color: var(--color-primary);
    z-index: 10;
    font-family: 'Roboto', sans-serif;
}

.fc-loader.hidden { display: none; }

.fc-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    font-family: 'Roboto', sans-serif;
}

.fc-table thead tr:first-child th {
    background: var(--color-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 10px 12px;
    text-align: center;
    border-right: 1px solid rgba(255,255,255,.15);
    white-space: nowrap;
    vertical-align: middle;
}

.fc-table thead tr:first-child th:last-child { border-right: none; }

.fc-table thead tr:nth-child(2) th {
    background: var(--color-primary);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 7px 12px;
    text-align: center;
    border-top: 1px solid rgba(255,255,255,.30);
    border-right: 1px solid rgba(255,255,255,.15);
}

.fc-th-group {
    border-left: 2px solid rgba(255,255,255,.30) !important;
}

.fc-table tbody tr {
    border-bottom: 1px solid #eef2f5;
    transition: background .12s;
}

.fc-table tbody tr:hover { background: #f4f9fb; }

.fc-table tbody tr:nth-child(even) { background: #fafcfd; }
.fc-table tbody tr:nth-child(even):hover { background: #f0f6f9; }

.fc-table td {
    padding: 10px 12px;
    vertical-align: top;
    color: #101d4f;
    line-height: 1.4;
    border-right: 1px solid #eef2f5;
}

.fc-table td:last-child { border-right: none; }
.fc-table td:first-child { font-weight: 500; color: var(--color-primary-dark); }

.fc-table td.fc-td-ente { border-left: 1px solid #dde8ed; }

/* ── PAGINAÇÃO ── */
.fc-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 14px 16px;
    border-top: 1px solid #eef2f5;
    font-size: 0.75rem;
    color: var(--color-primary);
    flex-wrap: wrap;
}

.fc-page-info {
    color: #5577aa;
    font-size: 0.6875rem;
    margin-right: 6px;
}

.fc-page-btn {
    min-width: 30px;
    height: 30px;
    padding: 0 8px;
    border: 1px solid #c8dde5;
    border-radius: 5px;
    background: #fff;
    color: var(--color-primary);
    font-size: 0.75rem;
    font-family: inherit;
    cursor: pointer;
    transition: background .12s, color .12s;
}

.fc-page-btn:hover { background: #f0f8fb; }
.fc-page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.fc-page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── ORIGEM DOS RECURSOS – WRAPPER SCROLL ── */
.fc-origem-scroll {
    overflow-y: auto;
    max-height: 280px;
    scrollbar-width: thin;
    scrollbar-color: rgba(38,69,132,.2) transparent;
}

.fc-origem-scroll::-webkit-scrollbar { width: 4px; }
.fc-origem-scroll::-webkit-scrollbar-thumb {
    background: rgba(38,69,132,.2);
    border-radius: 4px;
}

/* ── RESPONSIVO ── */
@media (max-width: 1100px) {
    .fc-charts { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {

    /* Página */
    .fc-page {
        padding: 12px 12px 32px;
        gap: 14px;
    }

    /* Intro */
    .fc-intro h2 {
        font-size: 1.0625rem;
        margin-bottom: 4px;
    }
    .fc-intro p {
        font-size: 0.78125rem;
        line-height: 1.55;
    }

    /* Painel */
    .fc-panel {
        padding: 14px 12px 14px;
        gap: 14px;
        border-radius: 10px;
    }

    /* Filtros */
    .fc-filters-bar {
        flex-direction: column;
        gap: 8px;
        padding-bottom: 14px;
    }
    .fc-filter-item {
        min-width: 100%;
    }
    /* Trigger maior para touch + feedback visual claro */
    .fc-ms-trigger {
        padding: 12px 14px;
        font-size: 0.875rem;
        border-radius: 10px;
        min-height: 48px; /* mínimo recomendado para touch targets (WCAG) */
    }
    /* Filtro ativo ganha borda destacada para indicar seleção em andamento */
    .fc-multiselect.is-open .fc-ms-trigger {
        border-color: var(--color-primary);
        background: #fff;
        box-shadow: 0 0 0 3px rgba(38,69,132,.12);
    }
    /* Itens do dropdown maiores para toque */
    .fc-ms-option {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }
    .fc-ms-option input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
    /* Buscar input maior */
    .fc-ms-search input {
        font-size: 0.8125rem;
        padding: 6px 10px;
    }
    /* Botões Todos/Nenhum mais acessíveis */
    .fc-ms-action-btn {
        font-size: 0.75rem;
        padding: 4px 10px;
        min-height: 32px;
    }

    /* Gráficos */
    .fc-charts {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .fc-chart-card {
        padding: 12px 10px 10px;
        border-radius: 8px;
    }
    .fc-chart-title {
        font-size: 0.75rem;
        margin-bottom: 6px;
    }
    .fc-chart-area {
        min-height: 200px;
        height: 220px;
    }
    .fc-origem-scroll {
        max-height: 220px;
    }

    /* Ações */
    .fc-actions {
        flex-direction: column;
        gap: 8px;
        padding-top: 14px;
        align-items: stretch;
    }
    .fc-btn {
        width: 100%;
        justify-content: center;
        padding: 13px 16px;
        font-size: 0.8125rem;
        font-weight: 600;
        border-radius: 8px;
        gap: 8px;
    }
    .fc-btn svg {
        width: 15px;
        height: 15px;
        flex-shrink: 0;
    }

    /* Tabela — layout de cartão no mobile */
    .fc-table-wrap {
        border-radius: 10px;
        overflow-x: visible;
        box-shadow: none;
        background: transparent;
    }
    .fc-table thead { display: none; }
    .fc-table,
    .fc-table tbody { display: block; width: 100%; }

    .fc-table tbody tr {
        display: block;
        background: #fff;
        border: 1px solid #dce8ef;
        border-radius: 12px;
        margin-bottom: 12px;
        overflow: hidden;
        box-shadow: 0 2px 6px rgba(16,29,79,.08);
    }

    /* Layout empilhado: label acima, valor abaixo */
    .fc-table tbody td {
        display: block;
        padding: 9px 14px;
        border-right: none;
        border-bottom: 1px solid #f0f5f8;
        font-size: 0.8125rem;
        white-space: normal;
        color: #1a2340;
        font-weight: 400;
        line-height: 1.45;
    }
    .fc-table tbody td:last-child { border-bottom: none; }
    .fc-table tbody td.fc-td-ente { border-left: none; }

    .fc-table tbody td::before {
        display: block;
        content: attr(data-label);
        font-size: 0.6875rem;
        font-weight: 700;
        color: var(--color-primary);
        text-transform: uppercase;
        letter-spacing: 0.07em;
        margin-bottom: 3px;
    }

    /* Primeira célula vira cabeçalho do cartão */
    .fc-table tbody td:first-child {
        display: block;
        background: var(--color-primary);
        color: #fff;
        font-size: 0.875rem;
        font-weight: 600;
        border-bottom: none;
        padding: 12px 14px;
        line-height: 1.4;
    }
    .fc-table tbody td:first-child::before { display: none; }

    /* Seção de Repasses — fundo diferenciado com separador */
    .fc-table tbody td:nth-child(7) {
        border-top: 2px solid #d0e5f0;
        background: #f4f9fc;
    }
    .fc-table tbody td:nth-child(8),
    .fc-table tbody td:nth-child(9) {
        background: #f4f9fc;
    }

    /* Paginação */
    .fc-pagination {
        padding: 10px 12px;
        gap: 4px;
    }
    .fc-page-btn {
        min-width: 40px;
        height: 40px;
        font-size: 0.6875rem;
    }
}

@media (max-width: 400px) {
    .fc-page {
        padding: 8px 8px 24px;
    }
    .fc-panel {
        padding: 12px 10px;
    }
    .fc-btn {
        padding: 12px 14px;
        font-size: 0.78125rem;
    }
}

@media print {
    .rb-header-wrapper, .rb-main-nav, .rb-footer-landing,
    .fc-filters-bar, .fc-charts, .fc-actions,
    .fc-loader, .fc-pagination { display: none !important; }

    body, .fc-page { background: #fff !important; padding: 0 !important; }
    .fc-table-wrap { box-shadow: none !important; border: 1px solid #ccc; border-radius: 0; overflow: visible; }
    .fc-table thead { display: table-header-group !important; }
    .fc-table tbody tr { display: table-row !important; background: #fff !important; border: none; border-radius: 0; box-shadow: none; margin: 0; }
    .fc-table td { display: table-cell !important; }
    .fc-table thead tr:first-child th,
    .fc-table thead tr:nth-child(2) th {
        background: var(--color-primary) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
