/* =========================================================
   Organograma do Estado — PTR-1204
   Estrutura organizacional do Poder Executivo de Rondônia
   (LC nº 965/2017, alterada pela LC nº 1.180/2023).
   Categorias e relações fiéis ao documento oficial.
   ========================================================= */

.org-estado {
    --org-direta: #213863;
    --org-autarquia: #26599c;
    --org-empresa: #0077b5;
    --org-fundacao: #6b4e9e;
    --org-line: #9aa7b8;
    --org-title: #335d8d;
    --org-card-bg: #ffffff;
    --org-card-border: #e1e8f0;
    --org-match: #ffd34e;
}

.org-intro {
    color: #343a40;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0 auto 1.25rem;
    max-width: 880px;
    text-align: center;
}

/* ---------- Barra de ferramentas (sticky) ---------- */
.org-toolbar {
    position: sticky;
    top: var(--org-sticky-top, 0px);
    z-index: 6;
    background-color: var(--org-card-bg);
    border: 1px solid var(--org-card-border);
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
    padding: .85rem 1rem;
    margin-bottom: 1.5rem;
}

.org-toolbar__linha {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    align-items: center;
    justify-content: space-between;
}

.org-search {
    position: relative;
    flex: 1 1 280px;
    min-width: 220px;
}

.org-search__icone {
    position: absolute;
    left: .8rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--org-title);
    pointer-events: none;
}

.org-search__input {
    width: 100%;
    padding: .55rem .75rem .55rem 2.3rem;
    border: 1px solid #c4cedb;
    border-radius: 8px;
    font-size: .92rem;
    color: #343a40;
}

.org-search__input:focus {
    outline: none;
    border-color: var(--org-title);
    box-shadow: 0 0 0 3px rgba(51, 93, 141, .18);
}

