/* ======================================================
   IA — Histórico de conversas
   ====================================================== */

.ia-hist-head {
    display: flex; align-items: flex-start; justify-content: space-between;
    flex-wrap: wrap; gap: 16px; margin-bottom: 22px;
}
.ia-hist-head-text { min-width: 0; }
.ia-hist-title { font-size: 30px; letter-spacing: -.6px; margin-bottom: 6px; }
.ia-hist-lead { font-size: 14.5px; color: #64748B; margin: 0; }
/* Nota de escopo (tn_20): conversa de projeto não aparece nesta lista. */
.ia-hist-nota { font-size: 12.5px; color: #94A3B8; margin: 6px 0 0; }
.ia-hist-nota a { color: #2563EB; font-weight: 600; }
/* Aviso de LGPD do administrador — fixo e discreto (nunca toast: precisa estar
   visível toda vez). Âmbar para se distinguir da nota cinza acima. */
.ia-hist-aviso {
    display: inline-flex; align-items: center; gap: 7px;
    margin: 10px 0 0; padding: 7px 12px; border-radius: 10px;
    background: rgba(245,158,11,.10); border: 1px solid rgba(245,158,11,.28);
    font-size: 12.5px; font-weight: 600; color: #92400E;
}
.ia-hist-aviso i { font-size: 11px; opacity: .85; }

/* Segmented control de escopo */
.ia-hist-scope {
    display: flex; gap: 3px; padding: 4px; border-radius: 13px;
    background: rgba(15, 23, 42, .05); border: 1px solid rgba(15, 23, 42, .04);
}
.ia-hist-scope-btn {
    cursor: pointer; padding: 8px 14px; border-radius: 10px; border: none;
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
    font-size: 13px; font-weight: 600; font-family: var(--ia-font-ui);
    background: transparent; color: #64748B; transition: background .15s, color .15s, box-shadow .15s;
}
.ia-hist-scope-btn i { font-size: 11px; opacity: .75; }
.ia-hist-scope-btn:not(.ia-hist-scope-btn--disabled):hover { color: #334155; }
.ia-hist-scope-btn--active {
    background: #fff; color: #2563EB;
    box-shadow: 0 4px 12px -6px rgba(15, 23, 42, .35);
}
.ia-hist-scope-btn--active i { opacity: 1; }
.ia-hist-scope-btn--disabled { opacity: .5; cursor: not-allowed; }
.ia-hist-scope-soon {
    font-size: 9px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    padding: 2px 6px; border-radius: 999px; background: rgba(15, 23, 42, .08); color: #64748B;
}

/* ---------- Filtros ---------- */
.ia-hist-filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; align-items: center; }

.ia-hist-search { position: relative; flex: 1; min-width: 240px; }
.ia-hist-search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: #94A3B8; pointer-events: none; }
.ia-hist-search-input {
    width: 100%; height: 44px; padding: 0 38px 0 40px; border-radius: 13px;
    border: 1px solid var(--ia-border-2); background: rgba(255, 255, 255, .85);
    font-family: var(--ia-font-ui); font-size: 14px; outline: none; color: #0F172A;
    transition: border-color .15s, box-shadow .15s, background .15s;
}
.ia-hist-search-input::placeholder { color: #94A3B8; }
.ia-hist-search-input:focus { background: #fff; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.ia-hist-search-clear {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    width: 24px; height: 24px; padding: 0; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 7px; background: rgba(15, 23, 42, .06); color: #64748B; font-size: 10px;
    transition: background .15s, color .15s;
}
.ia-hist-search-clear:hover { background: rgba(15, 23, 42, .12); color: #0F172A; }

.ia-hist-select-wrap {
    position: relative; display: flex; align-items: center; gap: 8px;
    padding: 0 30px 0 13px; height: 44px; border-radius: 13px;
    border: 1px solid var(--ia-border-2); background: rgba(255, 255, 255, .85); color: #64748B;
    transition: border-color .15s, box-shadow .15s, background .15s, color .15s;
}
.ia-hist-select-wrap:hover { background: #fff; border-color: rgba(148, 163, 184, .55); }
.ia-hist-select-wrap:focus-within { background: #fff; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
/* Filtro ativo fica visível de longe (antes, "Todos os agentes" e um agente
   escolhido tinham exatamente a mesma aparência). */
.ia-hist-select-wrap--on {
    background: rgba(37, 99, 235, .07); border-color: rgba(37, 99, 235, .3); color: #1D4ED8;
}
.ia-hist-select {
    border: none; outline: none; background: transparent; padding: 0;
    font-family: var(--ia-font-ui); font-size: 13.5px; font-weight: 600; color: inherit; cursor: pointer;
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
}
.ia-hist-select-chevron { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; opacity: .8; }

.ia-hist-limpar {
    height: 44px; padding: 0 14px; cursor: pointer; border-radius: 13px;
    display: inline-flex; align-items: center; gap: 7px;
    border: 1px dashed rgba(148, 163, 184, .5); background: transparent;
    font-family: var(--ia-font-ui); font-size: 13px; font-weight: 600; color: #64748B;
    transition: background .15s, color .15s, border-color .15s;
}
.ia-hist-limpar i { font-size: 10px; }
.ia-hist-limpar:hover { background: rgba(220, 38, 38, .06); border-color: rgba(220, 38, 38, .35); color: #DC2626; }

.ia-hist-resumo { font-size: 12.5px; color: #94A3B8; margin: 0 2px 14px; }
.ia-hist-resumo strong { color: #475569; font-weight: 700; }

/* ---------- Grupos por período ---------- */
.ia-hist-grupos { display: flex; flex-direction: column; gap: 22px; }
.ia-hist-grupo-head { display: flex; align-items: center; gap: 10px; margin: 0 2px 9px; }
.ia-hist-grupo-titulo {
    font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #94A3B8;
}
.ia-hist-grupo-linha { flex: 1; height: 1px; background: linear-gradient(90deg, rgba(148, 163, 184, .3), rgba(148, 163, 184, 0)); }
.ia-hist-grupo-qtd {
    font-size: 10.5px; font-weight: 700; color: #64748B;
    padding: 2px 8px; border-radius: 999px; background: rgba(15, 23, 42, .05);
}

/* ---------- Lista ---------- */
.ia-hist-list {
    border-radius: 18px; border: 1px solid var(--ia-border);
    background: rgba(255, 255, 255, .7);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    overflow: hidden; box-shadow: 0 10px 30px -20px rgba(15, 23, 42, .25);
}
.ia-hist-row {
    position: relative; width: 100%; text-align: left; cursor: pointer;
    display: flex; align-items: center; gap: 14px; padding: 14px 18px;
    background: none; border: none; border-bottom: 1px solid rgba(15, 23, 42, .05);
    transition: background .15s;
}
.ia-hist-row:last-child { border-bottom: none; }
.ia-hist-row:hover { background: rgba(37, 99, 235, .045); }
/* Faixa na cor do agente ao passar o mouse — dá identidade sem poluir. */
.ia-hist-row::before {
    content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
    border-radius: 0 3px 3px 0; background: var(--ia-row-cor, #2563EB);
    opacity: 0; transition: opacity .15s;
}
.ia-hist-row:hover::before { opacity: .55; }

.ia-hist-row-avwrap {
    flex-shrink: 0; width: 46px; height: 46px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
}
.ia-hist-row-av { width: 38px; height: 38px; border-radius: 11px; }

.ia-hist-row-body { flex: 1; min-width: 0; }
.ia-hist-row-head { display: flex; align-items: center; gap: 8px; }
.ia-hist-row-title {
    font-family: var(--ia-font-display); font-size: 14.5px; font-weight: 700; color: #0F172A;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ia-hist-row-pill { flex-shrink: 0; font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.ia-hist-row-snippet {
    display: block; font-size: 12.5px; color: #64748B; margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 560px;
}
.ia-hist-row-snippet--vazio { color: #CBD5E1; font-style: italic; }
/* Autor da conversa (só admin) — abaixo do trecho, discreto. */
.ia-hist-row-autor {
    display: inline-flex; align-items: center; gap: 5px; margin-top: 3px;
    font-size: 11.5px; font-weight: 600; color: #64748B;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.ia-hist-row-autor i { font-size: 9.5px; color: #94A3B8; }

.ia-hist-row-meta { text-align: right; flex-shrink: 0; line-height: 1.3; }
.ia-hist-row-date { display: block; font-size: 12.5px; font-weight: 700; color: #475569; }
.ia-hist-row-hora { display: block; font-size: 11px; color: #94A3B8; }

/* "Abrir ›" substitui o chevron solto: só aparece no hover (desktop), então a
   linha em repouso fica limpa e a ação fica explícita quando importa. */
.ia-hist-row-abrir {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 10px; border-radius: 9px;
    background: rgba(37, 99, 235, .1); color: #2563EB;
    font-size: 12px; font-weight: 700;
    opacity: 0; transform: translateX(-4px);
    transition: opacity .15s, transform .15s;
}
.ia-hist-row:hover .ia-hist-row-abrir { opacity: 1; transform: translateX(0); }

/* ---------- Esqueleto de carregamento ---------- */
.ia-hist-skel-row {
    display: flex; align-items: center; gap: 14px; padding: 14px 18px;
    border-bottom: 1px solid rgba(15, 23, 42, .05);
}
.ia-hist-skel-row:last-child { border-bottom: none; }
.ia-hist-skel-av, .ia-hist-skel-linha, .ia-hist-skel-meta {
    display: block; border-radius: 8px;
    background: linear-gradient(90deg, #EEF2F7 25%, #F8FAFC 37%, #EEF2F7 63%);
    background-size: 400% 100%; animation: ia-hist-shimmer 1.4s ease infinite;
}
.ia-hist-skel-av { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; }
.ia-hist-skel-body { flex: 1; min-width: 0; }
.ia-hist-skel-linha--t { width: 42%; height: 12px; }
.ia-hist-skel-linha--s { width: 68%; height: 10px; margin-top: 8px; }
.ia-hist-skel-meta { width: 46px; height: 12px; flex-shrink: 0; }
@keyframes ia-hist-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Vazio ---------- */
.ia-hist-empty {
    text-align: center; padding: 54px 20px;
    border-radius: 18px; border: 1px dashed rgba(148, 163, 184, .4);
    background: rgba(255, 255, 255, .5);
}
.ia-hist-empty-ico {
    width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(37, 99, 235, .08); color: #2563EB; font-size: 22px;
}
.ia-hist-empty-titulo { margin: 0 0 5px; font-size: 15px; font-weight: 700; color: #334155; }
.ia-hist-empty-txt { margin: 0; font-size: 13px; color: #94A3B8; }
.ia-hist-empty-btn {
    display: inline-flex; align-items: center; margin-top: 16px; cursor: pointer;
    padding: 9px 18px; border-radius: 11px; border: none;
    background: var(--ia-grad, linear-gradient(135deg, #2563EB, #1D4ED8)); color: #fff;
    font-family: var(--ia-font-ui); font-size: 13px; font-weight: 700; text-decoration: none;
    box-shadow: 0 10px 22px -12px rgba(37, 99, 235, .8); transition: filter .15s;
}
.ia-hist-empty-btn:hover { filter: brightness(1.07); color: #fff; text-decoration: none; }

@media (max-width: 575.98px) {
    .ia-hist-title { font-size: 24px; }
    .ia-hist-row { padding: 13px 14px; gap: 11px; }
    .ia-hist-row-snippet { max-width: 180px; }
    .ia-hist-scope { width: 100%; }
    .ia-hist-scope-btn { flex: 1; justify-content: center; }
    .ia-hist-scope-soon { display: none; }
    .ia-hist-select-wrap { flex: 1; }
    /* Sem hover no toque: a ação fica sempre visível, só que compacta. */
    .ia-hist-row-abrir { opacity: 1; transform: none; padding: 6px; font-size: 0; gap: 0; }
}
