/* ==========================================================================
   CONFIGURAÇÕES GERAIS E RESETS
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box; /* Garante que padding não quebre o tamanho do elemento */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body, html {
    height: 100vh;
    background-color: #f5f7fb;
    color: #333;
    overflow: hidden; /* Evita rolagem na página inteira */
    display: flex;
    flex-direction: column;
}

/* O esqueleto principal: Divide a tela em 4 colunas (a 3ª é a alça de
   redimensionamento da coluna direita). Largura da direita fica numa
   variável (--workspace-width) pra poder ser ajustada dinamicamente
   arrastando, sem precisar reescrever a lista inteira em JS. */
#app-container {
    display: grid;
    grid-template-columns: 280px 1fr 6px var(--workspace-width, 320px);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    transition: grid-template-columns 0.25s ease;
}

/* Colunas laterais colapsáveis (abertas/fechadas por demanda do usuário) */
#app-container.sidebar-collapsed {
    grid-template-columns: 0px 1fr 6px var(--workspace-width, 320px);
}
#app-container.workspace-collapsed {
    grid-template-columns: 280px 1fr 0px 0px;
}
#app-container.sidebar-collapsed.workspace-collapsed {
    grid-template-columns: 0px 1fr 0px 0px;
}

#app-container.sidebar-collapsed #sidebar {
    padding: 0;
    border-right: none;
    opacity: 0;
    pointer-events: none;
}
#app-container.workspace-collapsed #workspace-area {
    padding: 0;
    border-left: none;
    opacity: 0;
    pointer-events: none;
}

/* Alça de redimensionamento da coluna direita (arrastar = ajuste livre de
   largura, fora dos modos fixos já cobertos pelo botão de colapsar) */
.resize-handle {
    cursor: col-resize;
    background: transparent;
    position: relative;
}
.resize-handle::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 36px;
    border-radius: 2px;
    background: #cbd5e1;
}
.resize-handle:hover,
.resize-handle.arrastando {
    background: rgba(79, 70, 229, 0.15);
}
.resize-handle:hover::after,
.resize-handle.arrastando::after {
    background: #4f46e5;
}
#app-container.workspace-collapsed .resize-handle {
    pointer-events: none;
    opacity: 0;
}

/* ==========================================================================
   SEÇÕES COLAPSÁVEIS (sidebar e área de arquivos) -- clique no título
   recolhe/expande o conteúdo abaixo, sem precisar mexer em nenhum outro
   elemento; estado persiste em localStorage por seção.
   ========================================================================== */
.secao-colapsavel > h3,
.secao-colapsavel > .painel-custos-titulo {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.secao-colapsavel > h3::after,
.secao-colapsavel > .painel-custos-titulo::after {
    content: "▾";
    font-size: 0.65rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 6px;
}
.secao-colapsavel.recolhida > h3::after,
.secao-colapsavel.recolhida > .painel-custos-titulo::after {
    transform: rotate(-90deg);
}
/* #total-cost fica de fora do recolhimento -- na seção "Custo da Sessão",
   o total sempre visível é o pedido explícito, só o detalhamento
   (Comparativo de Custos, aninhado dentro dessa mesma seção) recolhe. */
.secao-colapsavel.recolhida > *:not(h3):not(.painel-custos-titulo):not(#total-cost) {
    display: none !important;
}

/* ==========================================================================
   1. ESTILIZAÇÃO DO PAINEL LATERAL (SIDEBAR)
   ========================================================================== */
#sidebar {
    background-color: #1e1e2f; /* Azul escuro corporativo */
    color: #fff;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2d2d44;
    padding: 20px;
    flex-shrink: 0;
    height: 100%;
    max-height: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    transition: padding 0.2s ease, opacity 0.2s ease;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    margin-bottom: 25px;
    color: #4f46e5; /* Roxo vibrante para destaque */
}

.sidebar-section {
    margin-bottom: 30px;
    flex-grow: 1; /* Faz as seções preencherem o espaço do meio */
}

.sidebar-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #8a8aa3;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
}

/* Inputs de chaves */
.input-group {
    margin-bottom: 12px;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 4px;
    color: #c1c1d6;
}

.input-group input {
    width: 100%;
    padding: 8px;
    background-color: #2d2d44;
    border: 1px solid #444466;
    border-radius: 4px;
    color: #fff;
    font-size: 0.85rem;
}

