/*ia.css — v7.1*/

/* ── Overlay ─────────────────────────────────────────────────── */
#ia-overlay {
  position: fixed;
  inset: 0;
  background: transparent;
  backdrop-filter: none;
  z-index: 9998;
}

/* ── Caixa principal ─────────────────────────────────────────── */
#ia-box {
  position: fixed;
  top: 50%;
  left: 50% ;
  transform: translate(-50%, -50%);
  z-index: 9999;
  width: min(540px, 95vw);
  min-height: 350px;        /* ← ADICIONAR ESTA LINHA */
  max-height: 82vh;
  background: #1a1625;
  border-radius: 24px;
  box-shadow:
    0 0 0 1px rgba(120, 80, 255, .15),
    0 24px 60px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ia-slide .22s ease;
  font-family: system-ui, -apple-system, sans-serif;
}

/* ── Header ──────────────────────────────────────────────────── */
#ia-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 14px 13px 18px;
  background: #1a1625;
  color: #fff;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
  gap: 8px;
  user-select: none;
}

#ia-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

#ia-titulo {
  font-size: .92rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: #f0eeff;
  white-space: nowrap;
}

#ia-disciplina-badge {
  font-size: .68rem;
  font-weight: 600;
  background: rgba(255, 255, 255, .08);
  color: #c4b8ff;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: .05em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, .1);
  white-space: nowrap;
}

#ia-header-acoes {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

/* ── Separador vertical entre grupos ─────────────────────────── */
.ia-header-sep {
  width: 1px;
  height: 18px;
  background: rgba(255, 255, 255, .1);
  margin: 0 3px;
  flex-shrink: 0;
}

/* ── Grupo de botões de posição ──────────────────────────────── */
#ia-pos-group {
  display: inline-flex;
  align-items: center;
  gap: 1px;
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(120, 80, 255, .2);
  border-radius: 12px;
  padding: 3px 4px;
}

.ia-pos-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 26px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: rgba(180, 160, 255, .45);
  transition:
    background .15s ease,
    color .15s ease,
    transform .1s ease;
  padding: 0;
  outline: none;
  flex-shrink: 0;
}

.ia-pos-btn:hover {
  background: rgba(120, 80, 255, .18);
  color: #c4b0ff;
  transform: scale(1.08);
}

.ia-pos-btn:active {
  transform: scale(0.94);
}

.ia-pos-btn.ia-pos-ativo {
  background: rgba(120, 80, 255, .28);
  color: #d0bcff;
  box-shadow: inset 0 0 0 1px rgba(150, 100, 255, .3);
}

/* Separador interno do grupo */
.ia-pos-sep {
  width: 1px;
  height: 14px;
  background: rgba(120, 80, 255, .25);
  margin: 0 3px;
  flex-shrink: 0;
}

/* Botão arrastar — estilo âmbar quando ativo */
.ia-pos-drag-btn {
  color: rgba(180, 160, 255, .38);
}

.ia-pos-drag-btn.ia-pos-ativo {
  background: rgba(255, 180, 80, .15);
  color: #fbbf24;
  box-shadow: inset 0 0 0 1px rgba(255, 180, 80, .25);
}

.ia-pos-drag-btn:hover {
  background: rgba(255, 180, 80, .12);
  color: #fbbf24;
}

/* ── Botões do header (limpar conversa, fechar) ──────────────── */
#ia-limpar,
#ia-fechar {
  background: none;
  border: none;
  color: rgba(255, 255, 255, .35);
  font-size: .95rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  transition: color .15s, background .15s;
}

#ia-limpar:hover,
#ia-fechar:hover {
  color: #fff;
  background: rgba(255, 255, 255, .08);
}

/* ── Botão modo explicação ───────────────────────────────────── */
#ia-explicacao {
  background: rgba(255, 255, 255, .04);
  border: none;
  font-size: .9rem;
  cursor: pointer;
  line-height: 1;
  padding: 6px 8px;
  border-radius: 8px;
  opacity: .5;
  transition: opacity .2s ease, background .2s ease, box-shadow .2s ease;
}

#ia-explicacao:hover {
  opacity: .85;
  background: rgba(255, 255, 255, .08);
}

