/* ==========================================================
   PAINEL DE FILTROS — padrão do box de filtros do painel EXEC
   (cabeçalho com título azul + contador + "Limpar", pills DSGov,
   busca no padrão br-select/br-input/br-list e listas dropdown
   com checkbox e fundo azul claro no item selecionado)
========================================================== */

.filter-panel {

    background: var(--card-bg);

    border: 1px solid #d4dbe3;

    border-radius: 4px;

    padding: 0;

    margin-bottom: 24px;

}

/* ==========================================================
   CABEÇALHO + EXPANDIR/RECOLHER DA ÁREA DE FILTROS
========================================================== */

.filter-panel-header {

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 12px;

    padding: 6px 22px;

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

    cursor: pointer;

    user-select: none;

}

.filter-panel-heading {

    display: flex;

    align-items: center;

    gap: 8px;

    min-width: 0;

}

.filter-panel-title {

    font-size: 12px;

    font-weight: 500;

    text-transform: uppercase;

    letter-spacing: .8px;

    line-height: 1.2;

    color: var(--primary);

    border-left: 3px solid var(--primary);

    padding-left: 10px;

    white-space: nowrap;

}

.filter-panel-count {

    border-radius: 100em;

    background: var(--primary-soft);

    color: var(--primary);

    font-size: 10px;

    font-weight: 700;

    line-height: 1.4;

    padding: 1px 6px;

    white-space: nowrap;

}

.filter-panel-count[hidden] {

    display: none;

}

.filter-panel-header-actions {

    display: flex;

    align-items: center;

    gap: 6px;

    flex-shrink: 0;

}

.filter-clear-btn {

    display: inline-flex;

    align-items: center;

    gap: 4px;

    padding: 4px 8px;

    background: transparent;

    border: 0;

    border-radius: 100em;

    color: var(--primary);

    font-family: inherit;

    font-size: 12px;

    font-weight: 600;

    cursor: pointer;

    transition: background-color .15s ease;

}

.filter-clear-btn svg {

    width: 14px;

    height: 14px;

}

.filter-clear-btn:hover {

    background: var(--primary-soft);

}

.filter-panel-toggle {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 24px;

    height: 24px;

    padding: 0;

    background: transparent;

    border: 0;

    border-radius: 100em;

    color: var(--primary);

    cursor: pointer;

    transition: background-color .15s ease;

}

.filter-panel-toggle svg {

    width: 16px;

    height: 16px;

    transition: transform .2s ease;

}

.filter-panel-toggle:hover {

    background: var(--primary-soft);

}

.filter-panel-body {

    padding: 16px 22px 20px;

}

/* Estado recolhido: esconde o corpo do formulário e vira o chevron */
.filter-panel.collapsed .filter-panel-body {

    display: none;

}

.filter-panel.collapsed .filter-panel-toggle svg {

    transform: rotate(180deg);

}

.filter-panel.collapsed .filter-panel-header {

    border-bottom: none;

}

/* ==========================================================
   GRID DOS FILTROS
========================================================== */

.filters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px 18px;
}

/* Mês: 6 pills por linha (2 linhas de 6 = 12 meses). */
.cell-mes .pill-row {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    justify-items: center;
    gap: 6px;
}

.cell-mes .pill {
    min-width: 38px;
    text-align: center;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

/* ==========================================================
   FAIXA DE ÓRGÃOS
========================================================== */

.orgaos-row {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

.orgaos-row .filter-group {
    gap: 8px;
}

.filter-head {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
}

.filter-head label {
    margin-right: 2px;
}

.filter-head-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}

.filter-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 4px;
    color: var(--text-faint);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.filter-action-btn svg {
    width: 14px;
    height: 14px;
}

.filter-action-btn:hover {
    background: var(--bg-soft);
    color: var(--primary);
}

.filter-action-btn-danger:hover {
    color: var(--danger);
}

/* ==========================================================
   RÓTULOS DOS GRUPOS (mesmo padrão dos subtítulos do EXEC)
========================================================== */

.filter-group > label,
.filter-head label {

    font-size: 10.5px;

    font-weight: 400;

    color: var(--success);

    text-transform: uppercase;

    letter-spacing: 0.6px;

}

/* ==========================================================
   MULTI-SELECT (lista dropdown padrão br-list/br-item)
========================================================== */

.ms-wrap select[multiple] {

    display: none;
}

.ms-container {

    position: relative;
}

.ms-btn {

    width: 100%;

    min-height: 40px;

    display: flex;

    align-items: center;

    justify-content: space-between;

    gap: 8px;

    background: #fff;

    border: 1px solid #888;

    border-radius: 6px;

    padding: 0 12px;

    color: var(--text);

    font-size: 13px;

    font-family: inherit;

    text-align: left;

    cursor: pointer;

    transition: border-color .15s ease, box-shadow .15s ease;
}

.ms-btn::after {

    content: "";

    width: 7px;

    height: 7px;

    flex-shrink: 0;

    border-right: 2px solid var(--primary);

    border-bottom: 2px solid var(--primary);

    transform: rotate(45deg) translateY(-2px);

}

.ms-btn:hover,
.ms-btn:focus {

    border-color: var(--primary);

    outline: none;

}

.ms-btn:focus-visible {

    box-shadow: 0 0 0 1px var(--primary);

}

.ms-panel {

    display: none;

    position: absolute;

    top: calc(100% + 4px);

    left: 0;

    right: 0;

    background: #fff;

    border: 1px solid #d4dbe3;

    border-radius: 0;

    z-index: 100;

    max-height: 320px;

    overflow: hidden;

    flex-direction: column;

    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);

}