/* Rodapé do custo acumulado */
.sidebar-footer {
    border-top: 1px solid #2d2d44;
    padding-top: 15px;
}

#total-cost {
    font-size: 1.4rem;
    font-weight: bold;
    color: #10b981; /* Verde moeda */
    margin-top: 5px;
}

/* ==========================================================================
   2. ESTILIZAÇÃO DO CHAT PRINCIPAL (CENTRO)
   ========================================================================== */
#chat-area {
    display: flex;
    flex-direction: column;
    background-color: #ffffff;
    height: 100%;
    min-width: 0;
    max-height: 100%;
    flex: 1;
    overflow: hidden;
}

/* Topo do Chat -- `flex-wrap` é essencial aqui: sem ele, com `#chat-area`
   tendo `overflow: hidden`, qualquer conteúdo que não caiba na largura
   disponível (ex.: coluna direita bem larga + seletor de imagem do Gemini
   visível) fica cortado silenciosamente na borda com `#workspace-area`, em
   vez de simplesmente descer pra uma segunda linha -- bug real achado em
   2026-07-22 (botão "🔊 Ler Seleção" quase invisível, cortado bem na borda). */
#chat-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
    background-color: #fafafa;
    flex-shrink: 0;
}

.btn-toggle-painel {
    background: none;
    border: 1px solid #ccc;
    border-radius: 6px;
    width: 34px;
    height: 34px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s;
}
.btn-toggle-painel:hover {
    background-color: #eef2f7;
}
.btn-toggle-painel:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}
.btn-toggle-painel:disabled:hover {
    background-color: transparent;
}
/* Cresce pra caber "⏳ Carregando..."/"▰▰▰ Parar" durante a reprodução --
   os outros botões do topo (☰/🗂️) ficam fixos em 34px porque só têm 1 emoji. */
#btn-ler-selecao {
    width: auto;
    min-width: 34px;
    padding: 0 8px;
    white-space: nowrap;
}
#btn-toggle-workspace {
    margin-left: auto;
}

#chat-header select {
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #ccc;
    font-size: 0.9rem;
}

/* Container de Mensagens (Rolagem automática) */
#messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#messages-container * {
    max-width: 100%;
    word-break: break-word;
    overflow-wrap: break-word;
}

pre[class*="language-"] {
    margin: 8px 0;
    border-radius: 8px;
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    max-width: 100%;
    overflow-x: auto;
}

code[class*="language-"] {
    font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
}

/* Estrutura das Bolhas de Mensagem */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message.user {
    align-self: flex-end; /* Alinha o usuário à direita */
}

.message.assistant {
    align-self: flex-start; /* Alinha a IA à esquerda */
}

.message-meta {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.98rem;
    line-height: 1.5;
}

.message.user .message-bubble {
    background-color: #007acc;
    color: #fff;
    border-bottom-right-radius: 2px;
}

.message.assistant .message-bubble {
    background-color: #f0f2f5;
    color: #222;
    border-bottom-left-radius: 2px;
}

.fonte-link {
    font-size: 0.78rem;
    color: #5a7ca8;
    text-decoration: none;
    border-bottom: 1px dotted #5a7ca8;
    white-space: nowrap;
}

.fonte-link:hover {
    color: #3d5f85;
    border-bottom-style: solid;
}

.message-cost {
    font-size: 0.75rem;
    color: #999;
    margin-top: 4px;
}

.message-fontes {
    font-size: 0.75rem;
    color: #888;
    margin-top: 4px;
    line-height: 1.4;
}

.message-fontes a {
    color: #7aa2ff;
    text-decoration: none;
}

.message-fontes a:hover {
    text-decoration: underline;
}

/* Player de áudio da IA */
.audio-player-container {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #d1d5db;
    display: flex;
    align-items: center;
    gap: 10px;
}

.audio-player-container audio {
    height: 30px;
}

/* Rodapé de entrada de texto */
#chat-footer {
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    background-color: #fff;
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
    padding: 12px 20px;
    margin-bottom: 8px;
    background: #ffffff;
    z-index: 10;
}

#user-input {
    flex-grow: 1;
    min-height: 50px;
    max-height: 200px;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    resize: none;
    overflow-y: auto;
    font-size: 0.95rem;
    transition: height 0.1s ease;
}

