/* MOBILE STYLES - MENU COMPACTO, ESCURO E NEUTRO */
@media (max-width: 768px) {
    /* GARANTIR QUE O MENU FIQUE SEMPRE VISÍVEL QUANDO ABERTO */
    .mobile-menu-open {
        overflow: hidden !important;
    }
    
    .mobile-menu-open body {
        overflow: hidden !important;
    }

    /* GARANTIR QUE A SIDEBAR FIQUE NA FRENTE DE TUDO */
    .sidebar {
        z-index: 9999 !important;
    }

    .mobile-overlay {
        z-index: 9998 !important;
    }

    /* RESET GERAL */
    html, body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
        background: #0a0a0a !important;
    }
    
    /* MENU HAMBURGUER DENTRO DA TOPBAR (PADRÃO PARA TODAS AS PÁGINAS) */
    .mobile-menu-toggle {
        position: absolute !important;
        top: 50% !important;
        left: 15px !important;
        transform: translateY(-50%) !important;
        z-index: 1001 !important;
        background: #1a1a1a !important;
        color: #cccccc !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 6px !important;
        border: 1px solid #333333 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        cursor: pointer !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
        pointer-events: auto !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        margin: 0 !important;
    }

    .mobile-menu-toggle:hover {
        background: #252525 !important;
        transform: translateY(-50%) scale(1.05) !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4) !important;
    }

    /* ANIMAÇÃO ESPECIAL NO CLIQUE DO BOTÃO */
    .mobile-menu-toggle:active {
        background: #333333 !important;
        transform: translateY(-50%) scale(0.85) !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
        transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1) !important;
        animation: buttonClickPulse 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* EFEITO DE PULSO NO CLIQUE */
    @keyframes buttonClickPulse {
        0% {
            box-shadow: 0 0 0 0 rgba(100, 100, 100, 0.4);
        }
        50% {
            box-shadow: 0 0 0 8px rgba(100, 100, 100, 0.2);
        }
        100% {
            box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
        }
    }

    /* ANIMAÇÃO DO ÍCONE HAMBURGUER QUANDO MENU ABRE */
    .mobile-menu-open .mobile-menu-toggle svg {
        transform: rotate(90deg);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* MENU HAMBURGUER NÃO SOME QUANDO MENU ABRE */
    .mobile-menu-open .mobile-menu-toggle {
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
        transform: translateY(-50%) scale(1) !important;
        background: #2a2a2a !important;
    }

    /* OVERLAY COM EFEITO DE FADE IN */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0);
        z-index: 9998 !important;
        display: none;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-menu-open .mobile-overlay {
        display: block;
        background: rgba(0, 0, 0, 0.7);
        animation: overlayFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes overlayFadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    /* SIDEBAR COM EFEITO DE SLIDE IN */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        height: 100vh !important;
        width: 280px !important;
        transform: translateX(-100%) !important;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 9999 !important;
        overflow-y: auto !important;
        background: #0a0a0a !important;
        box-shadow: 2px 0 30px rgba(0, 0, 0, 0.8) !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        -webkit-overflow-scrolling: touch !important;
        border-right: 1px solid #1a1a1a !important;
    }

    /* GARANTIR QUE O MENU APAREÇA QUANDO ABERTO COM ANIMAÇÃO */
    .mobile-menu-open .sidebar {
        transform: translateX(0) !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
        animation: slideInMenu 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideInMenu {
        from {
            transform: translateX(-100%);
            opacity: 0;
        }
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    /* EFEITO DE FLOAT NOS ITENS DO MENU */
    .sb-link {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 14px 16px !important;
        color: #b0b0b0 !important;
        text-decoration: none !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border: none !important;
        background: transparent !important;
        width: 100% !important;
        text-align: left !important;
        cursor: pointer !important;
        font-size: 14px !important;
        pointer-events: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
        border-radius: 8px !important;
        margin: 2px 8px !important;
        position: relative !important;
        border-left: 3px solid transparent !important;
        transform: translateX(-10px);
        opacity: 0;
        animation: slideInItem 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    }

    /* ANIMAÇÃO SEQUENCIAL DOS ITENS */
    .sb-link:nth-child(1) { animation-delay: 0.1s; }
    .sb-link:nth-child(2) { animation-delay: 0.15s; }
    .sb-link:nth-child(3) { animation-delay: 0.2s; }
    .sb-link:nth-child(4) { animation-delay: 0.25s; }
    .sb-link:nth-child(5) { animation-delay: 0.3s; }
    .sb-link:nth-child(6) { animation-delay: 0.35s; }
    .sb-link:nth-child(7) { animation-delay: 0.4s; }
    .sb-link:nth-child(8) { animation-delay: 0.45s; }
    .sb-link:nth-child(9) { animation-delay: 0.5s; }

    @keyframes slideInItem {
        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    .sb-link:hover {
        background: #1a1a1a !important;
        color: #e0e0e0 !important;
        transform: translateX(4px) !important;
    }

    .sb-link:hover .ico svg {
        fill: #e0e0e0 !important;
        transform: scale(1.1);
    }

    /* PÁGINA ATUAL COM EFEITO ESPECIAL */
    .sb-link.active {
        background: #1a1a1a !important;
        color: #e0e0e0 !important;
        border-left: 3px solid #666666 !important;
    }

    .sb-link.active .ico svg {
        fill: #e0e0e0 !important;
    }

    .sb-link .ico {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 20px !important;
        min-width: 20px !important;
        visibility: visible !important;
        opacity: 1 !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .sb-link .ico svg {
        width: 18px !important;
        height: 18px !important;
        fill: currentColor !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* SCROLL DISCRETO */
    .sidebar {
        overflow-y: scroll !important;
        scroll-behavior: smooth !important;
    }

    .sidebar::-webkit-scrollbar {
        width: 4px;
    }

    .sidebar::-webkit-scrollbar-track {
        background: #1a1a1a;
        border-radius: 2px;
    }

    .sidebar::-webkit-scrollbar-thumb {
        background: #404040;
        border-radius: 2px;
    }

    .sidebar::-webkit-scrollbar-thumb:hover {
        background: #505050;
    }

    /* TOPO DA SIDEBAR */
    .sb-top {
        padding: 25px 20px 20px 20px !important;
        border-bottom: 1px solid #1a1a1a !important;
        background: #0a0a0a !important;
        position: relative !important;
        min-height: 80px !important;
        margin-bottom: 10px !important;
    }

    .sb-logo {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        padding-right: 50px !important;
        width: 100% !important;
    }

    .logo-img {
        width: 36px !important;
        height: 36px !important;
        border-radius: 8px !important;
        border: 1px solid #333333 !important;
        flex-shrink: 0 !important;
    }

    .brand-text {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 !important;
        min-width: 0 !important;
    }

    /* NOME DO SISTEMA - CORES NEUTRAS */
    .brand-text strong {
        font-size: 15px !important;
        color: #e0e0e0 !important;
        font-weight: 600 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        line-height: 1.2 !important;
        word-wrap: break-word !important;
    }

    .brand-text .muted {
        font-size: 11px !important;
        color: #888888 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        font-weight: 400;
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
        line-height: 1.2 !important;
        margin-top: 2px !important;
    }

    /* BOTÃO FECHAR - COM EFEITO ESPECIAL */
    .sidebar-close {
        display: block !important;
        position: absolute !important;
        top: 25px !important;
        right: 20px !important;
        background: #1a1a1a !important;
        border: 1px solid #333333 !important;
        color: #888888 !important;
        cursor: pointer !important;
        padding: 8px !important;
        border-radius: 8px !important;
        z-index: 10002 !important;
        width: 34px !important;
        height: 34px !important;
        pointer-events: auto !important;
        visibility: visible !important;
        opacity: 1 !important;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .sidebar-close:hover {
        background: #252525 !important;
        color: #cccccc !important;
        transform: scale(1.1) !important;
    }

    .sidebar-close:active {
        transform: scale(0.95) !important;
        transition: all 0.1s ease !important;
        animation: closeButtonClick 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    /* ANIMAÇÃO NO CLIQUE DO BOTÃO FECHAR */
    @keyframes closeButtonClick {
        0% {
            box-shadow: 0 0 0 0 rgba(100, 100, 100, 0.3);
        }
        50% {
            box-shadow: 0 0 0 6px rgba(100, 100, 100, 0.1);
        }
        100% {
            box-shadow: none;
        }
    }

    .sidebar-close svg {
        width: 16px !important;
        height: 16px !important;
        display: block !important;
    }

    /* NAVEGAÇÃO */
    .sb-nav {
        padding: 15px 0 !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* LABEL - TEXTO NEUTRO */
    .sb-link .label {
        font-size: 14px !important;
        font-weight: 500 !important;
        color: inherit !important;
        opacity: 1 !important;
        visibility: visible !important;
        display: block !important;
        white-space: nowrap !important;
        overflow: visible !important;
        text-overflow: unset !important;
        max-width: none !important;
        width: auto !important;
    }

    /* DIVISORES */
    .sb-divider {
        margin: 12px 16px !important;
        border: none !important;
        border-top: 1px solid #1a1a1a !important;
        visibility: visible !important;
        opacity: 1 !important;
        display: block !important;
    }

    /* RODAPÉ DA SIDEBAR */
    .sb-footer {
        padding: 20px 0 !important;
        border-top: 1px solid #1a1a1a !important;
        visibility: visible !important;
        opacity: 1 !important;
        display: block !important;
        background: #0a0a0a !important;
        margin-top: 20px !important;
    }

    /* BOTÃO SAIR - NEUTRO */
    .sb-exit {
        color: #b0b0b0 !important;
        background: transparent !important;
        border-left: 3px solid transparent !important;
        margin: 8px !important;
        border-radius: 8px !important;
    }

    .sb-exit:hover {
        background: #1a1a1a !important;
        color: #e0e0e0 !important;
        transform: translateX(4px) !important;
    }

    .sb-exit .ico svg {
        fill: currentColor !important;
    }

    /* TOPBAR COM BOTÃO INTEGRADO (PADRÃO PARA TODAS AS PÁGINAS) */
    .topbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 990;
        background: #0a0a0a !important;
        padding: 12px 15px 12px 65px !important;
        min-height: 60px !important;
        border-bottom: 1px solid #1a1a1a !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    /* BOTÃO DO MENU DENTRO DA TOPBAR (PARA TODAS AS PÁGINAS) */
    .topbar .mobile-menu-toggle {
        position: absolute !important;
        top: 50% !important;
        left: 15px !important;
        transform: translateY(-50%) !important;
        z-index: 1001 !important;
    }

    /* CONTEÚDO DA TOPBAR */
    .topbar .brand {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        flex: 1 !important;
    }

    .topbar .brand strong {
        font-size: 16px !important;
        color: #e0e0e0 !important;
        font-weight: 600 !important;
        margin-bottom: 2px !important;
    }

    .topbar .brand .muted {
        font-size: 12px !important;
        color: #888888 !important;
        font-weight: 400 !important;
    }

    .topbar .badge {
        margin-left: auto !important;
    }

    /* ESPAÇO PARA A TOPBAR */
    .page {
        padding-top: 60px !important;
    }

    .main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* ========================================================================= */
    /* CORREÇÕES ESPECÍFICAS PARA MP CHAT - BOTÃO AO LADO DO AVATAR */
    /* ========================================================================= */
    
    /* MP CHAT OCUPA TELA INTEIRA */
    .mp-chat-container,
    .chat-premium-container,
    .chat-medium-container,
    .wa-shell {
        width: 100% !important;
        height: 100vh !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        z-index: 1000 !important;
    }
    
    /* CORREÇÃO DO BODY PARA MP CHAT */
    body.mp-chat-page {
        overflow: hidden !important;
        height: 100vh !important;
    }
    
    /* NO MP CHAT: BOTÃO AO LADO DO AVATAR DO ASSISTENTE */
    .mp-chat-page .mobile-menu-toggle {
        position: absolute !important;
        top: 50% !important;
        left: 15px !important;
        transform: translateY(-50%) !important;
        z-index: 1001 !important;
        background: rgba(26, 26, 26, 0.9) !important;
        pointer-events: auto !important;
        cursor: pointer !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* FEEDBACK ESPECÍFICO PARA MP CHAT */
    .mp-chat-page .mobile-menu-toggle:active {
        background: #333333 !important;
        transform: translateY(-50%) scale(0.85) !important;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2) !important;
        animation: buttonClickPulse 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }
    
    /* HEADER DO CHAT COM ESPAÇO PARA O BOTÃO */
    .chat-premium-header,
    .chat-medium-header,
    .wa-head {
        padding: 10px 15px 10px 65px !important;
        min-height: 70px !important;
        position: relative !important;
    }
    
    /* ÁREA DE MENSAGENS MAIOR */
    .chat-premium-messages,
    .chat-medium-messages,
    .wa-msgs {
        height: calc(100vh - 140px) !important;
        padding: 15px !important;
    }
    
    /* INPUT COMPACTO */
    .chat-premium-input-container,
    .chat-medium-input-container,
    .wa-compose {
        padding: 10px 15px !important;
        position: fixed !important;
        bottom: 0 !important;
        width: 100% !important;
        background: #0a0a0a !important;
        border-top: 1px solid #1a1a1a !important;
    }
    
    /* REMOVER MARGENS E PADDINGS DESNECESSÁRIOS */
    .container[style*="mp-chat"],
    .main #mpChatView {
        padding: 0 !important;
        margin: 0 !important;
        height: 100vh !important;
    }
    
    /* TOPBAR DO SISTEMA ESCONDIDA NO MP CHAT */
    .mp-chat-page .topbar {
        display: none !important;
    }
    
    .mp-chat-page .page {
        padding-top: 0 !important;
    }
}

/* DESKTOP - MANTEM COMPORTAMENTO ORIGINAL */
@media (min-width: 769px) {
    .mobile-menu-toggle,
    .mobile-overlay,
    .sidebar-close {
        display: none !important;
    }
    
    /* RESTAURA COMPORTAMENTO ORIGINAL DA SIDEBAR NO DESKTOP */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 78px;
        background: #0c0d10;
        border-right: 1px solid rgba(255,255,255,.06);
        padding: 14px 10px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        z-index: 1000;
        transition: width .2s ease;
        overflow: hidden;
    }
    
    .sidebar:hover {
        width: 260px;
        overflow: auto;
    }
    
    .sidebar .label {
        opacity: 0;
        max-width: 0;
        white-space: nowrap;
        overflow: hidden;
        transition: opacity .2s ease, max-width .2s ease;
    }
    
    .sidebar:hover .label {
        opacity: 1;
        max-width: 200px;
    }
}