:root {
            --sidebar-bg: #45276F;
            --sidebar-bg-hover: #6A459F;
            --sidebar-bg-active: #8d4de8;
            --sidebar-width-expanded: 250px;
            --sidebar-width-collapsed: 80px;
            --content-bg: #f4f4f9;
        }
        body {
    margin: 0;
    font-family: 'Montserrat', sans-serif; 
    background-color: var(--content-bg);
}
        

        /* --- ESTRUTURA PRINCIPAL --- */
        .sidebar {
            width: var(--sidebar-width-expanded);
            background-color: var(--sidebar-bg);
            color: #fff;
            height: 100vh;
            display: flex;
            flex-direction: column;
            transition: width 0.3s ease;
            position: fixed; /* Fixa a barra na tela */
            z-index: 100;
        }
        .main-content {
            flex-grow: 1;
            height: 100vh;
            overflow-y: auto;
            margin-left: var(--sidebar-width-expanded); /* Empurra o conteúdo para a direita */
            transition: margin-left 0.3s ease;
        }

        /* --- ESTADO RECOLHIDO --- */
        body.sidebar-collapsed .sidebar {
            width: var(--sidebar-width-collapsed);
        }
        body.sidebar-collapsed .main-content {
            margin-left: var(--sidebar-width-collapsed);
        }
        body.sidebar-collapsed .sidebar .nav-text {
            display: none;
        }
        body.sidebar-collapsed .sidebar .logo img {
            max-width: 150%;
            margin-left: -8px;
        }
        body.sidebar-collapsed .sidebar .nav-link {
            justify-content: center;
  
        }
        body.sidebar-collapsed .sidebar-toggle {
            justify-content: center;
        }
        body.sidebar-collapsed .sidebar-toggle .toggle-arrow {
            transform: rotate(180deg);
        }



        /* --- CONTEÚDO DO MENU LATERAL --- */
        .sidebar .logo {
    padding: 20px;
    text-align: center;
    height: 60px; /* Altura fixa para evitar "pulos" no layout */
    display: flex;
    align-items: center;
    justify-content: center;
      }

      .logo-expanded img, .logo-collapsed img {
          max-height: 50px; /* Altura máxima para ambos os logos */
          max-width: 100%;
          transition: opacity 0.3s ease;
      }

      .logo-collapsed {
          display: none; /* O logo recolhido começa escondido */
      }
      .logo-expanded {
          display: block;
      }

      body.sidebar-collapsed .logo-expanded {
          display: none; /* Esconde o logo grande */
      }
      body.sidebar-collapsed .logo-collapsed {
          display: block; /* Mostra o logo pequeno */
      }
        .sidebar .logo img {
            max-width: 100%;
            transition: max-width 0.3s ease;
        }
        .sidebar nav {
    flex-grow: 1;
    overflow-y: auto; /* Permite a rolagem vertical quando o conteúdo for maior que a área */
    min-height: 0;    /* Um ajuste necessário para o overflow funcionar corretamente em layouts flexbox */
}

/* Estiliza a barra de rolagem para navegadores baseados em WebKit (Chrome, Edge, etc.) */
.sidebar nav::-webkit-scrollbar {
  width: 8px; /* Largura da barra de rolagem */
}

/* Estiliza o fundo da barra de rolagem */
.sidebar nav::-webkit-scrollbar-track {
  background: var(--sidebar-bg); /* Usa a mesma cor de fundo da sidebar */
}

