/* ================================================================
   CARDS DE MENU (menu-card)
   ================================================================ */

.menu-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 12px;
    height: 100%;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease-in-out;
    white-space: normal;
    text-align: center;
    /* quebra palavras longas (ex: "Comprovante") em vez de estourar o card */
    overflow-wrap: anywhere;
    word-break: break-word;
}

.menu-card .card-title {
    font-size: 20px;
    margin-top: 10px;
}

.menu-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
    background-color: #f0f0f0;
}

.menu-card .iconAbase i {
    font-size: 36px !important;
}

.menu-card-wrapper {
    padding-left: 8px;
    padding-right: 8px;
    margin-bottom: 16px; /* espaçamento vertical real entre os cards */
}

/* ================================================================
   CARDS DE GRUPO (menus pai expansíveis)
   ================================================================ */

.menu-grupo-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px 16px;
    border-radius: 14px;
    background: #ffffff;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    cursor: pointer;
    user-select: none;
    transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
    text-align: center;
    min-height: 110px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.menu-grupo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.13);
    border-color: #c9cfd8;
}

.menu-grupo-card.aberto {
    border-color: #b0bec5;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.11);
}

.menu-grupo-icone-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    margin-bottom: 10px;
    transition: transform 0.22s ease;
}

.menu-grupo-card:hover .menu-grupo-icone-wrapper {
    transform: scale(1.08);
}

.menu-grupo-icone-wrapper i {
    font-size: 24px;
}

.menu-grupo-nome {
    font-size: 13px;
    font-weight: 700;
    color: #37474f;
    line-height: 1.25;
    margin-bottom: 6px;
}

/* Badge de contagem de itens */
.menu-grupo-badge {
    position: absolute;
    top: 8px;
    right: 10px;
    background: #607d8b;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 12px;
    padding: 1px 7px;
    line-height: 18px;
}

/* Seta de expansão */
.menu-grupo-seta {
    font-size: 11px;
    color: #90a4ae;
    transition: transform 0.25s ease;
}

.menu-grupo-card.aberto .menu-grupo-seta {
    transform: rotate(180deg);
}

/* Card "Sair" — mesmo visual dos grupos mas com hover avermelhado */
.menu-card-sair:hover {
    border-color: #ffcdd2 !important;
    box-shadow: 0 10px 24px rgba(251, 150, 120, 0.22) !important;
}

.menu-card-sair .menu-grupo-nome,
.menu-card-sair i {
    color: #e57373 !important;
}

/* ================================================================
   PAINEL DE FILHOS (dropdown expansível)
   ================================================================ */

.menu-grupo-filhos {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #ffffff;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    border-top: none;
    border-radius: 0 0 14px 14px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.10);
    overflow: hidden;
    /* Posicionamento: relativo para empurrar o contêiner e ativar o scroll nativo */
    position: relative;
    width: auto;
    margin: -4px 8px 0 8px; /* -4px top para encaixar sob o card, 8px lateral para alinhamento */

    /* Estado oculto via visibility + opacity + max-height */
    visibility: hidden;
    opacity: 0;
    max-height: 0;
    transform: translateY(-6px);
    transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.25s ease, margin-bottom 0.25s ease, visibility 0s linear 0.22s;
    pointer-events: none;
}

/* wrapper precisa ser position: relative para o dropdown se posicionar certo */
.menu-card-wrapper {
    position: relative;
}

.menu-grupo-filhos.visivel {
    visibility: visible;
    opacity: 1;
    max-height: 1000px;
    transform: translateY(0);
    transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.25s ease, visibility 0s linear 0s;
    pointer-events: auto;
}

/* Cada item filho */
.menu-filho-item {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    text-decoration: none !important;
    color: #37474f !important;
    font-size: 13px;
    font-weight: 500;
    border-bottom: 1px solid #f0f2f5;
    transition: background 0.16s ease, padding-left 0.16s ease;
}

.menu-filho-item:last-child {
    border-bottom: none;
}

.menu-filho-item:hover {
    background: #f5f7fa;
    padding-left: 18px;
    color: #1565c0 !important;
}

