/* ==========================================================================
   VARIÁVEIS GLOBAIS E RESET DE PÁGINA
   ========================================================================== */
:root { 
    --accent: #00ffcc; 
    --bg: #0f172a;     
    --panel: rgba(30, 41, 59, 0.95); 
    --text-muted: #94a3b8;
}

body { 
    margin: 0; 
    overflow: hidden; 
    background: var(--bg); 
    font-family: 'Segoe UI', sans-serif; 
    color: white; 
}

/* ==========================================================================
   NOVA SUPER BARRA PROFISSIONAL (IDEIAS AKIZ)
   ========================================================================== */
.top-bar {
    position: fixed; top: 0; left: 0; width: 100vw; height: 48px; /* <-- REDUZIDO PARA 48px! Mais fina e estética */
    background-color: var(--panel);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex; justify-content: flex-start; /* Prepara o terreno para o scroll */
    align-items: center; padding: 0 15px; z-index: 3000; box-sizing: border-box;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 15px;
}
.top-bar::-webkit-scrollbar { display: none; } /* Esconde a barra feia de rolagem */

.logo-area { display: flex; align-items: center; justify-content: flex-start; flex-shrink: 0; }
.logo-akiz { color: var(--accent); font-weight: 800; font-size: 1rem; }
.logo-ideias { color: #a29bfe; font-weight: 800; font-size: 1rem; }
.hub-link { display: flex; align-items: center; text-decoration: none; flex: 0 0 auto; }
.logo-hub { width: 26px; height: 26px; border-radius: 50%; box-shadow: 0 0 8px rgba(0, 255, 204, 0.4); transition: transform 0.2s; margin-right: 8px;}
.logo-hub:hover { transform: scale(1.1); box-shadow: 0 0 15px rgba(0, 255, 204, 0.8); }

/* O PULO DO GATO HORIZONTAL: Empurra os botões para a direita se houver espaço! */
.actions-area { display: flex; gap: 6px; align-items: center; flex-shrink: 0; margin-left: auto; }

/* Botões Profissionais (Lipoaspiração aplicada) */
.btn-pro {
    background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.15); color: white; 
    padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; 
    transition: all 0.2s ease; display: flex; align-items: center; gap: 5px; white-space: nowrap;
}
.btn-pro:hover { background: rgba(255,255,255,0.1); border-color: #a29bfe; }

.btn-pro-action {
    background: transparent; border: 1px solid rgba(255,255,255,0.1); color: var(--text-muted); 
    padding: 5px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; cursor: pointer; 
    transition: all 0.2s ease; white-space: nowrap;
}
.btn-pro-action:hover { background: rgba(0,255,204,0.1); color: var(--accent); border-color: var(--accent); }

/* Divisórias na barra */
.escala-container { opacity: 0.3; pointer-events: none; display: flex; align-items: center; gap: 8px; margin-left: 5px; border-left: 1px solid rgba(255,255,255,0.1); padding-left: 10px; }
.fundo-container { position: relative; display: flex; align-items: center; gap: 6px; margin-left: 5px; border-left: 1px solid rgba(255,255,255,0.1); padding-left: 10px; cursor: pointer; }

/* Botão padrão do Sidebar */
.main-btn { padding: 8px 15px; background: var(--accent); color: #0f172a; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; transition: 0.2s; }
.main-btn:hover { filter: brightness(1.1); }

/* ==========================================================================
   CENÁRIO PRINCIPAL E CÂMERA (FÍSICA DO MAPA)
   ========================================================================== */
#viewport { 
    width: 100vw; height: 100vh; overflow: hidden; position: relative; cursor: grab; 
}
#canvas-area { 
    width: 5000px; height: 5000px; position: absolute; transform-origin: 0 0; 
}
canvas { 
    position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none; 
}

/* ==========================================================================
   INTERFACE E MENUS FLUTUANTES
   ========================================================================== */
