/* v0.4.9 (Kleversom 21/11 23:40–23:55): Histórico > escolher pontos + UM componente de gráfico
   (Por ponto, Gráficos do Histórico e gráficos da conversa), no PADRÃO VISUAL DO GRÁFICO (seção 23:55) */

/* ---------- 1) escolher pontos (celular) ---------- */
@media (max-width:700px){
  #screen-history .hist-m.has-pick{padding-top:0!important;padding-bottom:calc(84px + var(--kx-sab,0px))!important}
  #screen-history .hist-m.kxp-points{gap:8px}
  #screen-history .kxp-row{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:2px}
  #screen-history .kxp-row .hist-m-back{min-width:0;color:var(--text-primary);font-size:17px;font-weight:700;padding:6px 0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  #screen-history .kxp-row .hist-m-back span{color:var(--text-secondary)}
  #screen-history .kxp-hint{flex:0 0 auto;font-size:12px;color:var(--text-muted)}
  #screen-history .hist-m-back{color:var(--text-primary)}
  #screen-history .kxp-hide{display:none!important}
  /* "Gráfico 1 ▾ · + Novo gráfico" numa linha; "Por equipamento / Tudo junto" pequenos, sem corte */
  #screen-history .hist-m-targetbar.kxp-tb{display:flex!important;flex-wrap:wrap;align-items:center;gap:6px 8px;margin:0;padding:0;border:0;background:none}
  #screen-history .kxp-tb .hist-m-target{display:inline-flex!important;align-items:center;margin:0;gap:0;flex:0 0 auto}
  #screen-history .kxp-tb .hist-m-target>span{display:none!important}
  #screen-history .kxp-tb select{width:auto!important;min-width:0;height:36px;padding:0 30px 0 12px!important;border-radius:18px!important;border:1px solid var(--border-default)!important;
    background-color:var(--bg-surface)!important;color:var(--text-primary)!important;font:600 15px/1 var(--kx-font)!important;-webkit-appearance:none;appearance:none;
    background-image:linear-gradient(45deg,transparent 50%,var(--text-secondary) 50%),linear-gradient(135deg,var(--text-secondary) 50%,transparent 50%)!important;
    background-position:calc(100% - 16px) 16px,calc(100% - 11px) 16px!important;background-size:5px 5px,5px 5px!important;background-repeat:no-repeat!important}
  #screen-history .kxp-new{height:36px;padding:0 12px;border:0;border-radius:18px;background:none;color:var(--primary);font:600 14px var(--kx-font);cursor:pointer}
  #screen-history .kxp-tb .hist-m-presets:not(.kxp-hide){display:inline-flex!important;flex:1 1 100%;gap:6px;margin:0}
  #screen-history .kxp-tb .hist-m-presets .hist-m-mini{flex:1 1 0;min-width:0;height:34px;padding:0 10px!important;border-radius:17px!important;font:600 13px var(--kx-font)!important;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  /* Limpar + Ver gráfico: barra fixa EMBAIXO (polegar), acima da barrinha do iPhone */
  #screen-history .hist-m-bar.kxp-bar{top:auto!important;bottom:calc(10px + var(--kx-sab,0px))!important;left:calc(12px + var(--kx-sal,0px))!important;right:calc(12px + var(--kx-sar,0px))!important;
    z-index:45;padding:6px!important;gap:6px!important;border-radius:28px!important;border:1px solid var(--border-default);background:var(--bg-elevated)!important;
    box-shadow:0 10px 30px rgba(0,0,0,.22)!important;backdrop-filter:none!important}
  #screen-history .kxp-bar .hist-m-bar-clear{height:44px;min-width:88px;border-radius:22px!important;border:0!important;background:transparent!important;color:var(--text-primary)!important;font:600 15px var(--kx-font)!important}
  #screen-history .kxp-bar .hist-m-bar-go{height:44px;border-radius:22px!important;font:600 15px var(--kx-font)!important;background:var(--kx-btn,#3B6E9E)!important;color:#fff!important}
  :root[data-theme="dark"] #screen-history .kxp-bar .hist-m-bar-go{background:#3B6E9E!important}
  #screen-history .hist-m-item-title{font-weight:600}
  #screen-history .hist-m-item-sub{text-transform:none}
}