.menu-filho-icone {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    flex-shrink: 0;
    font-size: 14px;
    transition: transform 0.16s ease;
}

.menu-filho-item:hover .menu-filho-icone {
    transform: scale(1.12);
}

.menu-filho-titulo {
    line-height: 1.3;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* ================================================================
   ANIMAÇÃO DE HOVER PARA CARDS DE FAVORITOS E RECENTES
   ================================================================ */
.menu-card-item {
    background: #ffffff;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
    color: #37474f;
    min-height: 110px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.menu-card-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.13);
    border-color: #c9cfd8;
}

/* ================================================================
   RESPONSIVO DOS CARDS DE MENU
   Fixa a largura do wrapper por breakpoint (sobrescreve col-* do bootstrap)
   ================================================================ */

/* celular pequeno: grupos em linha cheia, cards individuais 2 por linha */
@media (max-width: 575.98px) {
    /* cards individuais (sem grupo): 2 por linha */
    .menu-card-wrapper:not(.menu-card-wrapper--grupo) {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }

    /* cards de grupo e Sair: 1 por linha (dropdown fica legível) */
    .menu-card-wrapper--grupo {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }

    .menu-card-wrapper {
        padding-left: 6px;
        padding-right: 6px;
        margin-bottom: 12px;
    }

    .menu-card {
        padding: 14px 8px;
        border-radius: 10px;
    }

    .menu-card .iconAbase i {
        font-size: 26px !important;
    }

    .menu-card .card-title {
        font-size: 13px;
        margin-top: 6px;
        line-height: 1.2;
    }

    /* Em mobile, card de grupo vira "linha" (ícone + texto lado a lado) */
    .menu-grupo-card {
        min-height: 68px;
        padding: 12px 16px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 14px;
        text-align: left;
    }

    .menu-grupo-icone-wrapper {
        width: 42px;
        height: 42px;
        flex-shrink: 0;
        margin-bottom: 0;
    }

    .menu-grupo-icone-wrapper i {
        font-size: 20px;
    }

    .menu-grupo-nome {
        font-size: 13px;
        flex: 1;
        margin-bottom: 0;
    }

    .menu-grupo-seta {
        margin-left: auto;
        font-size: 13px;
    }

    .menu-grupo-badge {
        top: 6px;
        right: 38px;
    }

    .menu-grupo-filhos {
        left: 6px;
        right: 6px;
    }

    /* Previne que o footer sobreponha o final da tela em mobiles, já que ele pode quebrar em duas linhas */
    body {
        margin-bottom: 90px;
    }

    .page-wrapper {
        padding-bottom: 40px !important;
    }
}

/* celular grande / phablet: 3 por linha */
@media (min-width: 576px) and (max-width: 767.98px) {
    .menu-card-wrapper {
        flex: 0 0 33.3333% !important;
        max-width: 33.3333% !important;
    }

    .menu-card .iconAbase i {
        font-size: 30px !important;
    }

    .menu-card .card-title {
        font-size: 15px;
    }
}

/* ================================================================
   CORREÇÃO DE LAYOUT: GRADE 2X2 EM FAVORITOS E RECENTES (MOBILE)
   ================================================================ */
@media (max-width: 575.98px) {
    /* Força o uso de Grid para anular os conflitos de Flexbox e pseudo-elementos do template */
    #menu-dinamico-favoritos,
    #menu-dinamico-recentes {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        align-items: stretch;
    }

    /* Esconde os pseudo-elementos (clearfix legado) injetados pela classe .row do template */
    #menu-dinamico-favoritos::before, #menu-dinamico-favoritos::after,
    #menu-dinamico-recentes::before, #menu-dinamico-recentes::after {
        display: none !important;
        content: none !important;
    }

    /* Garante que o card ocupe 100% da sua célula no Grid, anulando o max-width: 50% do .col-6 */
    #menu-dinamico-favoritos .menu-card-wrapper,
    #menu-dinamico-recentes .menu-card-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        flex: none !important;
    }

    #menu-dinamico-favoritos p,
    #menu-dinamico-recentes p {
        grid-column: 1 / -1 !important;
    }
}
