/* =========================================
   BARRA LATERAL (SIDEBAR) - FINAL
   ========================================= */

.sidebar {
    width: var(--sidebar-width); /* Segue a variável do base.css */
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.1);
    overflow-x: hidden !important;
    overflow-y: hidden !important;
}

/* Cabeçalho Interno */
.sidebar-header {
    height: 80px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    gap: 0.8rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.8rem;
    overflow: visible;
    min-width: 0;
    flex: 1;
}

.logo i {
    font-size: 1.8rem;
    min-width: 30px;
    min-height: 30px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: visible;
}

.logo h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 0;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.sidebar-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-toggle i {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Chevron visível por padrão */
.sidebar-toggle .chevron-icon {
    display: inline;
    opacity: 1;
}

.sidebar-toggle .menu-icon {
    display: none;
    opacity: 0;
    position: absolute;
}

/* Quando minimizado - chevron gira e esconde, hamburger aparece */
body.compact-mode .sidebar-toggle .chevron-icon {
    opacity: 0;
    transform: rotate(180deg);
}

body.compact-mode .sidebar-toggle .menu-icon {
    display: inline;
    opacity: 1;
}

/* Menu */
.nav-menu {
    padding: 1rem 0.5rem;
    margin: 0;
    list-style: none;
    flex-grow: 1;
    overflow-y: visible !important;
    overflow-x: hidden !important;
}

.nav-item {
    margin-bottom: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0.7rem 0.8rem;
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    background: rgba(255,255,255,0.1);
    transform: translateX(3px);
}

.nav-item.active .nav-link {
    background: rgba(255,255,255,0.2);
    font-weight: 500;
}

.nav-link i {
    font-size: 1rem;
    min-width: 20px;
    min-height: 20px;
    text-align: center;
    margin-right: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: visible;
}

.nav-link span {
    font-size: 0.85rem;
    transition: opacity 0.2s;
}

/* Badge */
.notification-badge,
.carrinho-badge {
    background: #ef4444;
    color: #fff !important;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: auto;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
    display: none; /* Por padrão, escondido */
}

/* Só mostra o badge se tiver conteúdo e não estiver explicitamente escondido */
.notification-badge:not([style*="display: none"]),
.carrinho-badge:not([style*="display: none"]) {
    display: flex;
}

/* Rodapé */
.sidebar-footer {
    padding: 1.2rem 1.5rem 2rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.15);
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.user-info {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 1rem;
    overflow: visible;
    white-space: nowrap;
}

.user-info i {
    font-size: 2.2rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible;
}

.user-info span {
    font-size: 1rem;
    font-weight: 600;
}

.logout-icon {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-left: auto;
}

.logout-icon:hover {
    color: #ffffff;
    transform: scale(1.1);
}

/* =========================================
   REGRAS ESPECÍFICAS DE ESTADO E RESOLUÇÃO
   ========================================= */

/* 1. MODO COMPACTO (Ativado pelo botão no PC) */
body.compact-mode .logo h2,
body.compact-mode .nav-link span,
body.compact-mode .user-info span {
    display: none;
    opacity: 0;
}

body.compact-mode .logo {
    justify-content: center;
}

body.compact-mode .nav-link {
    justify-content: center;
    padding: 0.7rem;
}

body.compact-mode .nav-link i {
    margin-right: 0;
}

body.compact-mode .sidebar-footer {
    padding: 1rem;
    display: flex;
    justify-content: center;
}

body.compact-mode .user-info {
    justify-content: center;
    flex-direction: column;
    gap: 0.5rem;
}

body.compact-mode .notification-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    padding: 2px 5px;
    font-size: 0.6rem;
}

body.compact-mode .logout-icon {
    display: none !important;
}

/* 2. TABLET (Força visual compacto AUTOMATICAMENTE) */
@media (min-width: 769px) and (max-width: 1024px) {
    /* Força largura */
    .sidebar {
        width: 80px !important;
    }

    /* Esconde textos */
    .logo h2,
    .nav-link span,
    .user-info span,
    .sidebar-toggle {
        display: none !important;
    }

    /* Centraliza ícones */
    .nav-link {
        justify-content: center !important;
        padding: 0.7rem !important;
    }

    .nav-link i {
        margin: 0 !important;
    }

    .sidebar-footer {
        padding: 1rem !important;
        display: flex !important;
        justify-content: center !important;
    }

    .user-info {
        justify-content: center !important;
        flex-direction: column;
        gap: 0.5rem;
    }

    .notification-badge {
        position: absolute;
        top: 5px;
        right: 5px;
        padding: 2px 5px;
        font-size: 0.6rem;
    }
    
    /* Esconde ícone de logout no tablet */
    .logout-icon {
        display: none !important;
    }
}

