#modal-container.hidden {
    display: none;
}

#modal-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    /* Acima do btn_submenu_footer (z-index: 9999) */
}

#modal-container > .modal-content>* {
    background-color: #fff;
    border-radius: 8px;
    width: 90%;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: modal-appear 0.3s ease-out;
    text-transform: none;
    display: flex;
    align-items: center;
    justify-content: space-evenly;
}

@keyframes modal-appear {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#modal-container > .modal-content .modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid rgb(9, 82, 154);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color:  #f8f9fa;
    font-weight:bolder;
    font-size: 1.25rem;
    background-color:rgb(9, 82, 154);
}

#modal-container > .modal-content .modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: #f8f9fa;
}

#modal-container > .modal-content .close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #f8f9fa;
    cursor: pointer;
    padding: 0;
    margin: 0;
}

#modal-container > .modal-content .close-modal:hover {
    color: #f8f9fa;
}

#modal-container > .modal-content .modal-body {
    padding: 20px;
    color: #333;
    flex-direction: column;
}

/* .modal-footer {
    padding: 15px 20px;
    border-top: 1px solid rgb(255, 255, 255);
    display: flex;
    justify-content: center;
    gap: 10px;
    background-color: rgb(194, 194, 194);
} */

/* Resto do seu CSS permanece igual */

form {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 1rem;
}

.button {
    padding: 0.5rem 1rem;
    border: none;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

/* Botões de posiivo ou negativo na função */
.custom-delete-button {
  width: 142px;
  height: 38px;
  cursor: pointer;
  box-shadow: 1px 1px 3px rgba(225, 225, 225, 0.8);
  position: relative;
  border: none;
  border-radius: 4px;
  display: flex;
  justify-content: center;
  text-align: center;
  vertical-align: middle;

  padding: 0.6rem 2rem;
  color: rgb(255, 255, 255);
  font-weight: bolder;
}
.custom-delete-button:hover {
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
/* Botão vermelho */
.custom-delete-button.red {
  background: #e62222;
}
.custom-delete-button.red:hover {
  background: #ca1d1d;
}

/* Botão verde */
.custom-delete-button.green {
  background: #28a745;
}
.custom-delete-button.green:hover {
  background: rgb(56, 142, 75);
}

/* ==========================================================================
   MODAIS — refactor ref/modal-base (2026-06-13)
   ========================================================================== */

/* Base responsiva: largura adaptativa + scroll interno do body */
#modal-container > .modal-content {
    width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Variantes ampliam max-width SO em telas maiores; mobile sempre vence em 90vw */
#modal-container > .modal-content--pequeno { max-width: 480px; }
#modal-container > .modal-content--medio   { max-width: 640px; }
#modal-container > .modal-content--grande  { max-width: 900px; }

/* Body com scroll interno (modal nunca passa da viewport) */
#modal-container > .modal-content .modal-body {
    flex: 1;
    overflow-y: auto;
}

/* Mobile pequeno: mais espaco util, menos padding */
@media (max-width: 480px) {
    #modal-container > .modal-content {
        width: 96vw;
        max-height: 96vh;
    }
    #modal-container > .modal-content .modal-header,
    #modal-container > .modal-content .modal-body,
    #modal-container > .modal-content .modal-footer {
        padding: 12px 14px;
    }
}

/* Busca + lista (selecao) — usado pelo ref/modal-selecao */
.modal-busca {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.modal-busca__input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.modal-busca__botao {
    padding: 10px 20px;
}

@media (max-width: 600px) {
    .modal-busca {
        flex-direction: column;
    }
    .modal-busca__botao {
        width: 100%;
    }
}

.modal-resultados {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
}
.modal-resultados__estado-vazio {
    padding: 20px;
    text-align: center;
    color: #666;
}

.modal-tabela-resultados {
    width: 100%;
    min-width: 480px;
    border-collapse: collapse;
}
.modal-tabela-resultados thead tr {
    background-color: #f8f9fa;
}
.modal-tabela-resultados th,
.modal-tabela-resultados td {
    padding: 12px;
    border: 1px solid #ddd;
    text-align: left;
}
.modal-tabela-resultados tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}
.modal-tabela-resultados tbody tr:hover {
    background-color: #f5f5f5;
}

@media (max-width: 480px) {
    .modal-tabela-resultados th,
    .modal-tabela-resultados td {
        padding: 8px;
        font-size: 0.9rem;
    }
}

/* Estados de loading/erro/vazio (compartilhados) */
.modal-loading {
    padding: 20px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.modal-sem-resultados {
    padding: 20px;
    text-align: center;
    color: #666;
}
.modal-erro {
    padding: 20px;
    text-align: center;
    color: #dc3545;
}

/* Re-habilita .modal-footer (estava comentada como legado).
   Botoes centralizados -- alinha com a intencao do CSS legado (linha
   comentada usava justify-content: center) e e mais ergonomico em
   modais que tipicamente tem 1-2 botoes de acao. */
#modal-container > .modal-content .modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

@media (max-width: 480px) {
    #modal-container > .modal-content .modal-footer {
        flex-direction: column-reverse;
    }
    #modal-container > .modal-content .modal-footer .custom-delete-button {
        width: 100%;
    }
}

/* close-modal vira <button> */
#modal-container > .modal-content button.close-modal {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}
#modal-container > .modal-content button.close-modal:hover {
    opacity: 0.8;
}

/* Acessibilidade: sem outline padrao no modal-content (caller controla) */
#modal-container > .modal-content:focus {
    outline: none;
}

/* Fix de border-radius: o radius fica APENAS no .modal-content (wrapper);
   header/body/footer sao planos.
   - Sem este fix, o .modal-content > * legado vazava radius em todos os
     filhos: header com canto inferior arredondado destacava do body, body
     com canto superior destacava do header, e o mesmo entre body/footer.
   - overflow:hidden no wrapper clipa naturalmente os filhos retangulares
     para casar com os cantos arredondados do modal -- funciona com OU sem
     rodape, sem precisar de regra condicional. */
#modal-container > .modal-content {
    border-radius: 8px;
    overflow: hidden;
    background-color: #fff;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    animation: modal-appear 0.3s ease-out;
}
#modal-container > .modal-content .modal-header,
#modal-container > .modal-content .modal-body,
#modal-container > .modal-content .modal-footer {
    /* Reset do .modal-content > * legado que vazava: */
    border-radius: 0;
    box-shadow: none;
    animation: none;
    width: 100%;            /* legacy seta 90% -> 10% vazio na direita */
    box-sizing: border-box; /* width 100% inclui padding; sem isto, padding
                               20px somava 40px alem do parent e o overflow
                               hidden do wrapper cortava na direita */
}

/* Body precisa de display: block para layout normal de paragrafo/tabela.
   O > * legado seta display: flex + align-items: center + justify-content:
   space-evenly, o que empilha p/table como flex items lado a lado
   horizontal. Override aqui. */
#modal-container > .modal-content .modal-body {
    display: block;
    flex: 1;            /* mantem flex-item no eixo do .modal-content flex column */
    overflow-y: auto;
}