/* Estiliza o "puxador" da barra de rolagem */
.sidebar nav::-webkit-scrollbar-thumb {
  background-color: var(--sidebar-bg-hover); /* Cor um pouco mais clara para destaque */
  border-radius: 4px;
  border: 2px solid var(--sidebar-bg);
}
        .sidebar nav ul {
            list-style: none;
            padding: 0 15px;
            margin: 0;
        }
        .sidebar .nav-link {
            display: flex;
            align-items: center;
            gap: 15px;
            color: #fff;
            text-decoration: none;
            padding: 15px;
            border-radius: 6px;
            margin-bottom: 10px;
            transition: background-color 0.2s;
            overflow: hidden; /* Garante que o texto não vaze durante a animação */
            white-space: nowrap;
        }
        .sidebar .nav-link:hover {
            background-color: var(--sidebar-bg-hover);
        }
        .sidebar .nav-link.active {
            background-color: var(--sidebar-bg-active);
            font-weight: bold;
        }
        .sidebar .nav-link img {
    flex-shrink: 0;
    /* Filtro que transforma a imagem preta em branca */
    filter: brightness(0) invert(1);
    transition: filter 0.2s ease;
}



        /* --- BOTÃO DE RECOLHER --- */
        .sidebar-toggle {
            padding: 15px;
            background-color: rgba(0,0,0,0.2);
            cursor: pointer;
            display: flex;
            align-items: center;
            gap: 15px;
            border: none;
            color: #fff;
            width: 100%;
            overflow: hidden;
            white-space: nowrap;
        }
        .sidebar-toggle .toggle-arrow {
            transition: transform 0.3s ease;
            fill: #fff;
            flex-shrink: 0;
        }

        #module-container iframe {
    display: block;
}

        /* --- ÁREA DE CONTEÚDO --- */
      #module-container {
    height: 100%;
    padding: 0;
    font-size: 0;
}

.sidebar-footer {
    padding: 0 15px; /* Mesmo padding dos itens de navegação */
    margin-top: auto; /* MÁGICA: Empurra este bloco para o fundo */
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.2); /* Linha divisória sutil */
}
 #login-page {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: #f0f2f5;
            display: flex;
            justify-content: center;
            align-items: center;
            flex-direction: column;
            z-index: 1000;
        }
        #login-page img {
            max-width: 300px;
            margin-bottom: 40px;
        }
        #login-page-button {
            padding: 12px 24px;
            font-size: 1.1em;
            cursor: pointer;
            background-color: #7b2cbf; /* Cor roxa da sua sidebar */
            color: white;
            border: none;
            border-radius: 8px;
        }
        .hidden {
            display: none !important;
        }
        #login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    
    /* Fundo Roxo com a Imagem */
    background: linear-gradient(135deg, rgba(69, 39, 111, 0.92), rgba(42, 23, 71, 0.95)), 
                url('https://canaldaeng.com.br/wp-content/uploads/login-scaled.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    /* Centralização total */
    display: flex;
    justify-content: center;
    align-items: center;
}

.sidebar-footer {
            display: flex;
            flex-direction: column;
            align-items: center; /* Centraliza os itens horizontalmente */
            gap: 10px; /* Adiciona um espaço entre os itens */
            padding-bottom: 20px;
        }

        .sidebar-divider {
            width: 80%; /* Linha não toca as bordas */
            border: none;
            border-top: 1px solid rgba(255, 255, 255, 0.2); /* Cor da linha */
            margin: 5px 0; /* Espaçamento vertical */
        }
        #loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 1.2em;
    font-weight: 600;
    transition: opacity 0.3s ease;
}

/* A classe 'hidden' que já existe será usada para esconder o overlay */
#loading-overlay.hidden {
    display: none;
}

.loader {
    border: 8px solid #f3f3f3; /* Cinza claro */
    border-top: 8px solid var(--sidebar-bg-active); /* Roxo do tema */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    letter-spacing: 1px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* Container para alinhar o slider e o texto */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 15px; /* Espaçamento similar aos outros links */
}

/* Oculta o texto quando a sidebar está recolhida */
.sidebar-collapsed .theme-switch-wrapper .nav-text {
    display: none;
}

.theme-switch {
  position: relative;
  display: inline-block;
  width: 44px; /* Largura do slider */
  height: 24px; /* Altura do slider */
}

/* Esconde o checkbox padrão */
.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* A base do slider */
.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: .4s;
}

/* O círculo que se move */
.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

/* Estilos para quando o slider está ATIVADO (dark mode) */
input:checked + .slider {
  background-color: #6A459F; /* Cor roxa da sua marca */
}

input:checked + .slider:before {
  transform: translateX(20px); /* Move o círculo para a direita */
}

/* Formato arredondado */
.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Para Chrome, Edge, Safari, Opera (Navegadores WebKit/Blink) */

/* Define a largura da barra de rolagem inteira */
body.dark-mode ::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}


/* A parte que você arrasta (o "polegar") */
body.dark-mode ::-webkit-scrollbar-thumb {
  background-color: #5A3A8A; /* O nosso roxo-médio */
  border-radius: 10px;
}