/* ---------- 2) o cartão de gráfico ---------- */
.history-section-card.kxc-on{padding:16px 14px 12px!important}
.history-section-card.kxc-on>.history-section-header,.history-section-card.kxc-on>.history-section-body{position:absolute!important;left:-9999px!important;top:0!important;width:640px!important;height:1px!important;overflow:hidden!important;visibility:hidden!important;pointer-events:none!important}
.history-section-card.kxc-on{position:relative;overflow:hidden;display:block!important}
.history-section-card.kxc-on>.kxc-host{min-width:0;width:100%}
.kxc-plot{width:100%;min-width:0;overflow:hidden}
.kxc{font-family:var(--kx-font);color:var(--text-primary);position:relative}
.kxc-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:24px}
.kxc-ttl{min-width:0;font-size:15.5px;font-weight:600;line-height:1.3;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.kxc-vrow{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-top:2px}
.kxc-full .kxc-head{min-height:40px}
.kxc-acts{display:flex;align-items:center;gap:4px;flex:0 0 auto}
.kxc-an{display:inline-flex;align-items:center;gap:6px;height:36px;padding:0 14px 0 11px;border-radius:18px;border:1px solid var(--border-default);background:transparent;color:var(--text-primary);font:600 13.5px var(--kx-font);cursor:pointer}
.kxc-an svg,.kxc-ib svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.kxc-an svg{stroke-width:1.5}
.kxc-ib{display:grid;place-items:center;width:40px;height:40px;border-radius:20px;border:0;background:transparent;color:var(--text-secondary);cursor:pointer}
.kxc-ib svg circle{fill:currentColor;stroke:none}
.kxc-val{margin-top:2px;font-size:30px;font-weight:600;letter-spacing:-.01em;line-height:1.1;font-variant-numeric:tabular-nums}
.kxc-val small{font-size:15px;font-weight:500;color:var(--text-secondary);margin-left:4px}
.kxc-sum{margin-top:4px;font-size:13px;line-height:1.4;color:var(--text-secondary)}
.kxc-warn{color:#C77F12;font-weight:600}
:root[data-theme="dark"] .kxc-warn{color:#D9A548}
.kxc-per{display:flex;gap:4px;margin-top:12px;padding:3px;border-radius:12px;background:var(--bg-soft,rgba(127,127,127,.08));width:max-content;max-width:100%}
.kxc-per button{height:30px;min-width:52px;padding:0 10px;border:0;border-radius:9px;background:transparent;color:var(--text-secondary);font:600 13px var(--kx-font);cursor:pointer}
.kxc-per button[aria-current="true"]{background:var(--bg-surface);color:var(--text-primary);box-shadow:0 1px 3px rgba(0,0,0,.12)}
:root[data-theme="dark"] .kxc-per{background:#141517}
:root[data-theme="dark"] .kxc-per button[aria-current="true"]{background:#2A2C30}
.kxc-leg{display:flex;flex-wrap:wrap;gap:6px;margin-top:10px}
.kxc-chip{display:inline-flex;align-items:center;gap:7px;height:30px;max-width:100%;padding:0 11px 0 9px;border-radius:15px;border:1px solid var(--border-default);background:transparent;color:var(--text-primary);font:500 12.5px var(--kx-font);cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.kxc-chip i{flex:0 0 auto;width:9px;height:9px;border-radius:50%;background:var(--c,#888)}
.kxc-chip i.is-sp{width:14px;height:0;border-radius:0;background:none;border-top:2px dashed var(--c,#888)}
.kxc-chip.is-off{color:var(--text-muted);border-style:dashed}
.kxc-chip.is-off i{opacity:.35}
.kxc-chip[aria-pressed]{box-shadow:none!important;background:transparent!important;border-color:var(--border-default)!important;color:var(--text-primary)!important}
.kxc-chip.is-off[aria-pressed]{color:var(--text-muted)!important}
.kxc-add{color:var(--text-secondary);border-style:dashed}
.kxc-add svg{width:13px;height:13px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
.kxc-wrap{position:relative;margin:10px -6px 0 -6px;touch-action:pan-y;-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
.kxc-plot{width:100%}
.kxc-plot.kxc-anim{animation:kxcIn .3s ease-out}
@keyframes kxcIn{from{clip-path:inset(0 100% 0 0);opacity:.4}to{clip-path:inset(0 0 0 0);opacity:1}}
@media (prefers-reduced-motion:reduce){.kxc-plot.kxc-anim{animation:none}}
.kxc-empty{padding:28px 8px;text-align:center;font-size:13px;color:var(--text-secondary)}
.kxc-vl{position:absolute;width:1px;background:var(--text-muted);opacity:.6;pointer-events:none}
.kxc-dots{position:absolute;inset:0;pointer-events:none}
.kxc-dots i{position:absolute;width:8px;height:8px;margin:-6px 0 0 -6px;border-radius:50%;border:2px solid;background:var(--bg-surface)}
.kxc-tip{position:absolute;top:-6px;z-index:3;min-width:120px;max-width:240px;padding:7px 10px;border-radius:10px;background:var(--bg-elevated);border:1px solid var(--border-default);box-shadow:0 6px 18px rgba(0,0,0,.18);pointer-events:none;font-size:12px;line-height:1.35}
.kxc-tt{font-weight:600;color:var(--text-secondary);margin-bottom:2px;font-variant-numeric:tabular-nums}
.kxc-tr{display:flex;align-items:center;gap:6px;white-space:nowrap}
.kxc-tr i{width:8px;height:8px;border-radius:50%;flex:0 0 auto}
.kxc-tr i.is-sp{width:10px;height:0;border-radius:0;border-top:2px dashed;background:none!important;border-color:#8C8F95}
.kxc-tr span{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;color:var(--text-secondary)}
.kxc-tr b{font-weight:600;font-variant-numeric:tabular-nums;color:var(--text-primary)}
.kxc.is-loading .kxc-wrap,.kxc.is-loading .kxc-val,.kxc.is-loading .kxc-sum{opacity:.45;transition:opacity .2s}
.kxc-ld{position:absolute;right:4px;bottom:4px;font-size:12px;color:var(--text-muted)}
/* rodapé "Adicionar Ponto" do main.js: discreto */
#screen-pointHistory .point-history-footer-actions .primary-button{background:transparent!important;color:var(--primary)!important;border:1px dashed var(--border-default)!important;box-shadow:none!important;font-weight:600!important;border-radius:22px!important;min-height:44px}
#screen-pointHistory .history-multi-stack{gap:12px}

/* ---------- 3) conversa: versão compacta (toque abre tela cheia) ---------- */
figure.kxc-fig{padding:12px 12px 8px!important;border-radius:16px!important;margin:10px 0 0!important;overflow:hidden}
figure.kxc-fig>figcaption,figure.kxc-fig>.global-ai-message-chart{position:absolute!important;left:-9999px!important;width:600px!important;height:1px!important;overflow:hidden!important;visibility:hidden!important}
figure.kxc-fig{position:relative}
figure.kxc-fig.kxc-hid{display:none!important}
.kxc-compact .kxc-ttl{font-size:14.5px}
.kxc-compact .kxc-val{font-size:24px}
.kxc-compact .kxc-sum{font-size:12.5px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.kxc-compact .kxc-wrap{cursor:zoom-in;margin-top:8px}
.kxc-compact .kxc-leg{margin-top:8px}
.kxc-compact .kxc-chip{height:28px}
.kxc-joinbar{margin:10px 0 0}
.kxc-join{height:36px;padding:0 14px;border-radius:18px;border:1px solid var(--border-default);background:transparent;color:var(--text-primary);font:600 13px var(--kx-font);cursor:pointer}

/* ---------- tela cheia (toque no gráfico da conversa, ⋯ > Tela cheia, celular deitado) ---------- */
.kxc-full{position:fixed;inset:0;z-index:2147483000;background:var(--bg-app);display:flex;flex-direction:column;
  padding:calc(10px + var(--kx-sat,0px)) calc(14px + var(--kx-sar,0px)) calc(10px + var(--kx-sab,0px)) calc(14px + var(--kx-sal,0px))}
.kxc-fullhost{flex:1 1 auto;min-height:0;display:flex;flex-direction:column}
.kxc-fullhost .kxc{flex:1 1 auto;display:flex;flex-direction:column;min-height:0}
.kxc-fullhost .kxc-wrap{flex:1 1 auto;min-height:180px;margin:10px 0 0}
.kxc-fullhost .kxc-x{color:var(--text-primary)}
body.kxc-fullon{overflow:hidden}
@media (orientation:landscape) and (max-height:520px){
  .kxc-fullhost .kxc{display:grid;grid-template-columns:minmax(0,1fr) auto;grid-template-rows:auto auto auto minmax(0,1fr);column-gap:12px}
  .kxc-fullhost .kxc-head{grid-column:1/-1}
  .kxc-fullhost .kxc-val{font-size:22px;grid-column:1}
  .kxc-fullhost .kxc-sum{grid-column:1;margin-top:0}
  .kxc-fullhost .kxc-per{grid-column:2;grid-row:2/4;align-self:center;margin:0}
  .kxc-fullhost .kxc-leg{grid-column:1/-1;margin-top:6px}
  .kxc-fullhost .kxc-wrap{grid-column:1/-1;margin-top:10px;min-height:120px}
}
@media (min-width:701px){
  .kxc-ttl{font-size:16px}
  .kxc-val{font-size:32px}
  .kxc-wrap{margin-left:-4px;margin-right:-4px}
}