#btn-send {
    height: 50px;
    padding: 0 20px;
    background-color: #007acc;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: background 0.2s;
    flex-shrink: 0;
}

#btn-send:hover {
    background-color: #005999;
}

#btn-mic {
    height: 50px;
    width: 50px;
    padding: 0;
    background-color: #f1f3f5;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
}

#btn-mic:hover {
    background-color: #e5e7eb;
}

#btn-mic:disabled {
    opacity: 0.6;
    cursor: wait;
}

#btn-mic.gravando-audio {
    background-color: #e74c3c;
    border-color: #c0392b;
    color: #fff;
    animation: pulsar-gravacao 1.2s infinite;
}

@keyframes pulsar-gravacao {
    0%, 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
}

/* ==========================================================================
   3. ÁREA DE ARQUIVOS / WORKSPACE (DIREITA)
   ========================================================================== */
#workspace-area {
    background-color: #f8fafc;
    border-left: 1px solid #e5e7eb;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    min-width: 0;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    transition: padding 0.2s ease, opacity 0.2s ease;
}

.workspace-header h2 {
    font-size: 1.1rem;
    color: #334155;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

/* Zona de Arrastar Arquivos (Drag and Drop) */
#drop-zone {
    border: 2px dashed #cbd5e1;
    background-color: #fff;
    border-radius: 8px;
    padding: 30px 15px;
    text-align: center;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

#drop-zone:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

#drop-zone p {
    font-size: 0.9rem;
    font-weight: 600;
    color: #475569;
}

#drop-zone span {
    font-size: 0.75rem;
    color: #94a3b8;
    display: block;
    margin-top: 5px;
}

.workspace-section h3 {
    font-size: 0.85rem;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 10px;
}

#files-container {
    margin-top: 12px;
    max-height: 120px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-right: 4px;
}

/* Botões utilitários */
.btn-secondary {
    width: 100%;
    padding: 10px;
    background-color: #fff;
    border: 1px solid #cbd5e1;
    color: #475569;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: #f1f5f9;
    border-color: #94a3b8;
}

/* Switch simples para o botão de busca na Web */
.switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 20px;
}