/* Efeito ao passar o mouse sobre a barra */
body.dark-mode ::-webkit-scrollbar-thumb:hover {
  background-color: #6A459F; /* O roxo-claro para dar um destaque */
}
/* Define uma cor de fundo padrão para os iframes no modo claro */
#module-container iframe {
    background-color: var(--cor-fundo); /* O seu cinza claro padrão #f4f4f9 */
}

#module-container iframe {
    vertical-align: top;
}

/* Define uma cor de fundo para os iframes QUANDO o modo escuro está ativo */
body.dark-mode #module-container iframe {
    background-color: #0a0a14; /* O seu fundo preto-azulado do modo escuro */
}
#active-project-container {
    padding: 0 15px 15px 15px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

#active-project-container h4 {
    margin: 0 0 5px 0;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 1px;
}

#active-project-container p {
    margin: 0;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    word-wrap: break-word; /* Garante que nomes longos quebrem a linha */
}

/* Esconde o container quando a sidebar está recolhida */
.sidebar-collapsed #active-project-container {
    display: none !important;
}
/* --- CHAT DO GESTOR (FLUTUANTE) --- */
#admin-chat-btn {
    position: fixed;
    
    /* 1. POSIÇÃO PADRÃO (Baixa, para Budget, Takeoff, etc.) */
    bottom: 30px; 
    
    right: 30px;
    width: 60px;
    height: 60px;
    background-color: var(--sidebar-bg);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 2000;
    
    /* Adiciona uma transição suave para ele "deslizar" quando mudar de aba */
    transition: bottom 0.4s ease, transform 0.2s;
}

#admin-chat-btn:hover {
    transform: scale(1.1);
    background-color: var(--sidebar-bg-hover);
}

#chat-notification-dot {
    position: absolute;
    top: 0;
    right: 0;
    width: 15px;
    height: 15px;
    background-color: #e74a3b; /* Vermelho */
    border-radius: 50%;
    border: 2px solid white;
}

#admin-chat-window {
    position: fixed;
    
    /* 1. POSIÇÃO PADRÃO DA JANELA */
    bottom: 100px; 
    
    right: 20px;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 2000;
    overflow: hidden;
    border: 1px solid #ccc;
    
    /* Transição suave também na janela */
    transition: bottom 0.4s ease;
}

/* --- 2. REGRAS ESPECÍFICAS PARA QUANDO O DASHBOARD ESTIVER ATIVO --- */

/* Quando o body tiver a classe 'is-dashboard', o botão SOBE */
body.is-dashboard #admin-chat-btn {
    bottom: 120px !important; /* Sobe para fugir do botão da IA */
}

/* Quando o body tiver a classe 'is-dashboard', a janela SOBE junto */
body.is-dashboard #admin-chat-window {
    bottom: 190px !important;
}

/* Dark Mode para o Chat */
body.dark-mode #admin-chat-window {
    background-color: #1a1a3d;
    border-color: #45276F;
}

.admin-chat-header {
    background-color: var(--sidebar-bg);
    color: white;
    padding: 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-chat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.2em;
    cursor: pointer;
}

.admin-chat-body {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background-color: #f4f4f9;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

body.dark-mode .admin-chat-body {
    background-color: #0a0a14;
}

.admin-chat-footer {
    padding: 10px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background-color: white;
}

body.dark-mode .admin-chat-footer {
    background-color: #1a1a3d;
    border-top-color: #45276F;
}

.admin-chat-footer input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    outline: none;
}

.admin-chat-footer button {
    background-color: var(--sidebar-bg);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
}

/* Balões de Mensagem */
.msg-bubble {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9em;
    line-height: 1.4;
    position: relative;
}

.msg-admin {
    align-self: flex-end; /* Direita */
    background-color: #dcf8c6; /* Verde WhatsApp */
    color: #333;
    border-bottom-right-radius: 2px;
}