.ms-panel.open {

    display: flex;
}

.ms-search {

    margin: 8px;

    padding: 8px 10px;

    background: #fff;

    border: 1px solid #888;

    border-radius: 6px;

    color: var(--text);

    font-size: 12px;

    font-family: inherit;

    outline: none;

    flex-shrink: 0;

}

.ms-search:focus {

    border-color: var(--primary);

    box-shadow: 0 0 0 1px var(--primary);

}

.ms-options {

    overflow-y: auto;

    flex: 1;

    padding: 0;
}

.ms-option {

    display: flex;

    align-items: center;

    gap: 8px;

    padding: 8px 12px;

    font-size: 12.5px;

    color: var(--text);

    cursor: pointer;

    border-radius: 0;

    border-bottom: 1px solid #f0f0f0;

    white-space: normal;

}

.ms-option:hover {

    background: var(--thead-bg);
}

.ms-option:first-child {

    font-weight: 600;

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

}

.ms-option:not(:first-child):has(input[type=checkbox]:checked) {

    background: var(--primary-soft);
}

/* Checkbox quadrado do DSGov (igual ao das listas do EXEC) */
.ms-option input[type=checkbox] {

    -webkit-appearance: none;

    appearance: none;

    width: 16px;

    height: 16px;

    margin: 0;

    flex-shrink: 0;

    border: 1px solid rgba(19, 81, 180, .35);

    border-radius: 2px;

    background-color: #fff;

    background-repeat: no-repeat;

    background-position: center;

    background-size: 11px 11px;

    cursor: pointer;

}

.ms-option input[type=checkbox]:checked {

    background-color: var(--primary);

    border-color: var(--primary);

    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7-8' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

}

/* ==========================================================
   RODAPÉ DO PAINEL (unidade dos valores)
========================================================== */

.filters-actions {

    display: flex;

    justify-content: flex-start;

    gap: 10px;

    margin-top: 18px;

    padding-top: 18px;

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

}

.filters-actions select {
    background: #fff;
    border: 1px solid #888;
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    height: 40px;
    padding: 0 12px;
    cursor: pointer;
}

.filters-actions select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.filters-actions select option {
    background: #fff;
    color: var(--text);
}


/* ==========================================================
   BUSCA GLOBAL — padrão br-select / br-input / br-list do EXEC
========================================================== */

.gs-wrap {

    position: relative;

    margin-top: 16px;

    padding-top: 16px;

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

}

.gs-legend {

    display: flex;

    flex-wrap: wrap;

    gap: 6px 14px;

    justify-content: center;

    margin-bottom: 10px;

    font-size: 10.5px;

    color: var(--text-faint);

}

.gs-legend-item {

    display: inline-flex;

    align-items: center;

    gap: 6px;

}

.gs-legend-dot {

    width: 8px;

    height: 8px;

    border-radius: 2px;

    display: inline-block;

    flex-shrink: 0;

}

.gs-chips {

    display: flex;

    flex-wrap: wrap;

    justify-content: center;

    gap: 6px;

    margin-bottom: 10px;

}

.gs-chip {

    display: inline-flex;

    align-items: center;

    gap: 6px;

    background: #fff;

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

    border-radius: 100em;

    padding: 4px 6px 4px 9px;

    font-size: 11.5px;

    color: var(--text);

}

.gs-chip-dot {

    width: 7px;

    height: 7px;

    border-radius: 2px;

    flex-shrink: 0;

}

.gs-chip-type {

    font-weight: 700;

    white-space: nowrap;

}

.gs-chip-text {

    color: var(--text);

    max-width: 180px;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

}

.gs-chip-x {

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 15px;

    height: 15px;

    padding: 0;

    border: 0;

    border-radius: 100em;

    background: var(--primary-soft);

    color: var(--text-faint);

    cursor: pointer;

    flex-shrink: 0;

}

.gs-chip-x svg {

    width: 10px;

    height: 10px;

}

.gs-chip-x:hover {

    background: var(--danger);

    color: #fff;

}

.gs-select {

    position: relative;

    width: 100%;

    max-width: none;

}

.gs-select .br-input {

    position: relative;

    width: 100%;

}