#ia-explicacao.ativo {
  opacity: 1;
  background: rgba(140, 100, 255, .2);
  box-shadow: inset 0 0 0 1px rgba(140, 100, 255, .35);
}

/* ── Área de chat ─────────────────────────────────────────────── */
#ia-chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: #1a1625;
}

#ia-chat::-webkit-scrollbar { width: 4px; }
#ia-chat::-webkit-scrollbar-track { background: transparent; }
#ia-chat::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
}

/* Bolha genérica */
.ia-msg-bloco {
  max-width: 88%;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: .875rem;
  line-height: 1.65;
  word-break: break-word;
}

/* Usuário */
.ia-msg-user {
  align-self: flex-end;
  background: #2d2040;
  color: #e8e0ff;
  border-bottom-right-radius: 6px;
}

/* Assistente */
.ia-msg-assistant {
  align-self: flex-start;
  background: #231d35;
  color: #e0ddf0;
  border-bottom-left-radius: 6px;
  border: 1px solid rgba(255, 255, 255, .06);
}

.ia-pensando { padding: 14px 18px; }

/* ── Markdown ─────────────────────────────────────────────────── */
.ia-msg-assistant p    { margin: 0 0 .6em; }
.ia-msg-assistant p:last-child { margin-bottom: 0; }

.ia-msg-assistant h2,
.ia-msg-assistant h3 {
  margin: .8em 0 .3em;
  font-size: .875rem;
  font-weight: 700;
  color: #c4b8ff;
}

.ia-msg-assistant ul {
  margin: .4em 0;
  padding-left: 1.2em;
}

.ia-msg-assistant li { margin-bottom: .25em; }

.ia-msg-assistant strong {
  font-weight: 700;
  color: #c4b8ff;
}

.ia-msg-assistant em { font-style: italic; }

.ia-msg-assistant code {
  background: rgba(140, 100, 255, .15);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: .82em;
  color: #c4a8ff;
}

.ia-msg-assistant pre {
  background: #120f1e;
  color: #d4c8ff;
  padding: 12px 14px;
  border-radius: 12px;
  overflow-x: auto;
  font-size: .8rem;
  margin: .5em 0;
  border: 1px solid rgba(255, 255, 255, .06);
}

.ia-msg-assistant pre code {
  background: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}

/* ── Avisos / erros ───────────────────────────────────────────── */
.ia-aviso {
  background: rgba(255, 200, 0, .1);
  color: #f0d060;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .82rem;
  border: 1px solid rgba(255, 200, 0, .2);
}

.ia-erro {
  background: rgba(255, 80, 80, .1);
  color: #ff9090;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .82rem;
  border: 1px solid rgba(255, 80, 80, .2);
}

/* ── Loader ───────────────────────────────────────────────────── */
.ia-loading {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 4px 0;
}

.ia-loading span {
  width: 8px;
  height: 8px;
  background: #8b5cf6;
  border-radius: 50%;
  animation: ia-bounce .9s infinite ease-in-out;
}

.ia-loading span:nth-child(2) { animation-delay: .15s; }
.ia-loading span:nth-child(3) { animation-delay: .30s; }

/* ── Área de input ────────────────────────────────────────────── */
#ia-input-area {
  border-top: 1px solid rgba(255, 255, 255, .06);
  padding: 14px 16px;
  background: #1a1625;
  flex-shrink: 0;
}

/* Wrapper com posicionamento relativo para o botão X */
#ia-input-wrapper {
  position: relative;
}

#ia-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 14px;
  padding: 11px 40px 11px 14px;
  font-size: .875rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color .2s;
  background: #231d35;
  line-height: 1.5;
  color: #e0ddf0;
    scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .1) transparent;
}

#ia-input::-webkit-scrollbar { width: 4px; }
#ia-input::-webkit-scrollbar-track { background: transparent; }
#ia-input::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .1);
  border-radius: 4px;
}
#ia-input::-webkit-scrollbar-thumb:hover {
  background: rgba(140, 100, 255, .3);
}
#ia-input::placeholder { color: rgba(255, 255, 255, .3); }
#ia-input:focus { border-color: rgba(140, 100, 255, .5); }


