/* ============================================================
   MineOS — Assistente (agente analítico tipo ChatGPT/Gemini)
   Respostas fundamentadas nos dados da mina: resumo conversacional
   + gráfico/tabela + fonte + perguntas de follow-up.
   Carregado em management-console-v2.html.
   ============================================================ */

/* ---------- barra "Pergunte" no topo do Painel ---------- */
.askbar {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid color-mix(in srgb, var(--accent) 32%, var(--border));
  border-radius: var(--r-md); padding: 12px 14px; margin-bottom: 16px;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 8%, transparent);
}
.askbar .ab-spark { width: 22px; height: 22px; color: var(--accent); flex: none; }
.askbar input {
  flex: 1; border: 0; outline: 0; background: none;
  font-family: var(--font-ui); font-size: 15px; color: var(--fg);
}
.askbar input::placeholder { color: var(--fg-lo); }
.askbar .ab-go {
  flex: none; display: inline-flex; align-items: center; gap: 7px;
  border: 0; border-radius: var(--r-sm); cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-family: var(--font-ui); font-weight: 700; font-size: 13px; padding: 9px 15px;
}
.askbar .ab-go:hover { background: var(--accent-deep); }
.ask-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin: -6px 0 18px; }
.ask-chip {
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 600;
  color: var(--fg-mid); background: var(--surface); cursor: pointer;
  border: 1px solid var(--border); border-radius: 999px; padding: 7px 13px;
}
.ask-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- tela do assistente ---------- */
.asst { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.asst-thread { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 24px; }
.asst-inner { max-width: 860px; margin: 0 auto; }

/* estado vazio / boas-vindas */
.asst-empty { max-width: 860px; margin: 0 auto; padding-top: 14px; }
.asst-hi { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.asst-hi .av {
  width: 46px; height: 46px; border-radius: 13px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.asst-hi .av svg { width: 26px; }
.asst-hi h2 { font-family: var(--font-display); font-weight: 800; font-size: 26px; letter-spacing: -.02em; margin: 0; }
.asst-hi .sub { font-family: var(--font-mono); font-size: 11px; letter-spacing: .04em; color: var(--fg-lo); margin-top: 3px; }
.asst-lede { color: var(--fg-mid); font-size: 15px; line-height: 1.55; max-width: 56ch; margin: 6px 0 26px; }
.asst-sg-h { font-family: var(--font-mono); font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--text-faint); margin-bottom: 12px; }
.asst-sg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.asst-sg-card {
  display: flex; align-items: flex-start; gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 15px 16px; cursor: pointer; transition: .15s var(--ease);
}
.asst-sg-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.asst-sg-card .ic { width: 30px; height: 30px; border-radius: 8px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--accent); }
.asst-sg-card .ic svg { width: 16px; }
.asst-sg-card .q { font-size: 14px; font-weight: 600; line-height: 1.4; }
.asst-sg-card .cat { font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; text-transform: uppercase; color: var(--fg-lo); margin-top: 4px; }

/* mensagens */
.asst-msg { margin-bottom: 22px; }
.asst-msg.user { display: flex; justify-content: flex-end; }
.asst-bubble {
  max-width: 76%; background: var(--accent); color: var(--accent-ink);
  border-radius: 16px 16px 4px 16px; padding: 11px 15px;
  font-size: 14.5px; font-weight: 600; line-height: 1.45;
}
.asst-row { display: flex; gap: 13px; align-items: flex-start; }
.asst-bot-av {
  width: 34px; height: 34px; border-radius: 10px; flex: none; margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent);
}
.asst-bot-av svg { width: 19px; }
.asst-answer { flex: 1; min-width: 0; }
.asst-lead { font-size: 15px; line-height: 1.6; color: var(--fg); margin: 4px 0 0; }
.asst-lead b { color: var(--fg); font-weight: 800; }
.asst-lead .hl { color: var(--accent); font-weight: 800; }