.msg-client {
    align-self: flex-start; /* Esquerda */
    background-color: white;
    color: #333;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.msg-sender {
    font-size: 0.75em;
    font-weight: bold;
    margin-bottom: 3px;
    display: block;
    color: #555;
}
.msg-time {
    display: block;
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.45); /* Cinza translúcido para funcionar em fundo verde ou branco */
    text-align: right;
    margin-top: 4px;
    font-weight: normal;
}
/* Classe para esconder o chat quando atrapalha a visão */
#admin-chat-btn.chat-fade-out {
    opacity: 0;
    pointer-events: none; /* Impede cliques quando invisível */
    transform: translateY(20px); /* Desliza um pouco para baixo */
}
       
/* --- TELA DE LOGIN ESTILIZADA --- */
#login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    
    /* CORREÇÃO DO FUNDO:
       Reduzi a opacidade de 0.95 para 0.85 para a imagem aparecer.
    */
    background: linear-gradient(135deg, rgba(69, 39, 111, 0.85), rgba(42, 23, 71, 0.85)), 
                url('https://canaldaeng.com.br/wp-content/uploads/login-scaled.jpg');
    
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    /* Centralização Flexbox Absoluta */
    display: flex;
    justify-content: center;
    align-items: center;
}

#login-page.hidden {
    display: none !important;
}

.login-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 450px; /* Largura máxima do conjunto */
    padding: 20px;
    animation: fadeIn 1s ease-out;
}

.login-logo {
    text-align: center;
    margin-bottom: 30px; /* Espaço entre o logo e o cartão do Clerk */
}

.login-logo img {
    max-width: 240px; 
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.login-logo p {
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 500;
    margin-top: 10px;
    opacity: 0.95;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* --- FORÇA O CARTÃO DO CLERK A SER O ÚNICO CARTÃO --- */
/* Isso garante que o container do Clerk fique centralizado */
#clerk-sign-in-mount {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* Ocultar marca Clerk */
.cl-footer, 
.cl-internal-b3fm6y,
a[href*="clerk"] {
    display: none !important;
}

/* ==========================================================================
   OTIMIZAÇÃO MOBILE (Adicione ao final do index.css)
   ========================================================================== */

/* Regras para Tablets e Celulares (telas menores que 768px) */
@media screen and (max-width: 768px) {

    /* --- 1. ESTRUTURA E MENU LATERAL --- */
    
    /* O menu vira um painel deslizante sobreposto */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 250px !important; /* Sempre largura total quando aberto */
        transform: translateX(-100%); /* Começa escondido à esquerda */
        transition: transform 0.3s ease-in-out;
        z-index: 9999; /* Acima de tudo */
        box-shadow: 4px 0 15px rgba(0,0,0,0.5);
    }

    /* Classe auxiliar para mostrar o menu via JS */
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    
    /* Botão de abrir menu (Toggle) fixo e visível */
    .sidebar-toggle {
        position: fixed;
        bottom: 20px;
        left: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        justify-content: center;
        z-index: 10001; /* Acima até do overlay */
        background-color: var(--sidebar-bg);
        box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    }
    
    /* Ajuste da seta no mobile */
    .sidebar.mobile-open + .sidebar-toggle .toggle-arrow {
        transform: rotate(180deg); 
    }

    /* O conteúdo principal ocupa 100% da tela sempre */
    .main-content {
        margin-left: 0 !important;
        width: 100%;
    }

    /* Fundo escuro quando o menu abre (Backdrop) */
    #mobile-menu-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 9990; /* Logo abaixo do menu */
        backdrop-filter: blur(2px);
    }

    #mobile-menu-overlay.active {
        display: block;
    }

    /* --- 2. LOGIN PAGE --- */
    .login-wrapper {
        width: 90%; /* Margem de segurança nas laterais */
        padding: 15px;
    }
    
    .login-logo img {
        max-width: 180px; /* Logo menor no celular */
    }

    /* --- 3. CHAT DO GESTOR --- */
    /* Ajuste para não cobrir o botão do menu */
    #admin-chat-btn {
        bottom: 90px !important; /* Mais alto para não bater no toggle do menu */
        right: 20px;
        width: 50px;
        height: 50px;
    }

    /* Janela do chat quase tela cheia para facilitar digitação */
    #admin-chat-window {
        width: 90%;
        left: 5%;
        right: 5%;
        bottom: 150px !important;
        height: 60vh;
    }

    /* --- 4. TEMA SWITCH --- */
    /* Garante que o texto não quebre layout */
    .theme-switch-wrapper .nav-text {
        font-size: 0.9em;
    }
}