/* ── Botão limpar o campo de texto ───────────────────────────── */
#ia-limpar-input {
  position: absolute;
  bottom: 50%;
  right: 15px;
  transform: translateY(50%) scale(0.7);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  border: 1px solid rgba(120, 80, 255, .2);
  background: rgba(120, 80, 255, .08);
  color: rgba(180, 150, 255, .6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity .18s ease,
    transform .18s cubic-bezier(.34, 1.56, .64, 1),
    background .15s ease,
    color .15s ease;
}

#ia-limpar-input:hover {
  background: rgba(120, 80, 255, .22);
  color: #c4a0ff;
  border-color: rgba(140, 100, 255, .45);
}

#ia-limpar-input:active {
  transform: translateY(50%) scale(0.88) !important;
}


/* ── Rodapé do input ──────────────────────────────────────────── */
#ia-rodape {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

#ia-contador {
  font-size: .7rem;
  color: rgba(255, 255, 255, .25);
}

#ia-enviar {
  background: #7c3af3;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 9px 22px;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  min-width: 110px;
  letter-spacing: .01em;
}

#ia-enviar:disabled    { opacity: .4; cursor: default; }
#ia-enviar:not(:disabled):hover { background: #6d28e0; }

/* ── Animações ────────────────────────────────────────────────── */
@keyframes ia-slide {
  from { opacity: 0; transform: translate(-50%, -47%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes ia-bounce {
  0%, 80%, 100% { transform: scale(0); opacity: .3; }
  40%           { transform: scale(1); opacity:  1; }
}

/* ── Fonte da resposta ────────────────────────────────────────── */
.ia-fonte {
  font-size: 10px;
  opacity: .3;
  display: block;
  text-align: right;
  margin-top: 6px;
  color: #a090cc;
}

/* ── Botão flutuante ──────────────────────────────────────────── */
.ia-fab-custom {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 0;
  background: #1a1625;
  color: #e8e0ff;
  border: 1px solid rgba(120, 80, 255, .4);
  border-radius: 50px;
  padding: 13px 14px;
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  overflow: hidden;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, .5),
    0 0 0 1px rgba(100, 60, 255, .1);
  transition:
    padding 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
    border-color 0.25s ease,
    box-shadow 0.25s ease;
  animation: ia-pulse-ring 4s ease-in-out infinite;
}

.ia-fab-icon {
  font-size: 1.05rem;
  line-height: 1;
  color: #a78bff;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  transition: transform 0.3s ease;
}

.ia-fab-label {
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  opacity: 0;
  margin-left: 0;
  color: #c4b0ff;
  transition:
    max-width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.25s ease,
    margin-left 0.3s ease;
}

.ia-fab-custom:hover {
  padding: 13px 18px 13px 14px;
  border-color: rgba(140, 100, 255, .7);
  box-shadow:
    0 12px 40px rgba(0, 0, 0, .55),
    0 0 0 1px rgba(120, 80, 255, .3),
    0 0 40px rgba(100, 60, 255, .2);
  animation: none;
}

.ia-fab-custom:hover .ia-fab-label {
  max-width: 120px;
  opacity: 1;
  margin-left: 8px;
}

.ia-fab-custom:hover .ia-fab-icon {
  transform: rotate(20deg) scale(1.1);
}

.ia-fab-custom:active { transform: scale(0.97); }

@keyframes ia-pulse-ring {
  0%, 90%, 100% {
    box-shadow:
      0 8px 32px rgba(0, 0, 0, .5),
      0 0 0 1px rgba(100, 60, 255, .1);
  }
  45% {
    box-shadow:
      0 0 0 6px rgba(100, 60, 255, .07),
      0 8px 32px rgba(0, 0, 0, .5),
      0 0 50px rgba(100, 60, 255, .18);
  }
}

/* ── Responsivo ───────────────────────────────────────────────── */
@media (max-width: 768px) {
  #ia-pos-group,
  .ia-header-sep:first-of-type {
    display: none;
  }
}

@media (max-width: 480px) {
  #ia-box {
    width: 100vw;
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    top: auto;
    bottom: 0;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
    animation: ia-slide-up .22s ease;
    min-height: 420px; 
  }

  .ia-fab-custom {
    bottom: 18px;
    right: 18px;
    padding: 11px 12px;
  }
}

@keyframes ia-slide-up {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}