/* =========================================================
   RESET / BASE
========================================================= */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden;
}

/* =========================================================
   WIDGET BASE
========================================================= */
#star-ia-widget{
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: Arial, sans-serif;
}

/* garante que não fique atrás de nada */
#star-ia-widget, #star-ia-presence, #star-ia-chat { z-index: 99999; }

/* =========================================================
   PRESENÇA (BOLHA + AVATAR)
========================================================= */
#star-ia-presence{
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: row-reverse;
  gap: 12px;
  cursor: pointer;
}

.presence-avatar{ position: relative; }

.presence-avatar img{
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
}

.online-dot{
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #2ecc71;
  border-radius: 50%;
  border: 2px solid #fff;
}

.presence-bubble{
  background: #fff;
  padding: 8px 14px;
  border-radius: 18px;
  min-width: 80px;
  min-height: 36px;
  max-width: 220px;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* =========================================================
   CHAT BOX (NÃO FORÇA ABRIR!)
========================================================= */
#star-ia-chat{
  /* IMPORTANTE: não forçar display no CSS */
  display: none;               /* fechado por padrão */
  flex-direction: column;      /* quando abrir, vira coluna */
  overflow: hidden;

  width: 360px;
  height: 520px;               /* altura CONTROLADA no desktop */
  max-height: 520px;

  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.25);
}

/* Se seu JS abre com display:block, converte para flex sem quebrar o “fechar” */
#star-ia-chat[style*="display: block"]{ display: flex !important; }

/* =========================================================
   HEADER
========================================================= */
#star-ia-header{
  background: #4CAF50;
  color: #fff;

  display: flex;
  align-items: center;
  justify-content: space-between;

  padding: 10px 12px;
  border-radius: 16px 16px 0 0;
  flex-shrink: 0;
}

.star-ia-header-left{
  display: flex;
  align-items: center;
  gap: 10px;
}

.star-ia-header-left img,
#star-ia-header img{
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.star-ia-header-text{
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.star-ia-header-text small{
  font-size: 11px;
  opacity: 0.9;
}

#star-ia-close{
  font-size: 22px;
  cursor: pointer;
}

/* =========================================================
   MESSAGES (rolagem correta em FLEX)
========================================================= */
#star-ia-messages{
  flex: 1;
  min-height: 0;                 /* CHAVE: impede “crescer” e sumir input */
  padding: 12px;

  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  background: #f7f7f7;
}

/* bolhas */
.star-ia-msg{
  margin-bottom: 10px;
  line-height: 1.4;
}

/* BOT - layout com avatar + balão */
.star-ia-msg.bot{
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

/* AVATAR NAS MENSAGENS */
.bot-avatar img{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

/* BALÃO BOT */
.bot-bubble{
  background: #f1f1f1;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 75%;
  font-size: 14px;

  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* USER */
.star-ia-msg.user{
  background: #DCF8C6;
  padding: 10px 14px;
  border-radius: 16px;
  margin-left: auto;
  max-width: 75%;
  text-align: right;

  white-space: normal;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* =========================================================
   TYPING
========================================================= */
.star-ia-msg.typing{
  background: #f1f1f1;
  padding: 8px 14px;
  border-radius: 20px;
  width: fit-content;
  margin: 0 auto 10px auto;
}

.typing-dots{
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.typing-dots span{
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  display: inline-block;
  animation: blink 1.4s infinite both;
}
.typing-dots span:nth-child(2){ animation-delay:.2s; }
.typing-dots span:nth-child(3){ animation-delay:.4s; }

@keyframes blink{
  0%{opacity:.2}
  20%{opacity:1}
  100%{opacity:.2}
}

/* =========================================================
   INPUT AREA (não pode sumir)
========================================================= */
#star-ia-input-area{
  display: flex;
  align-items: center;
  gap: 10px;

  padding: 10px;
  border-top: 1px solid #eee;
  background: #fff;

  flex-shrink: 0;
}

#star-ia-input{
  flex: 1;
  border-radius: 20px;
  border: 1px solid #ddd;
  padding: 10px 14px;
  font-size: 14px;
}

#star-ia-send{
  width: 44px;
  height: 44px;
  border-radius: 999px;

  background: #2ecc71;
  color: #fff;

  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  padding: 0;
}

#star-ia-send svg{
  width: 20px;
  height: 20px;
  display: block;
}

/* =========================================================
   POWERED BY
========================================================= */
#star-ia-powered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 12px;
    padding: 8px 0;
    background: #fafafa;
    border-top: 1px solid #eee;
    color: #4CAF50;
    font-weight: 900; /* 🔴 NEGRITO */
}

.star-powered-inline img {
    height: 16px;
    width: auto;
    vertical-align: middle;
    display: inline-block;
}


/* =========================================================
   BOTÃO WHATSAPP (se usar nas mensagens)
========================================================= */
.star-ia-whatsapp-btn,
.star-ia-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    background-color: #25D366;
    color: #ffffff !important;

    padding: 12px 20px;
    border-radius: 999px;

    font-weight: 600;
    font-size: 14px;
    text-decoration: none !important;

    min-width: 200px;
    height: 44px;
}
.star-ia-whatsapp-btn:hover,
.star-ia-whatsapp-btn:active,
.star-ia-whatsapp-btn:focus,
.star-ia-btn:hover,
.star-ia-btn:active,
.star-ia-btn:focus{
  background-color: #25D366;
  color: #ffffff !important;
  text-decoration: none !important;
}

/* =========================================================
   MOBILE (iPhone/Safari teclado) — tela cheia sem sumir header/input
========================================================= */
@media (max-width: 768px){

  #star-ia-widget{
    right: 0;
    left: 0;
    bottom: 0;
  }

  #star-ia-chat{
    position: fixed !important;
    inset: 0 !important;

    width: 100vw !important;

    /* fallback + iOS */
    height: 100vh !important;
    height: 100svh !important;
    height: 100dvh !important;

    max-height: none !important;
    border-radius: 0 !important;

    /* NÃO forçar display aqui */
    overflow: hidden !important;
    background: #fff !important;
  }

  /* notch/top safe area */
  #star-ia-header{
    padding-top: calc(10px + env(safe-area-inset-top)) !important;
    border-radius: 0 !important;
  }

  /* mensagens não “empurram” o input */
  #star-ia-messages{
    min-height: 0 !important;
    padding-bottom: 12px !important;
  }

  /* input sticky no rodapé (não fixed) */
  #star-ia-input-area{
    position: sticky !important;
    bottom: 0 !important;
    z-index: 5 !important;

    padding-bottom: calc(10px + env(safe-area-inset-bottom)) !important;
  }

  /* evita zoom iOS ao focar */
  #star-ia-input{
    font-size: 16px !important;
  }

  /* powered continua visível e não sobe por cima do teclado */
  #star-ia-powered{
    padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
  }
}

/* =========================================================
   DESKTOP (mantém fixo e sem crescer)
========================================================= */
@media (min-width: 769px){
  #star-ia-widget{
    right: 20px;
    left: auto;
    bottom: 20px;
  }

  #star-ia-chat{
    width: 360px;
    height: 520px;
    max-height: 520px;
  }
}
.star-ia-btn {
    display:flex;
    align-items:center;
    justify-content:center;
    gap:8px;
}