.switch input { display: none; }

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px; width: 14px;
    left: 3px; bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider { background-color: #10b981; }
input:checked + .slider:before { transform: translateX(14px); }

/* ==========================================================================
   4. COMPONENTES INJETADOS DINAMICAMENTE PELO APP.JS
   (painel de custos, sessões, imagens geradas, turnos seletivos, voz)
   ========================================================================== */

/* Painel Comparativo de Custos */
.painel-custos {
    background: rgba(248, 249, 250, 0.95);
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    margin: 8px 0;
}
.painel-custos-titulo {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #2d3748;
}
.painel-custos-stats {
    font-size: 0.72rem;
    color: #718096;
    margin-bottom: 10px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 6px;
}
.painel-custos-linha {
    margin-bottom: 8px;
}
.painel-custos-linha:last-child {
    margin-bottom: 0;
}
.painel-custos-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    margin-bottom: 3px;
}
.painel-custos-provedor {
    font-weight: 500;
    display: flex;
    align-items: center;
    color: #2d3748;
}
.painel-custos-valor {
    font-family: monospace;
    font-weight: 600;
    color: #1a202c;
}
.painel-custos-barra-bg {
    height: 6px;
    background: #edf2f7;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}
.painel-custos-barra-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease-out;
}
.bg-openai { background: #10a37f; }
.bg-claude { background: #d97706; }
.bg-gemini { background: #2563eb; }

.badge-ativo {
    background: #e2e8f0;
    color: #4a5568;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 600;
}
.badge-barato {
    background: #c6f6d5;
    color: #22543d;
    font-size: 0.6rem;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 6px;
    font-weight: 600;
}

/* Bolha de imagem gerada/anexada */
.image-bubble-container {
    margin: 12px 0;
    display: block;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #cbd5e0;
    background: #111111;
    max-width: 480px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.chat-generated-image {
    width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
}
.chat-generated-image.pending-local-img {
    opacity: 0.5;
    background: rgba(255, 255, 255, 0.05);
    min-height: 220px;
}
.image-actions {
    display: flex;
    align-items: center;
    background: rgba(20, 20, 20, 0.95);
    padding: 8px 12px;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.image-storage-hint {
    font-size: 0.65rem;
    color: rgba(255, 255, 255, 0.45);
    cursor: default;
    white-space: nowrap;
}
.image-actions-botoes {
    display: flex;
    gap: 12px;
}
.btn-img-action {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 0.75rem;
    cursor: pointer;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s ease;
}
.btn-img-action:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Turnos inativos (excluídos do contexto enviado à IA) */
.message.inativo {
    opacity: 0.38;
    filter: grayscale(65%);
    border-left: 3px dashed #cbd5e0;
    background: rgba(226, 232, 240, 0.15);
    transition: all 0.25s ease-in-out;
}

.message-meta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 6px;
}

.btn-toggle-turno {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.08);
    color: #4a5568;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    width: auto;
}
.btn-toggle-turno:hover {
    background: rgba(0, 0, 0, 0.12);
    transform: scale(1.02);
}
.message.user .btn-toggle-turno {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
}
.message.user .btn-toggle-turno:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Lista de conversas na barra lateral */
.conversas-sidebar-container h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #8a8aa3;
    letter-spacing: 0.5px;
    margin: 0;
}
.conversas-sidebar-container {
    border-bottom: 1px solid #2d2d44;
    padding-bottom: 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.btn-nova-conversa {
    background: #2563eb;
    color: #ffffff;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s ease;
    width: 100%;
}
.btn-nova-conversa:hover {
    background: #1d4ed8;
}
/* Medidor de economia (versão "fina", fora do <option> -- dentro do
   dropdown nativo o navegador só aceita texto puro, então lá usamos emoji de
   quadrado colorido; aqui, sendo elementos normais de DOM, dá pra ter cantos
   arredondados e borda fina de verdade). Reflete o modelo ATUALMENTE
   selecionado. Pedido do usuário em 2026-07-22. */
.badge-economia {
    display: inline-flex;
    gap: 3px;
    margin-left: 8px;
    vertical-align: middle;
}
.badge-economia .quadrado-economia {
    width: 7px;
    height: 7px;
    border-radius: 2px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.08);
}
.badge-economia .quadrado-economia.tier-1 { background: #ef4444; border-color: #dc2626; }
.badge-economia .quadrado-economia.tier-2 { background: #f97316; border-color: #ea580c; }
.badge-economia .quadrado-economia.tier-3 { background: #eab308; border-color: #ca8a04; }
.badge-economia .quadrado-economia.tier-4 { background: #22c55e; border-color: #16a34a; }

.linha-acoes-backup {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}
.btn-acao-backup {
    flex: 1;
    background: #2d2d44;
    color: #d8d8f0;
    border: 1px solid #444466;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}
.btn-acao-backup:hover {
    background: #3a3a58;
}
.input-busca-conversas {
    width: 100%;
    padding: 7px 10px;
    margin-top: 8px;
    background-color: #2d2d44;
    border: 1px solid #444466;
    border-radius: 4px;
    color: #fff;
    font-size: 0.78rem;
}
.input-busca-conversas::placeholder {
    color: #8a8aa3;
}
.busca-conversas-vazio {
    font-size: 0.75rem;
    color: #8a8aa3;
    text-align: center;
    padding: 12px 4px;
}

.lista-conversas {
    max-height: 200px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-right: 4px;
    margin-top: 8px;
}
.item-conversa {
    display: flex;
    flex-direction: column;
    padding: 8px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.78rem;
    transition: all 0.2s ease;
}
.linha-item-conversa {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.trecho-busca-conversa {
    margin-top: 4px;
    font-size: 0.68rem;
    color: #8a8aa3;
    font-style: italic;
    line-height: 1.4;
    overflow-wrap: break-word;
}
.item-conversa:hover {
    background: rgba(255, 255, 255, 0.08);
}
.item-conversa.ativa {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.4);
    font-weight: 600;
}
.titulo-conversa {
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    flex: 1;
    padding-right: 8px;
    color: #ffffff;
    text-align: left;
}
.acoes-conversa {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.btn-baixar-conversa,
.btn-duplicar-conversa,
.btn-renomear-conversa,
.btn-limpar-conversa,
.btn-deletar-conversa {
    background: none;
    border: none;
    color: #8a8aa3;
    cursor: pointer;
    padding: 2px;
    font-size: 0.85rem;
    transition: color 0.2s ease;
}
.btn-baixar-conversa:hover {
    color: #60a5fa;
}
.btn-duplicar-conversa:hover {
    color: #34d399;
}
.btn-renomear-conversa:hover {
    color: #60a5fa;
}
.btn-limpar-conversa:hover {
    color: #f0b429;
}
.input-renomear-conversa {
    flex: 1;
    min-width: 0;
    margin-right: 8px;
    background: #2d2d44;
    border: 1px solid #4f46e5;
    border-radius: 4px;
    color: #ffffff;
    font-size: 0.78rem;
    padding: 3px 6px;
}
.btn-deletar-conversa:hover {
    color: #e53e3e;
}

/* Voz tocando - animação de equalização (qualquer botão de play/pause de
   áudio -- Ouvir Resposta, Ler Arquivo, Ler Seleção) */
.btn-audio-toggle.audio-ativo {
    background: #2563eb;
    color: white;
    animation: pulse-audio 1.4s infinite ease-in-out;
}
@keyframes pulse-audio {
    0%, 100% { opacity: 0.85; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
}

/* Indicador de espera (spinner + sinônimo de "economizando") -- discreto de
   propósito: só um leve itálico/opacidade, sem chamar atenção do resto da
   tela. Usado tanto na bolha "pensando" do chat quanto em botões (Enviar
   Lote, TTS). */
.indicador-espera-ativo {
    font-style: italic;
    opacity: 0.8;
}

/* ==========================================================================
   5. QUADRO DE FERRAMENTAS EXTERNAS GRATUITAS
   ========================================================================== */

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.btn-icone-sidebar {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid #2d2d44;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    margin-bottom: 25px; /* alinha com a margem do h2 ao lado */
    transition: background 0.2s ease;
}
.btn-icone-sidebar:hover {
    background: rgba(255, 255, 255, 0.14);
}

.modal-ferramentas-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-ferramentas-card {
    background: #ffffff;
    border-radius: 12px;
    width: 90%;
    max-width: 640px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.15), 0 10px 10px -5px rgba(0,0,0,0.06);
}

.modal-ferramentas-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.modal-ferramentas-header h3 {
    font-size: 1.05rem;
    color: #1e293b;
}
.btn-fechar-modal-ferramentas {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #64748b;
    line-height: 1;
    padding: 4px;
}
.btn-fechar-modal-ferramentas:hover {
    color: #1e293b;
}

.modal-ferramentas-corpo {
    padding: 18px 22px 22px;
    overflow-y: auto;
}

.ferramentas-carregando,
.ferramentas-erro {
    font-size: 0.85rem;
    color: #64748b;
    text-align: center;
    padding: 20px 0;
}

.aviso-utilidade-publica {
    font-size: 0.78rem;
    line-height: 1.5;
    color: #475569;
    background: #f0f5ff;
    border: 1px solid #dbe6ff;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.ferramentas-atualizado-em {
    font-size: 0.68rem;
    color: #94a3b8;
    margin-bottom: 16px;
}

.secao-categoria-ferramentas {
    margin-bottom: 18px;
}
.secao-categoria-ferramentas:last-child {
    margin-bottom: 0;
}
.secao-categoria-ferramentas h4 {
    font-size: 0.85rem;
    color: #334155;
    margin-bottom: 8px;
}

.grid-ferramentas-gratuitas {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.card-ferramenta-gratuita {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 12px;
    background: #f8fafc;
}

.card-ferramenta-nome {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4f46e5;
    text-decoration: none;
}
.card-ferramenta-nome:hover {
    text-decoration: underline;
}

.card-ferramenta-limite {
    font-size: 0.74rem;
    color: #64748b;
    margin-top: 4px;
    line-height: 1.4;
}

/* ==========================================================================
   6. AÇÃO SOBRE IMAGEM ANEXADA (Analisar vs Editar)
   ========================================================================== */

.btn-acao-imagem {
    flex: 1;
    font-size: 0.72rem;
    padding: 4px 6px;
    border-radius: 5px;
    border: 1px solid var(--border-color, #dcdde1);
    background: var(--bg-primary, #fff);
    color: var(--text-primary, #555);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-acao-imagem:hover {
    background: rgba(108, 92, 231, 0.08);
}

.btn-acao-imagem.ativo {
    background: #6c5ce7;
    border-color: #6c5ce7;
    color: #fff;
    font-weight: 600;
}

.legenda-modelo-edicao {
    font-size: 0.68rem;
    color: #6c5ce7;
    cursor: help;
}