/**
 * Menu Mobile Melhorado
 * Animações suaves, melhor UX e gestos touch
 */

/* ============================================
   NAVBAR TOGGLER ANIMADO
   ============================================ */

.navbar-toggler {
    padding: 0.5rem;
    border: none !important;
    background: transparent;
    position: relative;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1050;
}

/* Garantir que o botão apareça em mobile */
@media (max-width: 991.98px) {
    .navbar-toggler {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 1050 !important;
    }
    
    .navbar-toggler-icon {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
}

/* Esconder em desktop (Bootstrap já faz isso, mas garantindo) */
@media (min-width: 992px) {
    .navbar-toggler {
        display: none !important;
    }
}

.navbar-toggler:focus {
    box-shadow: none;
    outline: none;
}

.navbar-toggler:hover {
    background: rgba(4, 106, 56, 0.1);
    border-radius: 8px;
}

.navbar-toggler-icon {
    width: 24px;
    height: 20px;
    position: relative;
    display: block !important;
    transition: all 0.3s ease;
    background-image: none !important; /* Remover ícone padrão do Bootstrap */
    background-color: transparent !important;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after,
.navbar-toggler-icon span {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--primary-green);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    left: 0;
}

.navbar-toggler-icon span {
    top: 50%;
    transform: translateY(-50%);
    display: block !important;
}

.navbar-toggler-icon::before {
    top: 0;
}

.navbar-toggler-icon::after {
    bottom: 0;
}

/* Animação quando menu está aberto */
.navbar-toggler[aria-expanded="true"] .navbar-toggler-icon span {
    opacity: 0;
    transform: translateY(-50%) scale(0);
}

.navbar-toggler[aria-expanded="true"] .navbar-toggler-icon::before {
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
}

.navbar-toggler[aria-expanded="true"] .navbar-toggler-icon::after {
    bottom: 50%;
    transform: translateY(50%) rotate(-45deg);
}

/* ============================================
   MENU MOBILE OVERLAY
   ============================================ */

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1035;
    backdrop-filter: blur(2px);
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MENU MOBILE ANIMADO
   ============================================ */

@media (max-width: 991.98px) {
    .navbar-collapse {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: #ffffff;
        box-shadow: -2px 0 20px rgba(0, 0, 0, 0.1);
        padding: 1.5rem;
        transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
        z-index: 1040;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        visibility: hidden;
    }

    .navbar-collapse.show {
        right: 0;
        visibility: visible;
    }
    
    /* Garantir que o menu não apareça por padrão */
    .navbar-collapse:not(.show) {
        right: -100% !important;
        visibility: hidden !important;
    }

    .navbar-nav {
        margin-top: 2rem;
    }

    .nav-item {
        margin-bottom: 0.5rem;
        opacity: 0;
        transform: translateX(20px);
        animation: slideInRight 0.4s ease forwards;
    }

    .nav-item:nth-child(1) { animation-delay: 0.1s; }
    .nav-item:nth-child(2) { animation-delay: 0.15s; }
    .nav-item:nth-child(3) { animation-delay: 0.2s; }
    .nav-item:nth-child(4) { animation-delay: 0.25s; }
    .nav-item:nth-child(5) { animation-delay: 0.3s; }
    .nav-item:nth-child(6) { animation-delay: 0.35s; }
    .nav-item:nth-child(7) { animation-delay: 0.4s; }

    .nav-link {
        padding: 0.75rem 1rem;
        border-radius: 8px;
        transition: all 0.3s ease;
        display: flex;
        align-items: center;
        font-weight: 500;
        color: var(--text-gray-700);
    }

    .nav-link:hover,
    .nav-link.active {
        background: linear-gradient(135deg, rgba(4, 106, 56, 0.1) 0%, rgba(206, 17, 38, 0.1) 100%);
        color: var(--primary-green);
        transform: translateX(5px);
    }

    .nav-link i {
        width: 24px;
        margin-right: 0.75rem;
        font-size: 1.1rem;
    }

    /* Dropdown no mobile */
    .dropdown-menu {
        position: static !important;
        float: none;
        width: 100%;
        margin-top: 0.5rem;
        margin-left: 1rem;
        border: none;
        box-shadow: none;
        background: rgba(4, 106, 56, 0.05);
        border-radius: 8px;
        padding: 0.5rem 0;
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease, padding 0.3s ease;
    }

    .dropdown-menu.show {
        max-height: 500px;
        padding: 0.5rem 0;
    }

    .dropdown-item {
        padding: 0.625rem 1.5rem;
        border-radius: 0;
        transition: all 0.2s ease;
    }

    .dropdown-item:hover {
        background: rgba(4, 106, 56, 0.1);
        padding-left: 2rem;
    }

    .dropdown-item i {
        width: 20px;
        margin-right: 0.75rem;
    }

    /* Header do menu mobile */
    .mobile-menu-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 1rem;
        border-bottom: 1px solid #e9ecef;
        margin-bottom: 1rem;
    }

    .mobile-menu-header .navbar-brand {
        font-size: 1.25rem;
    }

    .mobile-menu-close {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        background: transparent;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
        font-size: 1.5rem;
        color: var(--text-gray-700);
    }

    .mobile-menu-close:hover {
        background: rgba(4, 106, 56, 0.1);
        color: var(--primary-green);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ============================================
   GESTOS TOUCH (SWIPE)
   ============================================ */

@media (max-width: 991.98px) {
    .navbar-collapse {
        touch-action: pan-y;
    }

    .navbar-collapse.swiping {
        transition: none;
    }
}

/* ============================================
   BODY LOCK QUANDO MENU ABERTO
   ============================================ */

body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ============================================
   MELHORIAS DE ACESSIBILIDADE
   ============================================ */

.navbar-toggler:focus-visible {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
}

.nav-link:focus-visible {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
    border-radius: 8px;
}

/* ============================================
   ANIMAÇÃO DE ENTRADA DOS ITENS
   ============================================ */

@media (max-width: 991.98px) {
    .navbar-collapse.show .nav-item {
        animation: slideInRight 0.4s ease forwards;
    }

    .navbar-collapse:not(.show) .nav-item {
        animation: none;
        opacity: 0;
        transform: translateX(20px);
    }
}
