/* chat.css — janela de chat flutuante (arrastar, redimensionar, persistência) */

:root{
  --iah-font: var(--bs-font-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans");
  --iah-bg:   var(--bs-body-bg, #fff);
  --iah-fg:   var(--bs-body-color, #111827);
  --iah-muted:#f3f4f6;
  --iah-border: rgba(0,0,0,.12);
  --iah-radius: 12px;
  --iah-shadow: 0 10px 30px rgba(0,0,0,.18);
  --iah-header-h: 0px; /* ajustado via JS */
}

/* Contêiner principal do chat */
#iah-chat{
  position: fixed; /* FIXO: acompanha viewport, independente do scroll */
  top: calc(var(--iah-header-h, 0px) + 5px); /* 5px abaixo do header (definido na abertura) */
  right: calc(16px + env(safe-area-inset-right, 0px));
  width: 368px; min-width: 300px; max-width: min(96vw, 560px);
  height: 56vh; min-height: 260px; max-height: calc(100vh - var(--iah-header-h) - 16px);
  background: var(--iah-bg); color: var(--iah-fg);
  border: 1px solid var(--iah-border); border-radius: var(--iah-radius);
  box-shadow: var(--iah-shadow);
  display: flex; flex-direction: column; overflow: hidden;
  z-index: 2147483647; font-family: var(--iah-font); font-size: 0.95rem;
  resize: both;
}
#iah-chat[hidden]{ display: none !important; }

/* Barra de título */
#iah-chat .iah-head{
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px;
  background: #230000;  /* exigido */
  color: #fff;
  user-select: none; cursor: move;
}
#iah-chat .iah-title{
  margin: 0; font-size: 0.98rem; font-weight: 700; letter-spacing: .2px;
}
#iah-chat .iah-head-actions{
  display: inline-flex; align-items: center; gap: 8px;
}

/* Botões (Nova conversa / Enviar) com #FDBA4D */
#iah-chat .iah-btn{
  border: 1px solid rgba(0,0,0,.06);
  background: #FDBA4D;        /* <<< cor solicitada */
  color: #230000;             /*  bom contraste sobre o âmbar */
  border-radius: 8px; cursor: pointer;
  padding: 6px 10px; font: 600 12px/1 var(--iah-font);
  transition: filter .15s ease, transform .04s ease, box-shadow .15s ease;
}
#iah-chat .iah-btn:hover{ filter: brightness(.98); }
#iah-chat .iah-btn:focus-visible{
  outline: 0; box-shadow: 0 0 0 3px rgba(253,186,77,.35);
}

/* Botão fechar (4px mais alto) */
#iah-chat .iah-close{
  appearance: none; border: 0; background: transparent; color: #fff;
  font-size: 20px; cursor: pointer; line-height: 1;
  position: relative; top: -4px; /* <<< sobe 4px */
}
#iah-chat .iah-close::before{
  content: ""; position: absolute; inset: -10px; /* hit-area maior */
}

/* Área de mensagens */
#iah-chat .iah-body{
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px; overflow: auto; flex: 1 1 auto; background: var(--iah-bg);
}
#iah-chat .iah-body::-webkit-scrollbar{ width: 6px; }
#iah-chat .iah-body::-webkit-scrollbar-thumb{ background: rgba(0,0,0,.2); border-radius: 3px; }

#iah-chat .iah-msg{
  border-radius: 10px; padding: 8px 10px; max-width: min(80%, 72ch);
  white-space: pre-wrap; word-wrap: break-word; line-height: 1.45;
}
#iah-chat .user{ align-self: flex-end; background: rgba(35,0,0,.06); }
#iah-chat .bot{  align-self: flex-start; background: var(--iah-muted); }
#iah-chat .typing{ opacity: .85; font-style: italic; }

/* Rodapé (entrada) */
#iah-chat .iah-form{
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--iah-border);
  background: var(--iah-bg);
}
#iah-chat .iah-input{
  flex: 1; resize: vertical; min-height: 40px; max-height: 140px; padding: 8px 10px;
  border: 1px solid var(--iah-border); border-radius: 8px;
  background: var(--iah-bg); color: var(--iah-fg); font: inherit; outline: none;
}
#iah-chat .iah-input::placeholder{ color: rgba(17,24,39,.5); }
#iah-chat .iah-input:focus{
  border-color: rgba(35,0,0,.55);
  box-shadow: 0 0 0 3px rgba(35,0,0,.18);
}

/* Enviar com #FDBA4D */
#iah-chat .iah-send{
  padding: 8px 12px; border: 0; border-radius: 8px; cursor: pointer;
  background: #FDBA4D;        /* <<< cor solicitada */
  color: #230000;             /* contraste */
  font: inherit; min-width: 44px;
  transition: filter .15s ease, transform .04s ease, box-shadow .15s ease;
}
#iah-chat .iah-send:hover{ filter: brightness(.98); }
#iah-chat .iah-send:active{ transform: translateY(1px); }
#iah-chat .iah-send:disabled{ opacity: .5; cursor: not-allowed; }

/* Indicador opcional */
#iah-chat .iah-resize{
  position: absolute; width: 14px; height: 14px; right: 2px; bottom: 2px;
  background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,.2) 50%);
  border-radius: 2px; pointer-events: none;
}

/* Acessibilidade */
@media (prefers-reduced-motion: reduce){
  #iah-chat, #iah-chat .iah-send, #iah-chat .iah-msg { transition: none !important; animation: none !important; }
}

/* Mobile */
@media (max-width: 520px){
  #iah-chat{
    right: calc(8px + env(safe-area-inset-right, 0px));
    width: min(96vw, 420px);
    height: 52vh;
  }
  #iah-chat .iah-head{ padding: 10px; }
  #iah-chat .iah-form{ padding: 8px; gap: 6px; }
  #iah-chat .iah-input{ min-height: 44px; }
}