/* bloco de evidência (gráfico/tabela) */
.asst-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 18px; margin-top: 14px; overflow-x: auto;
}
.asst-card-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.asst-card-h .t { font-family: var(--font-display); font-weight: 700; font-size: 14px; }
.asst-card-h .s { font-family: var(--font-mono); font-size: 10px; letter-spacing: .04em; color: var(--fg-lo); margin-left: auto; }

/* barras horizontais */
.abar-list { display: flex; flex-direction: column; gap: 11px; }
.abar-row { display: flex; align-items: center; gap: 12px; }
.abar-l { width: 124px; flex: none; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abar-l .code { font-family: var(--font-mono); }
.abar-track { flex: 1; height: 18px; background: var(--surface-3); border-radius: 5px; overflow: hidden; }
.abar-track i { display: block; height: 100%; border-radius: 5px; transition: width .5s var(--ease); }
.abar-v { width: 72px; flex: none; text-align: right; font-family: var(--font-mono); font-size: 12.5px; font-weight: 700; }

/* mini barras verticais (tendência) */
.acol-wrap { display: flex; align-items: flex-end; gap: 10px; height: 130px; }
.acol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 7px; height: 100%; justify-content: flex-end; }
.acol .bar { width: 100%; max-width: 40px; background: var(--accent-soft); border-radius: 5px 5px 0 0; min-height: 5px; }
.acol .bar.hi { background: var(--accent); }
.acol .cl { font-family: var(--font-mono); font-size: 10px; color: var(--fg-lo); }
.acol .cv { font-family: var(--font-mono); font-size: 10px; color: var(--fg-mid); font-weight: 700; }

/* tabela */
table.atable { width: 100%; border-collapse: collapse; font-size: 13px; }
table.atable th { text-align: left; padding: 8px 10px; font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .07em; text-transform: uppercase; color: var(--fg-lo); font-weight: 600; border-bottom: 1px solid var(--border); }
table.atable td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); color: var(--fg); }
table.atable tbody tr:last-child td { border-bottom: 0; }
table.atable td.num, table.atable th.num { text-align: right; font-family: var(--font-mono); }
table.atable .code { font-family: var(--font-mono); font-weight: 700; }

/* progresso meta */
.ameter { display: flex; flex-direction: column; gap: 14px; }
.ameter-row .ml { display: flex; align-items: baseline; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.ameter-row .ml b { font-weight: 700; }
.ameter-row .ml .v { margin-left: auto; font-family: var(--font-mono); font-weight: 700; }
.ameter-track { height: 12px; border-radius: 99px; background: var(--surface-3); overflow: hidden; position: relative; }
.ameter-track i { display: block; height: 100%; border-radius: 99px; }
.ameter-mark { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--fg-mid); }

/* fonte + follow-ups */
.asst-source { display: inline-flex; align-items: center; gap: 7px; margin-top: 13px; font-size: 12.5px; font-weight: 700; color: var(--accent); cursor: pointer; }
.asst-source svg { width: 14px; }
.asst-source:hover { text-decoration: underline; }
.asst-fu-h { font-family: var(--font-mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); margin: 18px 0 9px; }
.asst-fu { display: flex; gap: 8px; flex-wrap: wrap; }
.asst-fu button {
  font-family: var(--font-ui); font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--fg-mid); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 7px 13px; text-align: left;
}
.asst-fu button:hover { border-color: var(--accent); color: var(--accent); }

/* typing */
.asst-typing { display: inline-flex; gap: 4px; padding: 6px 2px; }
.asst-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-lo); animation: asstBlink 1.2s infinite both; }
.asst-typing i:nth-child(2) { animation-delay: .2s; }
.asst-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes asstBlink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.asst-note { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-faint); margin-top: 12px; display: flex; align-items: center; gap: 6px; }
.asst-note svg { width: 12px; color: var(--st-available); }

