/* ---------------------------------------------------------------- Chat (layout inspirado no Claude Code) */

.chat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top));
}
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--sep);
}
.chat-head .titulo { flex: 1; min-width: 0; }
.chat-head .titulo strong { display: block; font-size: 15px; }
.chat-head .titulo span { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head .barra { width: 120px; }
.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.transcript-inner { max-width: 780px; margin: 0 auto; padding: 28px 16px 24px; display: flex; flex-direction: column; gap: 18px; }

.msg { display: flex; gap: 12px; animation: entrar .3s var(--ease); }
.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  flex: none;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #47B37A, #237349);
  color: #fff;
  margin-top: 1px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3);
}
.msg-avatar svg { width: 17px; height: 17px; }
.msg-corpo { flex: 1; min-width: 0; font-size: 15.5px; line-height: 1.6; overflow-wrap: anywhere; }
.msg-corpo strong { font-weight: 650; }
.msg-corpo ul { margin: 6px 0; padding-left: 20px; }
.msg-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.msg.usuario { justify-content: flex-end; }
.bolha {
  max-width: min(80%, 560px);
  background: var(--user-bubble);
  border-radius: 20px 20px 6px 20px;
  padding: 10px 16px;
  font-size: 15.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bolha.comando { background: transparent; border: 1px dashed var(--sep); color: var(--text-2); font-size: 13.5px; padding: 6px 12px; border-radius: 999px; }
.bolha .i { margin-right: 6px; color: var(--accent); }
.dica {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 14px;
  margin-left: 42px;
}
.dica .i { color: var(--accent); }
.digitando { display: inline-flex; gap: 4px; padding: 10px 0; }
.digitando span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); animation: pulso 1.2s infinite; }
.digitando span:nth-child(2) { animation-delay: .15s; }
.digitando span:nth-child(3) { animation-delay: .3s; }
@keyframes pulso { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.resumo-card { border-radius: var(--r-lg); padding: 6px 0; margin-top: 4px; }
.resumo-grupo { padding: 10px 16px; }
.resumo-grupo + .resumo-grupo { border-top: 1px solid var(--sep); }
.resumo-grupo h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-bottom: 6px; font-weight: 700; }
.resumo-item { display: grid; grid-template-columns: minmax(0, 38%) minmax(0, 1fr) auto; gap: 10px; align-items: start; padding: 5px 0; font-size: 14px; }
.resumo-item .rot { color: var(--text-2); }
.resumo-item .val { overflow-wrap: anywhere; }
.lapis {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  border: 0;
  background: transparent;
  color: var(--text-3);
  display: grid;
  place-items: center;
  margin-top: -3px;
}
.lapis:hover { background: var(--accent-soft); color: var(--accent); }
.lapis svg { width: 15px; height: 15px; }

.composer-wrap {
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 35%);
}
.composer-area { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 10px; }
.composer { border-radius: var(--r-xl); padding: 10px 10px 8px 16px; transition: box-shadow .2s var(--ease); }
.composer:focus-within { box-shadow: var(--shadow), var(--focus), inset 0 1px 0 var(--glass-highlight); }
.composer textarea {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  outline: none;
  font-size: 15.5px;
  line-height: 1.5;
  max-height: 220px;
  padding: 6px 0;
  display: block;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:focus-visible { box-shadow: none; }
.composer .entrada-especial { display: flex; gap: 10px; align-items: center; padding: 4px 0 6px; flex-wrap: wrap; }
.composer .entrada-especial .field, .composer .entrada-especial .select { flex: 1; min-width: 180px; }
.composer-rodape { display: flex; align-items: center; gap: 6px; }
.composer-rodape .espaco { flex: 1; }
.composer-rodape .atalho { font-size: 12px; color: var(--text-3); margin-right: 6px; }
.enviar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 0;
  background: var(--acao);
  color: var(--acao-texto);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(46, 139, 87, .3);
  transition: transform .15s var(--ease), opacity .2s;
}
.enviar:disabled { opacity: .35; box-shadow: none; }
.enviar:active { transform: scale(.93); }
.enviar svg { width: 20px; height: 20px; }
.ferramenta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 550;
}
.ferramenta:hover { background: var(--surface-sunken); color: var(--text); }
.ferramenta svg { width: 17px; height: 17px; }
.arquivo-alvo {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--r);
  border: 1.5px dashed var(--sep);
  color: var(--text-2);
  background: transparent;
  text-align: left;
}
.arquivo-alvo:hover, .arquivo-alvo.sobre { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }

.lista-busca { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.lista-opcoes { display: flex; flex-wrap: wrap; gap: 8px; max-height: min(34vh, 220px); overflow-y: auto; padding: 2px; }
.calendario { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.cal-atalhos { display: flex; gap: 8px; }
.cal-topo { display: flex; align-items: center; justify-content: space-between; }
.cal-topo strong { font-size: 14.5px; }
.cal-topo strong::first-letter { text-transform: uppercase; }
.cal-grade { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-sem { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--text-3); padding: 2px 0; }
.dia { border: 0; background: transparent; border-radius: 10px; height: clamp(30px, 4.6vh, 38px); font-size: 14px; font-variant-numeric: tabular-nums; }
.dia:hover { background: var(--accent-soft); color: var(--accent); }
.dia.passado { color: var(--text-3); }
.dia.hoje { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 700; }
.chat-side { border-left: 1px solid var(--sep); overflow-y: auto; padding: 20px 16px; display: flex; flex-direction: column; gap: 16px; }
.chat-side .glass { border-radius: var(--r-lg); }
.progresso-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.progresso-card .linha-progresso { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); }
.so-mobile { display: none; }

@media (max-width: 1020px) {
  .chat { grid-template-columns: 1fr; }
  .chat-side { display: none; }
  .so-mobile { display: inline-flex; }
  .chat-head .barra { display: none; }
}
