/* css2/historico.css
   Tela "Chat / Histórico" — painel único de entrada no chat da Ayla.
   Antes era um drawer lateral só de listagem; agora é a própria tela
   cheia (estilo app) que decide qual conversa abre no Studio/cpu.js. */

.historico-overlay-bg {
    /* A tela deixou de ser um modal sobre o chat — ela É a tela.
       Mantido oculto só para não quebrar as chamadas antigas de
       add/remove 'active' feitas por historico.js. */
    display: none !important;
}

.historico-drawer {
    position: fixed;
    inset: 0;
    background: #050b06;
    background-image: radial-gradient(circle at 50% 0%, rgba(0,255,150,0.06), transparent 60%);
    z-index: 9999;
    display: none;
    flex-direction: column;
    font-family: 'Inter', sans-serif;
    color: #e6ffe9;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.22s ease, transform 0.22s ease;
}
.historico-drawer.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.historico-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 14px 10px;
    border-bottom: 1px solid rgba(0, 255, 150, 0.15);
}
.historico-header .historico-voltar {
    background: none;
    border: none;
    color: var(--neon-green);
    font-size: 0.95rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.historico-header .historico-titulo-drawer {
    display: none; /* título já fica implícito no botão "Voltar ao Painel" */
}

.historico-busca {
    padding: 10px 14px;
}
.historico-busca input {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(0, 255, 150, 0.25);
    background: rgba(255, 255, 255, 0.04);
    color: #e6ffe9;
    font-size: 0.9rem;
    outline: none;
}
.historico-busca input:focus {
    border-color: var(--neon-green);
    box-shadow: 0 0 8px rgba(0, 255, 150, 0.25);
}

.historico-lista {
    flex: 1;
    overflow-y: auto;
    padding: 6px 12px 100px;
}

.historico-grupo-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: rgba(230, 255, 233, 0.5);
    padding: 14px 4px 8px;
}

/* ---------------------------------------------------------
   Cartão de conversa (avatar + título/hora + preview + contagem)
   --------------------------------------------------------- */
.historico-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 10px;
    border-radius: 14px;
    background: rgba(0, 255, 150, 0.045);
    border: 1px solid rgba(0, 255, 150, 0.12);
    margin-bottom: 8px;
    cursor: pointer;
    position: relative;
    transition: background 0.12s ease;
}
.historico-item:active { background: rgba(0, 255, 150, 0.09); }
.historico-item.ativa { background: rgba(0, 255, 150, 0.16); border-color: rgba(0,255,150,0.35); }

.historico-item-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 255, 150, 0.12);
    border: 1px solid rgba(0, 255, 150, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.historico-item-corpo {
    flex: 1;
    min-width: 0;
}
.historico-item-linha-topo {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.historico-item-titulo {
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    outline: none;
}
.historico-item-titulo[contenteditable="true"] {
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    padding: 0 4px;
}
.historico-item-hora {
    font-size: 0.68rem;
    color: rgba(230, 255, 233, 0.5);
    flex-shrink: 0;
    white-space: nowrap;
}
.historico-item-preview {
    font-size: 0.78rem;
    color: rgba(230, 255, 233, 0.55);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 3px;
}

.historico-item-contagem {
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: var(--neon-green);
    color: #032b17;
    font-size: 0.68rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
    margin-top: 2px;
}

.historico-item-menu-btn {
    background: none;
    border: none;
    color: rgba(230, 255, 233, 0.55);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0 2px;
    flex-shrink: 0;
    line-height: 1;
}
.historico-item-menu-btn:hover { color: var(--neon-green); }

/* Popover de ações (favoritar, renomear, copiar, exportar, compartilhar, excluir) */
.historico-item-acoes-popover {
    position: absolute;
    right: 8px;
    top: 42px;
    background: #0a140d;
    border: 1px solid rgba(0, 255, 150, 0.25);
    border-radius: 12px;
    padding: 6px;
    z-index: 20;
    display: none;
    flex-direction: column;
    min-width: 210px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}
.historico-item-acoes-popover.aberto { display: flex; }
.historico-item-acoes-popover button {
    background: none;
    border: none;
    color: #e6ffe9;
    text-align: left;
    padding: 9px 10px;
    border-radius: 8px;
    font-size: 0.82rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.historico-item-acoes-popover button:hover { background: rgba(0, 255, 150, 0.1); }
.historico-item-acoes-popover button.perigo { color: #ff8a8a; }
.historico-item-acoes-popover button.perigo:hover { background: rgba(255, 59, 59, 0.12); }

.historico-lista-vazia,
.historico-lista-carregando {
    text-align: center;
    font-size: 0.8rem;
    color: rgba(230, 255, 233, 0.5);
    padding: 24px 10px;
}

/* ---------------------------------------------------------
   Rodapé — consumo de espaço / plano
   --------------------------------------------------------- */
.historico-footer {
    padding: 12px 14px 16px;
    border-top: 1px solid rgba(0, 255, 150, 0.15);
    background: #050b06;
}
.historico-barra {
    width: 100%;
    height: 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
    margin-bottom: 6px;
}
.historico-barra-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--neon-green), #00e5ff);
    transition: width 0.3s ease;
}
.historico-barra-fill.critico {
    background: linear-gradient(90deg, #ff9f43, #ff3b3b);
}
.historico-consumo-texto {
    font-size: 0.78rem;
    color: rgba(230, 255, 233, 0.75);
}
.historico-plano-label {
    font-size: 0.72rem;
    color: rgba(230, 255, 233, 0.45);
    margin-top: 2px;
}

/* ---------------------------------------------------------
   Botão flutuante "Nova Conversa" (canto inferior direito)
   --------------------------------------------------------- */
.historico-fab-nova {
    position: fixed;
    right: 18px;
    bottom: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 10000;
}
.historico-fab-icone {
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: var(--neon-green);
    color: #032b17;
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 25px rgba(0, 255, 150, 0.55);
    transition: transform 0.15s ease;
}
.historico-fab-nova:active .historico-fab-icone { transform: scale(0.94); }
.historico-fab-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.4px;
    line-height: 1.15;
    color: var(--neon-green);
    text-align: center;
    text-shadow: 0 0 6px rgba(0, 255, 150, 0.5);
}

/* Aviso de limite atingido */
.historico-aviso-limite {
    margin: 8px 14px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 59, 59, 0.1);
    border: 1px solid rgba(255, 59, 59, 0.35);
    color: #ffb3b3;
    font-size: 0.78rem;
    line-height: 1.4;
}

/* Sugestão automática de novo assunto (banner inline no chat) */
.historico-sugestao-assunto {
    position: fixed;
    left: 50%;
    bottom: 110px;
    transform: translateX(-50%);
    background: rgba(10, 14, 10, 0.95);
    border: 1px solid rgba(0, 255, 150, 0.35);
    border-radius: 14px;
    padding: 12px 16px;
    max-width: min(360px, 90vw);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 9997;
    font-family: 'Inter', sans-serif;
    color: #e6ffe9;
    font-size: 0.85rem;
    text-align: center;
}
.historico-sugestao-assunto .historico-sugestao-botoes {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    justify-content: center;
}
.historico-sugestao-assunto button {
    flex: 1;
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 150, 0.3);
    background: rgba(0, 255, 150, 0.08);
    color: var(--neon-green);
    font-size: 0.78rem;
    cursor: pointer;
}
.historico-sugestao-assunto button.secundario {
    background: none;
    color: rgba(230, 255, 233, 0.7);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Scroll da lista discreto */
.historico-lista::-webkit-scrollbar { width: 5px; }
.historico-lista::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 150, 0.25);
    border-radius: 4px;
}