/* composer */
.asst-composer { flex: none; border-top: 1px solid var(--border); background: var(--surface); padding: 14px 24px 16px; }
.asst-comp-inner { max-width: 860px; margin: 0 auto; }
.asst-comp-box { display: flex; align-items: flex-end; gap: 10px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); padding: 8px 8px 8px 14px; }
.asst-comp-box:focus-within { border-color: var(--accent); }
.asst-comp-box textarea {
  flex: 1; border: 0; outline: 0; background: none; resize: none;
  font-family: var(--font-ui); font-size: 14.5px; color: var(--fg); line-height: 1.45;
  max-height: 120px; padding: 6px 0;
}
.asst-comp-box textarea::placeholder { color: var(--fg-lo); }
.asst-send {
  flex: none; width: 38px; height: 38px; border: 0; border-radius: var(--r-sm); cursor: pointer;
  background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center;
}
.asst-send:hover { background: var(--accent-deep); }
.asst-send svg { width: 17px; }
.asst-disc { font-family: var(--font-mono); font-size: 10px; color: var(--text-faint); text-align: center; margin-top: 9px; letter-spacing: .03em; }

@media (max-width: 900px) {
  .asst-sg-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   Launcher flutuante + painel ancorado
   ============================================================ */
.asst-fab {
  position: fixed; right: 24px; bottom: 24px; z-index: 150;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  box-shadow: 0 12px 30px -8px rgba(0,0,0,.55), 0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent);
  display: flex; align-items: center; justify-content: center; transition: transform .2s var(--ease);
}
.asst-fab:hover { transform: translateY(-2px) scale(1.04); }
.asst-fab svg { width: 26px; }
.asst-fab .ic-close { display: none; }
.asst-fab.open .ic-open { display: none; }
.asst-fab.open .ic-close { display: block; }
.asst-fab .fab-pulse { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--accent); animation: fabPulse 2.8s ease-out infinite; pointer-events: none; }
@keyframes fabPulse { 0% { opacity: .5; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(1.55); } }
.asst-fab.open .fab-pulse { display: none; }
@media (prefers-reduced-motion: reduce) { .asst-fab .fab-pulse { display: none; } }

/* backdrop + modal central (full size) */
.asst-backdrop { position: fixed; inset: 0; z-index: 148; background: color-mix(in srgb, var(--ink-950) 62%, transparent); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .2s var(--ease); }
.asst-backdrop.open { opacity: 1; pointer-events: auto; }

.asst-panel {
  position: fixed; top: 50%; left: 50%; z-index: 149;
  width: min(960px, 92vw); height: min(840px, 88vh);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: 0 40px 100px -20px rgba(0,0,0,.7);
  display: flex; flex-direction: column; overflow: hidden;
  transform-origin: center; visibility: hidden; transform: translate(-50%, -47%) scale(.985);
  pointer-events: none; transition: transform .22s var(--ease), visibility .22s var(--ease);
}
.asst-panel.open { visibility: visible; transform: translate(-50%, -50%); pointer-events: auto; }

.asst-phead { flex: none; display: flex; align-items: center; gap: 11px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.asst-phead .pav { width: 36px; height: 36px; border-radius: 10px; flex: none; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent); }
.asst-phead .pav svg { width: 20px; }
.asst-phead .pmeta { min-width: 0; flex: 1; }
.asst-phead .pn { font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: -.01em; }
.asst-phead .ps { font-family: var(--font-mono); font-size: 10px; letter-spacing: .05em; color: var(--fg-lo); margin-top: 1px; }
.asst-phead .pnew, .asst-phead .px { width: 32px; height: 32px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--fg-mid); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.asst-phead .pnew:hover, .asst-phead .px:hover { color: var(--fg); border-color: var(--fg-lo); }
.asst-phead .pnew svg { width: 16px; }
.asst-pbody { flex: 1; min-height: 0; display: flex; }
.asst-pbody .asst { flex: 1; }

/* dentro do modal o cabeçalho já traz a marca — esconde o saludo duplicado */
.asst-panel .asst-hi { display: none; }
.asst-panel .asst-empty { padding-top: 4px; }

@media (max-width: 560px) {
  .asst-panel { width: 94vw; height: 88vh; }
  .asst-fab { right: 16px; bottom: 16px; }
}