/* 3. MOBILE (Barra fixa de ícones + expansão ao clicar) */
@media (max-width: 768px) {
    /* Esconde o botão de recolher/chevron para não ficar em cima do ícone do peixe */
    .sidebar-toggle {
        display: none !important;
    }

    /* Barra sempre visível como coluna de ícones */
    .sidebar {
        width: 64px !important;
        transform: translateX(0);
        transition: width 0.3s ease;
        margin: 0 !important;
        padding: 0 !important;
        border-right: none !important; /* Remove borda que pode criar gap visual */
    }

    /* Esconde textos para ficar só os ícones */
    .logo h2,
    .nav-link span,
    .user-info span {
        display: none;
    }

    /* Quando o usuário clica na logo (body.mobile-menu-open),
       a sidebar expande e mostra os textos completos */
    body.mobile-menu-open .sidebar {
        width: 240px !important;
    }

    body.mobile-menu-open .logo h2,
    body.mobile-menu-open .nav-link span,
    body.mobile-menu-open .user-info span {
        display: inline;
    }

    /* Ícones centralizados quando só a coluna estreita está visível */
    .sidebar-header {
        justify-content: center;
        padding: 0 0.5rem;
    }

    .logo {
        justify-content: center;
        margin: 0 auto;
    }

    .nav-link {
        justify-content: center;
        padding: 0.7rem 0.5rem !important;
    }

    .nav-link i {
        margin-right: 0 !important;
    }

    .sidebar-footer {
        display: flex;
        justify-content: center;
        padding: 1rem 0.5rem !important;
    }

    .user-info {
        justify-content: center;
        flex-direction: column;
        gap: 0.5rem;
    }

    /* Quando expandir (mostrar textos), volta a alinhar à esquerda */
    body.mobile-menu-open .sidebar-header {
        justify-content: space-between;
        padding: 0 1.5rem;
    }

    body.mobile-menu-open .logo {
        justify-content: flex-start;
        margin: 0;
    }

    body.mobile-menu-open .nav-link {
        justify-content: flex-start;
        padding: 0.7rem 0.8rem !important;
    }

    body.mobile-menu-open .nav-link i {
        margin-right: 12px !important;
    }

    body.mobile-menu-open .sidebar-footer {
        justify-content: flex-start;
        padding: 1.2rem 1.5rem 2rem 1.5rem !important;
    }

    body.mobile-menu-open .user-info {
        justify-content: flex-start;
        flex-direction: row;
        gap: 1rem;
    }
    
    /* Esconde ícone de logout no mobile */
    .logout-icon {
        display: none !important;
    }
}

/* =========================================
   BOTÃO ESPECIAL "SE TORNE NOSSO FORNECEDOR"
   ========================================= */
#fornecedorLink {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    margin-top: 0.5rem !important;
    border-radius: 8px !important;
    transition: all 0.3s ease !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
}

#fornecedorLink:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    transform: translateX(3px) scale(1.02) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4) !important;
}

#fornecedorLink i {
    color: #ffffff !important;
}

#fornecedorLink span {
    color: #ffffff !important;
    font-weight: 600 !important;
}

/* Badge de notificação é controlado pelo JavaScript */

/* Remove qualquer ícone de sino dos itens Contato e Sede Local */
.nav-link[data-page="sedelocal"] i.fa-bell,
.nav-link[data-page="sedelocal"] i.fas.fa-bell,
.nav-link[data-page="sedelocal"] i.far.fa-bell,
.nav-link[data-page="sedelocal"] i[class*="bell"],
.nav-link[data-page="contato"] i.fa-bell,
.nav-link[data-page="contato"] i.fas.fa-bell,
.nav-link[data-page="contato"] i.far.fa-bell,
.nav-link[data-page="contato"] i[class*="bell"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    font-size: 0 !important;
}

/* Garante que apenas o ícone correto apareça */
.nav-link[data-page="sedelocal"] i.fa-map-marker-alt,
.nav-link[data-page="sedelocal"] i.fas.fa-map-marker-alt {
    display: flex !important;
}

.nav-link[data-page="contato"] i.fa-phone-alt,
.nav-link[data-page="contato"] i.fas.fa-phone-alt {
    display: flex !important;
}