.gs-select input#gsInput {

    width: 100%;

    height: 40px;

    box-sizing: border-box;

    background: #fff;

    border: 1px solid #888;

    border-radius: 6px;

    padding: 0 48px 0 16px;

    color: var(--text);

    font-family: inherit;

    font-size: 14px;

    font-weight: 500;

    text-align: left;

    outline: none;

    transition: border-color .15s ease, box-shadow .15s ease;

}

.gs-select input#gsInput::placeholder {

    color: var(--text-faint);

    font-weight: 400;

}

.gs-select input#gsInput:focus {

    border-color: var(--primary);

    box-shadow: 0 0 0 1px var(--primary);

}

.gs-select .br-button {

    position: absolute;

    right: 4px;

    top: 50%;

    transform: translateY(-50%);

    display: inline-flex;

    align-items: center;

    justify-content: center;

    width: 32px;

    height: 32px;

    padding: 0;

    border: 0;

    border-radius: 100em;

    background: transparent;

    color: var(--primary);

    cursor: pointer;

}

.gs-select .br-button:hover {

    background: var(--primary-soft);

}

.gs-select .br-button svg {

    width: 16px;

    height: 16px;

}

.gs-dropdown {

    display: none;

    position: absolute;

    top: calc(100% + 4px);

    left: 0;

    right: 0;

    background: #fff;

    border: 1px solid #d4dbe3;

    border-radius: 0;

    max-height: 288px;

    overflow-y: auto;

    z-index: 200;

    padding: 0;

    box-shadow: 0 8px 24px rgba(0, 0, 0, .18);

}

.gs-dropdown.open {

    display: block;

}

.gs-result {

    display: flex;

    align-items: center;

    gap: 10px;

    width: 100%;

    padding: 8px 12px;

    background: #fff;

    border: 0;

    border-bottom: 1px solid #f0f0f0;

    color: var(--text);

    font-family: inherit;

    font-size: 12.5px;

    text-align: left;

    cursor: pointer;

}

.gs-result:hover {

    background: var(--thead-bg);

}

.gs-result.is-selected {

    background: var(--primary-soft);

}

.gs-item-dot {

    width: 9px;

    height: 9px;

    border-radius: 2px;

    flex-shrink: 0;

}

.gs-item-text {

    flex: 1;

    min-width: 0;

    overflow: hidden;

    text-overflow: ellipsis;

    white-space: nowrap;

}

.gs-item-type {

    flex-shrink: 0;

    font-size: 9px;

    font-weight: 700;

    letter-spacing: .5px;

    text-transform: uppercase;

}

.gs-item-check {

    display: flex;

    align-items: center;

    justify-content: center;

    width: 16px;

    height: 16px;

    flex-shrink: 0;

    border: 1px solid rgba(19, 81, 180, .35);

    border-radius: 2px;

    background: #fff;

    color: transparent;

    font-size: 10px;

    line-height: 1;

}

.gs-item-check.is-checked {

    background: var(--primary);

    border-color: var(--primary);

    color: #fff;

}

.gs-result-header {

    padding: 8px 12px 4px;

    font-size: 11px;

    font-weight: 700;

    letter-spacing: .04em;

    text-transform: uppercase;

    color: var(--primary);

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

}

.gs-empty {

    padding: 10px 12px;

    text-align: center;

    font-size: 12px;

    color: var(--text-faint);

}

/* ==========================================================
   PILL BUTTONS — mesmo padrão das pills do EXEC
========================================================== */

.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.pill-scroll {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 92px;
    overflow-y: auto;
    padding-right: 4px;
}

.pill-scroll::-webkit-scrollbar {
    width: 6px;
}

.pill-scroll::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.pill {
    padding: 4px 10px;
    font-size: 11.5px;
    font-weight: 500;
    border-radius: 100em;
    border: .5px solid rgba(19, 81, 180, .35);
    background: #fff;
    color: #3b3b3b;
    cursor: pointer;
    transition: background-color .13s ease, border-color .13s ease, color .13s ease;
    font-family: inherit;
    user-select: none;
    line-height: 1.4;
    white-space: nowrap;
}

.pill:hover {
    border-color: var(--primary);
    background: #ecf1f9;
    color: #3b3b3b;
    transform: none;
    box-shadow: none;
}

.pill.active {
    background: var(--primary);
    border: 1px solid var(--primary);
    color: #fff;
}

/* ==========================================================
   PILL FILTERS: pills no desktop, dropdown no mobile
========================================================== */

.filter-type-pill .ms-wrap {
    display: none;
}

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

@media (max-width: 768px) {

    .filter-panel-header {

        padding: 6px 16px;

    }

    .filter-panel-body {

        padding: 16px;

    }

    .filters-grid {
        grid-template-columns: 1fr;
    }

    .filter-type-pill .pill-row {
        display: none;
    }

    .filter-type-pill .ms-wrap {
        display: block;
    }

    .filters-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-actions select {
        width: 100%;
    }

    .ms-panel {
        max-height: 220px;
    }

    .gs-select input#gsInput {

        font-size: 13px;

    }
}