.org-acoes {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.org-btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .85rem;
    border: 1px solid var(--org-title);
    border-radius: 8px;
    background-color: #fff;
    color: var(--org-title);
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.org-btn:hover,
.org-btn:focus-visible {
    background-color: var(--org-title);
    color: #fff;
    outline: none;
}

.org-indice {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem .5rem;
    margin-top: .75rem;
    padding-top: .75rem;
    border-top: 1px dashed var(--org-card-border);
}

.org-indice a {
    font-size: .82rem;
    font-weight: 600;
    color: var(--org-title);
    text-decoration: none;
    padding: .25rem .6rem;
    border-radius: 999px;
    background-color: #eef3f8;
    transition: background-color .15s ease, color .15s ease;
}

.org-indice a:hover,
.org-indice a:focus-visible {
    background-color: var(--org-title);
    color: #fff;
    outline: none;
}

.org-search__status {
    margin: .6rem 0 0;
    font-size: .85rem;
    color: #5a6675;
    min-height: 1.1rem;
}

/* ---------- Títulos de seção ---------- */
.org-section {
    margin-top: 2.5rem;
    scroll-margin-top: calc(var(--org-sticky-top, 0px) + 1rem);
}

.org-section-title {
    color: var(--org-title);
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: .35rem;
    text-align: center;
}

.org-section-title::after {
    content: "";
    display: block;
    width: 56px;
    height: 3px;
    margin: .5rem auto 0;
    background-color: var(--org-title);
    border-radius: 2px;
}

.org-section-desc {
    color: #5a6675;
    font-size: .92rem;
    margin: .75rem auto 1.5rem;
    max-width: 820px;
    text-align: center;
}

/* ---------- Caixas (nós) ---------- */
.org-node {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: .5rem .7rem;
    border-radius: 6px;
    color: #fff;
    line-height: 1.25;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.org-node__nome {
    font-size: .8rem;
    font-weight: 500;
}

.org-node__sigla {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
}

.org-node--direta {
    background-color: var(--org-direta);
    border: 1px solid var(--org-direta);
}

.org-node--autarquia {
    background-color: var(--org-autarquia);
    border: 1px dashed #cfe0f2;
}

.org-node--empresa {
    background-color: var(--org-empresa);
    border: 1px dashed #cdeaff;
}

.org-node--fundacao {
    background-color: var(--org-fundacao);
    border: 1px dashed #e2d6f3;
}

/* destaque de busca */
.org-node--match {
    outline: 3px solid var(--org-match);
    outline-offset: 1px;
    box-shadow: 0 0 0 3px rgba(255, 211, 78, .35);
}

/* ---------- Núcleo de Governo ---------- */
.org-nucleo {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 1.5rem;
}

.org-node--governadoria {
    align-items: center;
    text-align: center;
    min-width: 260px;
    margin-bottom: 2rem;
    border-radius: 8px;
}

.org-node--governadoria .org-node__nome {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.org-node--governadoria::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    height: 2rem;
    border-left: 2px solid var(--org-line);
}

.org-nucleo__ramos {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 1.75rem;
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

/* ---------- Secretarias (masonry por colunas) ---------- */
.org-secretarias {
    column-count: 3;
    column-gap: 1.5rem;
    margin-top: 1.25rem;
}

.org-secretarias .org-card {
    break-inside: avoid;
    margin-bottom: 1.5rem;
}

/* ---------- Card (details/summary) ---------- */
.org-card {
    background-color: var(--org-card-bg);
    border: 1px solid var(--org-card-border);
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .07);
    overflow: hidden;
}

.org-card__summary {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .65rem .85rem;
    cursor: pointer;
    list-style: none;
}

.org-card__summary::-webkit-details-marker {
    display: none;
}

.org-card__summary--estatico {
    cursor: default;
}

.org-card__summary .org-node {
    flex: 1 1 auto;
    text-align: center;
    box-shadow: none;
}

.org-card__summary .org-node__nome {
    font-size: .88rem;
    font-weight: 700;
}

.org-card__chevron {
    flex: 0 0 auto;
    color: var(--org-title);
    transition: transform .2s ease;
}

.org-card[open] .org-card__chevron {
    transform: rotate(180deg);
}

.org-card__summary:hover .org-node,
.org-card > summary:focus-visible .org-node {
    filter: brightness(1.12);
}

.org-card > summary:focus-visible {
    outline: 3px solid rgba(51, 93, 141, .5);
    outline-offset: -2px;
}

.org-card__body {
    padding: .25rem .85rem 1rem;
}

.org-card__nota {
    margin: 0;
    padding: .5rem .85rem .85rem;
    font-size: .82rem;
    font-style: italic;
    color: #7a8696;
    text-align: center;
}

/* ---------- Árvore: espinha + cotovelo (centrado no nó) ---------- */
.org-branch {
    list-style: none;
    margin: 0;
    padding: 0;
}

.org-item {
    position: relative;
}

.org-item__row {
    position: relative;
    padding: .28rem 0 .28rem 1.4rem;
}

/* filhos indentados */
.org-item > .org-branch {
    margin-left: 1.4rem;
}

/* cotovelo horizontal, centralizado verticalmente no nó */
.org-item__row > .org-node::after {
    content: "";
    position: absolute;
    top: 50%;
    left: -.95rem;
    width: .95rem;
    border-top: 2px solid var(--org-line);
}

.org-item--vinculada > .org-item__row > .org-node::after {
    border-top-style: dashed;
}

/* espinha vertical: itens não-últimos cobrem toda a altura (liga ao próximo irmão) */
.org-item:not(:last-child)::after {
    content: "";
    position: absolute;
    left: .45rem;
    top: 0;
    bottom: 0;
    border-left: 2px solid var(--org-line);
}

/* último filho: a espinha para no centro do nó (sem sobra) */
.org-item:last-child > .org-item__row::before {
    content: "";
    position: absolute;
    left: .45rem;
    top: 0;
    height: 50%;
    border-left: 2px solid var(--org-line);
}

/* ---------- Legenda ---------- */
.org-legenda {
    margin: 1.5rem auto 0;
    max-width: 960px;
    padding: 1rem 1.25rem;
    background-color: #f0f4f8;
    border-radius: 10px;
}

.org-legenda__grupos {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2.5rem;
    justify-content: center;
    margin-top: .75rem;
}

.org-legenda__rotulo {
    display: block;
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--org-title);
    margin-bottom: .5rem;
}

.org-legenda__lista {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: .5rem 1.25rem;
}

.org-legenda__lista li {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: #343a40;
}

.org-legenda__amostra {
    display: inline-block;
    width: 26px;
    height: 17px;
    border-radius: 4px;
    flex: 0 0 auto;
}

.org-legenda__linha {
    display: inline-block;
    width: 34px;
    height: 0;
    border-top: 2px solid #343a40;
    flex: 0 0 auto;
}

.org-legenda__linha--tracejada {
    border-top-style: dashed;
}

/* ---------- Rodapé legal ---------- */
.org-rodape {
    margin-top: 2.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--org-card-border);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .75rem 1rem;
}

.org-rodape__texto {
    margin: 0;
    font-size: .85rem;
    color: #5a6675;
    flex: 1 1 320px;
}

.org-pdf-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .55rem 1rem;
    border: 1px solid var(--org-title);
    border-radius: 8px;
    color: var(--org-title);
    font-weight: 600;
    text-decoration: none;
    transition: background-color .2s ease, color .2s ease;
}

.org-pdf-link:hover,
.org-pdf-link:focus-visible {
    background-color: var(--org-title);
    color: #fff;
    text-decoration: none;
    outline: none;
}

/* estado de filtragem */
.org-card.is-hidden,
.org-item.is-hidden {
    display: none;
}

/* ---------- Responsivo ---------- */
@media (max-width: 1100px) {
    .org-secretarias {
        column-count: 2;
    }
}

@media (max-width: 680px) {
    .org-secretarias {
        column-count: 1;
    }

    .org-nucleo__ramos {
        grid-template-columns: 1fr;
    }

    .org-node--governadoria {
        min-width: 0;
        width: 100%;
    }

    .org-toolbar__linha {
        justify-content: stretch;
    }
}

/* ---------- Movimento reduzido ---------- */
@media (prefers-reduced-motion: reduce) {
    .org-card__chevron,
    .org-btn,
    .org-indice a,
    .org-pdf-link {
        transition: none;
    }
}

/* ---------- Impressão ---------- */
@media print {
    .org-toolbar {
        display: none;
    }

    .org-card {
        box-shadow: none;
        break-inside: avoid;
    }

    .org-card__chevron {
        display: none;
    }

    .org-node {
        box-shadow: none;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