#sidebar { position: fixed; top: 65px; left: 20px; z-index: 2000; background: var(--panel); padding: 15px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); width: 200px; max-height: 70vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.proj-item { padding: 10px; margin-bottom: 5px; background: rgba(255,255,255,0.05); border-radius: 6px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; font-size: 13px; transition: background 0.2s; }
.proj-item:hover { background: rgba(255,255,255,0.1); }
.proj-item.active { border: 1px solid var(--accent); background: rgba(0,255,204,0.15); color: var(--accent); font-weight: bold; }
.btn-del-proj { color: #ff5e57; font-weight: bold; padding: 2px 6px; border-radius: 4px; cursor: pointer; }
.btn-del-proj:hover { background: rgba(255, 94, 87, 0.2); }

#footer-auteria { position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; color: rgba(255,255,255,0.3); z-index: 2000; pointer-events: none; letter-spacing: 1px; }

/* ==========================================================================
   ANIMAÇÃO DE BRILHO DO BOTÃO DE VERSÃO
   ========================================================================== */
@keyframes pulsar-borda {
    0% { border-color: rgba(0, 255, 204, 0.2); box-shadow: 0 0 0 rgba(0, 255, 204, 0); }
    50% { border-color: rgba(0, 255, 204, 1); box-shadow: 0 0 12px rgba(0, 255, 204, 0.6); color: #00ffcc; }
    100% { border-color: rgba(0, 255, 204, 0.2); box-shadow: 0 0 0 rgba(0, 255, 204, 0); }
}

#version-btn { 
    position: fixed; bottom: 10px; left: 20px; z-index: 2000; 
    background: rgba(255, 255, 255, 0.05); padding: 5px 10px; border-radius: 6px; 
    font-size: 11px; color: #94a3b8; cursor: pointer; transition: background 0.2s; 
    border: 1px solid rgba(0, 255, 204, 0.3); 
    animation: pulsar-borda 2.5s infinite ease-in-out;
}

#version-btn:hover { 
    background: rgba(0, 255, 204, 0.1); color: var(--accent); border-color: var(--accent); 
    animation: none; box-shadow: 0 0 15px rgba(0, 255, 204, 0.8);
}

