/* =========================================================
   Assistente com IA — widget flutuante + versão embutida
   ========================================================= */
.ai-launcher {
  position: fixed;
  right: 18px;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 54px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #7C5CFF, #3D8BFF);
  color: #fff;
  font: 600 15px/1 "Plus Jakarta Sans", system-ui, sans-serif;
  cursor: pointer;
  box-shadow: 0 16px 34px -14px rgba(124, 92, 255, .9);
  transition: transform .2s, box-shadow .2s, opacity .2s;
}
.ai-launcher:hover { transform: translateY(-2px); }
.ai-launcher .i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-launcher__dot {
  position: absolute; top: 8px; right: 12px; width: 10px; height: 10px;
  border-radius: 50%; background: #24d16b; border: 2px solid #fff;
}
.ai-launcher[hidden] { display: none; }
@media (min-width: 768px) { .ai-launcher { right: 28px; bottom: calc(104px + env(safe-area-inset-bottom)); } }
@media (max-width: 420px) { .ai-launcher__text { display: none; } .ai-launcher { padding: 0; width: 54px; justify-content: center; } }

.ai-panel {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: min(400px, calc(100vw - 36px));
  height: min(620px, calc(100dvh - 36px));
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 40px 90px -30px rgba(8, 11, 42, .6), 0 0 0 1px rgba(8, 11, 42, .06);
  transform-origin: bottom right;
  animation: aiPanelIn .28s cubic-bezier(.2, .8, .2, 1);
}
.ai-panel[hidden] { display: none; }
@keyframes aiPanelIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@media (max-width: 520px) {
  .ai-panel { right: 0; bottom: 0; width: 100vw; height: 100dvh; border-radius: 0; }
}
@media (prefers-reduced-motion: reduce) { .ai-panel, .ai-launcher { animation: none; transition: none; } }

.ai-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: #080B2A;
  color: #F5F3EE;
}
.ai-head__avatar {
  display: grid; place-items: center; width: 42px; height: 42px; flex: none;
  border-radius: 50%; background: linear-gradient(135deg, #7C5CFF, #3D8BFF);
}
.ai-head__avatar .i { width: 22px; height: 22px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ai-head__title { flex: 1; min-width: 0; }
.ai-head__title b { display: block; font-size: 15px; }
.ai-head__title small { display: flex; align-items: center; gap: 6px; font-size: 12px; color: rgba(245, 243, 238, .72); }
.ai-head__status { width: 8px; height: 8px; border-radius: 50%; background: #24d16b; }
.ai-head__close {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none;
  border: 0; border-radius: 10px; background: rgba(245, 243, 238, .1); color: inherit; cursor: pointer;
}
.ai-head__close:hover { background: rgba(245, 243, 238, .2); }
.ai-head__close .i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.ai-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #F5F3EE;
  scroll-behavior: smooth;
}
.ai-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
  animation: aiMsgIn .3s ease;
}
@keyframes aiMsgIn { from { opacity: 0; transform: translateY(8px); } }
.ai-msg--bot { align-self: flex-start; background: #fff; color: #171821; border-bottom-left-radius: 5px; box-shadow: 0 1px 2px rgba(8, 11, 42, .06); }
.ai-msg--user { align-self: flex-end; background: #080B2A; color: #F5F3EE; border-bottom-right-radius: 5px; }
.ai-msg p { margin: 0 0 8px; }
.ai-msg p:last-child { margin-bottom: 0; }
.ai-msg ul { margin: 6px 0; padding-left: 18px; }
.ai-msg li { margin: 3px 0; }
.ai-msg a { color: #5536E0; font-weight: 700; text-decoration: underline; }
.ai-msg--user a { color: #B3A3FF; }
.ai-msg strong { font-weight: 700; }
.ai-msg--tool {
  align-self: center; max-width: 92%; padding: 7px 14px;
  background: rgba(124, 92, 255, .12); color: #5536E0;
  border-radius: 999px; font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
}
.ai-msg--tool .i { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }

.ai-typing { align-self: flex-start; display: flex; gap: 4px; padding: 14px 16px; background: #fff; border-radius: 16px; border-bottom-left-radius: 5px; }
.ai-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9a8cff; animation: aiBlink 1.2s infinite ease-in-out; }
.ai-typing i:nth-child(2) { animation-delay: .2s; }
.ai-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes aiBlink { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.ai-chips { display: flex; gap: 8px; padding: 10px 14px 0; overflow-x: auto; scrollbar-width: none; }
.ai-chips::-webkit-scrollbar { display: none; }
.ai-chips button {
  flex: none; padding: 8px 13px; border: 1px solid rgba(124, 92, 255, .3);
  border-radius: 999px; background: #fff; color: #5536E0;
  font: 600 13px "Plus Jakarta Sans", system-ui, sans-serif; white-space: nowrap; cursor: pointer;
  transition: background .2s, color .2s;
}
.ai-chips button:hover { background: #6C4CF5; color: #fff; border-color: #6C4CF5; }

.ai-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid rgba(8, 11, 42, .08); }
.ai-form textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 24px; padding: 10px 14px;
  border: 1px solid rgba(8, 11, 42, .16); border-radius: 14px;
  font: 400 14.5px "Plus Jakarta Sans", system-ui, sans-serif; color: #171821; background: #F5F3EE;
}
.ai-form textarea:focus { outline: none; border-color: #7C5CFF; box-shadow: 0 0 0 3px rgba(124, 92, 255, .2); }
.ai-form__send {
  display: grid; place-items: center; width: 44px; height: 44px; flex: none;
  border: 0; border-radius: 12px; background: #6C4CF5; color: #fff; cursor: pointer; transition: background .2s;
}
.ai-form__send:hover { background: #5B3BE8; }
.ai-form__send:disabled { opacity: .5; cursor: default; }
.ai-form__send .i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.ai-foot { padding: 0 16px 10px; font-size: 11px; color: #62647A; text-align: center; background: #fff; }

/* ---- Versão embutida na página de IA ---- */
.ai-embed { display: flex; flex-direction: column; height: min(560px, 74vh); background: #fff; border-radius: 22px; overflow: hidden; box-shadow: 0 50px 100px -40px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.06); }
.ai-embed .ai-log { background: #F7F6F2; }