/* Modais */
.modal-box { position:fixed; top:50%; left:50%; transform:translate(-50%, -50%); background:#1e293b; padding:25px; border-radius:12px; border:1px solid var(--accent); z-index:3000; box-shadow:0 10px 40px rgba(0,0,0,0.8); width: 350px; max-width: 90vw; }
.modal-box h3 { color: var(--accent); margin-top: 0; text-align: center; }
.tutorial-content p, .patch-content p, .patch-content li { font-size: 13px; color: #e2e8f0; margin-bottom: 10px; line-height: 1.5; }
.patch-content h4 { color: #a29bfe; margin-bottom: 5px; margin-top: 0; }
.patch-content ul { padding-left: 20px; margin-top: 0; }
.tutorial-content strong { color: #feca57; }

/* ==========================================================================
   ENTIDADES (BOLHAS DE IDEIA E IMAGENS)
   ========================================================================== */
.entity { 
    position: absolute; z-index: 100; cursor: grab; background: #1e293b; 
    border: 2px solid rgba(255,255,255,0.1); transition: box-shadow 0.3s, background 0.3s; 
    display: flex; flex-direction: column; overflow: hidden; user-select: none; -webkit-user-select: none; 
}

.bubble { width: 120px; height: 120px; border-radius: 50%; align-items: center; justify-content: center; padding: 15px; box-sizing: border-box; }
.image-card { width: 250px; height: 200px; border-radius: 12px; resize: both; }

.label { font-weight: bold; text-align: center; color: var(--accent); padding: 5px; pointer-events: none; word-wrap: break-word; font-size: 14px; line-height: 1.2; }

/* ==========================================================================
   ESTADO EXPANDIDO (PC PADRÃO)
   ========================================================================== */
.expanded { 
    width: 400px !important; height: auto !important; min-height: 200px !important;
    max-height: 80vh !important; max-width: none !important; aspect-ratio: unset !important; 
    border-radius: 12px !important; z-index: 9000 !important; cursor: default !important; 
    background: rgba(15, 23, 42, 0.85); border: 2px solid rgba(0, 255, 204, 0.4); 
    backdrop-filter: blur(12px) !important; -webkit-backdrop-filter: blur(12px) !important; 
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.8) !important; display: flex !important; flex-direction: column !important;
}

.expanded .label { display: none; }

.content-area { 
    flex: 1; width: 100%; height: 100%; outline: none; display: none; overflow-y: auto; 
    padding: 20px; color: #e2e8f0; cursor: text; box-sizing: border-box; user-select: text; -webkit-user-select: text; 
}
.expanded .content-area { display: block; flex: 1; overflow-y: auto; padding-right: 5px; }

.tools { 
    margin-top: auto; display: none; width: 100%; background: rgba(0,0,0,0.8); padding: 8px; 
    justify-content: space-around; border-top: 1px solid rgba(255,255,255,0.1); box-sizing: border-box; 
}
.expanded .tools, .image-card:hover .tools { display: flex; }
.tool-btn { background: none; border: none; color: white; cursor: pointer; font-size: 16px; opacity: 0.8; }
.tool-btn:hover { opacity: 1; transform: scale(1.1); }

/* ==========================================================================
   INDICADORES E CAIXA DE SELEÇÃO MÚLTIPLA
   ========================================================================== */
.entity.selecionada-ativa { z-index: 150 !important; }
#caixa-selecao { position: fixed; border: 1px dashed #00ffcc; background: rgba(0, 255, 204, 0.1); z-index: 9999; pointer-events: none; display: none; }

/* ==========================================================================
   SIDEBAR DE MANUAL E ATUALIZAÇÕES
   ========================================================================== */
#modal-patch {
    position: fixed; top: 48px; right: 0; width: 320px; height: calc(100vh - 48px);
    background: var(--panel); border: 1px solid var(--accent); border-right: none;
    border-radius: 12px 0 0 12px; padding: 20px; box-sizing: border-box; z-index: 3000;
    color: white; box-shadow: -5px 0 25px rgba(0,0,0,0.5);
    transform: translateX(110%); transition: transform 0.3s ease-in-out;
    display: flex; flex-direction: column;
}

#modal-patch.aberto { transform: translateX(0); }
.patch-content { flex-grow: 1; overflow-y: auto; padding-right: 8px; }

/* ==========================================================================
   CONTRASTE AUTOMÁTICO PARA FUNDOS CLAROS
   ========================================================================== */
.tema-claro .top-bar { background-color: rgba(255, 255, 255, 0.85) !important; border-bottom: 1px solid rgba(0, 0, 0, 0.1); }
.tema-claro .logo-ideias { color: #4a60ba; }
.tema-claro .btn-pro { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); color: #0f172a; }
.tema-claro .btn-pro:hover { background: rgba(0,0,0,0.1); border-color: #a29bfe; }
.tema-claro .btn-pro-action { color: #475569; border-color: rgba(0,0,0,0.1); }
.tema-claro .btn-pro-action:hover { color: #0f172a; border-color: var(--accent); background: rgba(0,255,204,0.1); }

.tema-claro .label { color: #0f172a !important; font-weight: 900; }
.tema-claro .content-area { color: #1e293b !important; font-weight: 500; }
.tema-claro .tool-btn { color: #0f172a !important; }
.tema-claro .fundo-container span, .tema-claro #box-escala span { color: #0f172a !important; }
.tema-claro .fundo-container { background: rgba(255,255,255,0.5); border: 1px solid rgba(0,0,0,0.1);}

/* Isso vai transformar as bolhas escuras em bolhas claras e limpas quando o fundo for claro */
.tema-claro .entity:not(.expanded) {
    background: #ffffff; 
    border-color: rgba(0, 0, 0, 0.15); 
    box-shadow: 0 4px 10px rgba(0,0,0,0.05); 
}

.tema-claro .expanded {
    background: rgba(255, 255, 255, 0.85); border: 2px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15) !important;
}

/* ==========================================================================
   LEGENDA E PALETA DE CORES
   ========================================================================== */
.legenda-area { text-align: center; outline: none; font-size: 13px; margin-top: 5px; color: #e2e8f0; user-select: text; -webkit-user-select: text; cursor: text; min-height: 18px; word-wrap: break-word; }
.legenda-area:empty::before { content: "Adicionar legenda..."; color: rgba(255,255,255,0.3); pointer-events: none; }
.entity:not(.expanded) .legenda-area:empty { display: none; }
.tema-claro .legenda-area { color: #1e293b !important; }

#paleta-fundo {
    /* 1. Tiramos a paleta da "caixa" da barra e fixamos direto na tela */
    position: fixed; 
    
    /* 2. Colocamos logo abaixo da barra superior (que tem 48px) */
    top: 55px;       
    
    /* 3. Alinhamos no cantinho direito, respeitando os 15px de margem atuais */
    right: 15px;     
    
    /* 4. Garantimos que ela passe por cima do Sidebar e de qualquer modal! */
    z-index: 4000;   
    
    /* Daqui para baixo, mantemos SEUS estilos originais intocados! */
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px); 
    -webkit-backdrop-filter: blur(10px); 
    padding: 12px;
    border-radius: 12px; 
    border: 1px solid rgba(0, 255, 204, 0.3); 
    display: none; 
    gap: 10px; 
    flex-wrap: wrap; 
    width: 145px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.8); 
    cursor: default;
}

#paleta-fundo.mostrar { display: flex; }
.swatch { width: 28px; height: 28px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255,255,255,0.1); transition: transform 0.2s, border-color 0.2s; box-sizing: border-box; }
.swatch:hover { transform: scale(1.15); border-color: #00ffcc; }
.custom-color-btn { display: flex; align-items: center; justify-content: center; background: #334155; font-size: 14px; border: 1px dashed rgba(255,255,255,0.4); }

/* ==========================================================================
   ANIMAÇÃO E MODO APRESENTAÇÃO
   ========================================================================== */
@keyframes flutuar { 0%, 100% { translate: 0 0; } 50% { translate: 0 -8px; } }
.selecionada-ativa { animation: flutuar 3s ease-in-out infinite; }

body.modo-apresentacao .top-bar,
body.modo-apresentacao #sidebar,
body.modo-apresentacao #version-btn, body.modo-apresentacao .tools { display: none !important; }

body.modo-apresentacao .content-area, body.modo-apresentacao .legenda-area { pointer-events: none !important; user-select: none; }

#btn-sair-apresentacao {
    display: none; position: fixed; top: 20px; right: 20px; z-index: 9999;
    background: rgba(255, 118, 117, 0.9); color: white; border: none; padding: 10px 20px;
    border-radius: 8px; font-weight: bold; cursor: pointer; box-shadow: 0 4px 15px rgba(0,0,0,0.5); backdrop-filter: blur(5px);
}
body.modo-apresentacao #btn-sair-apresentacao { display: block; }

/* ==========================================================================
   SCROLLBAR PADRÃO AKIZ
   ========================================================================== */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e293b; border-radius: 4px; }
::-webkit-scrollbar-thumb { background: #00ffcc; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #00cca3; }
.tema-claro ::-webkit-scrollbar-track { background: #e2e8f0; }
.tema-claro ::-webkit-scrollbar-thumb { background: #4a60ba; }

/* ==========================================================================
   OTIMIZAÇÃO RESPONSIVA (TABLETS E PC MENOR)
   ========================================================================== */
@media (max-width: 1024px) {
    #version-btn { bottom: 20px; left: 20px; background: rgba(0,0,0,0.85); }
    #footer-auteria { display: none; }
}

/* ==========================================================================
   OTIMIZAÇÃO EXTREMA MOBILE (SMARTPHONES EM PÉ OU DEITADOS)
   ========================================================================== */
@media (max-width: 768px) {
    
    /* LIPOASPIRAÇÃO DE TEXTOS PARA MOBILE: Foco nas ferramentas */
    .logo-ideias { display: none; } /* Oculta a palavra ".akiz" para ganhar espaço */
    #box-escala { display: none !important; } /* O zoom no celular é na pinça com os dedos */
    .actions-area .btn-pro-action:nth-child(3) { display: none; } /* Botão Apresentar */
    .fundo-container span { display: none; }

    /* Ajuste das margens para não ficar buracos na barra */
    .logo-area > div:nth-child(2) { margin-right: 5px !important; }
    .criacao-area { border-left: none !important; padding-left: 5px !important; }

    /* Bolhas levemente menores pro touch */
    .entity { transform: scale(0.9); }

    /* SIDEBAR CENTRALIZADA PARA TOQUE RÁPIDO */
    #sidebar { 
        position: fixed; top: 50% !important; left: 50%; transform: translate(-50%, -50%); 
        width: 85%; max-width: 320px; padding: 20px; z-index: 3500; box-shadow: 0 10px 50px rgba(0,0,0,0.9); 
    }

    /* MODAL DA IDEIA VIRA UM POP-UP CENTRALIZADO */
    .expanded {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: 92vw !important; 
        max-height: 80vh !important;
        margin: 0 !important;
        z-index: 9999 !important; 
    }

    .modal-box {
        width: 90vw;
        padding: 20px 15px;
    }
}