/* ============================================================
   Instituto Vida Plena – Assistente IA Widget
   Pra. Rosana Vinhosa | rosanavinhosa.com.br
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=Inter:wght@300;400;500&display=swap');

/* ── CSS VARS (sobrescritas pelo JS com as cores do admin) ── */
:root {
  --ivp-primary : #4A3728;
  --ivp-accent  : #C49A5A;
  --ivp-light   : #FAF7F2;
  --ivp-white   : #FFFFFF;
  --ivp-text    : #2C1F14;
  --ivp-muted   : #8A7060;
  --ivp-bubble-user : #4A3728;
  --ivp-bubble-bot  : #F2EBE0;
  --ivp-shadow  : 0 8px 40px rgba(74,55,40,0.18);
  --ivp-radius  : 20px;
  --ivp-font-body   : 'Inter', sans-serif;
  --ivp-font-display: 'Lora', serif;
}

/* ── RESET ── */
#ivpai-root * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── ROOT CONTAINER ── */
#ivpai-root {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  font-family: var(--ivp-font-body);
}

/* ════════════════════════════════════
   TOGGLE BUTTON
════════════════════════════════════ */
#ivpai-toggle {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--ivp-primary), #2C1A10);
  color: var(--ivp-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(74,55,40,0.35), 0 0 0 0 rgba(196,154,90,0.4);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: ivp-pulse 3s infinite;
  position: relative;
}

#ivpai-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(74,55,40,0.45), 0 0 0 6px rgba(196,154,90,0.15);
  animation: none;
}

#ivpai-toggle svg {
  width: 26px;
  height: 26px;
  stroke: var(--ivp-accent);
}

@keyframes ivp-pulse {
  0%, 100% { box-shadow: 0 6px 24px rgba(74,55,40,0.35), 0 0 0 0 rgba(196,154,90,0.4); }
  50%       { box-shadow: 0 6px 24px rgba(74,55,40,0.35), 0 0 0 10px rgba(196,154,90,0); }
}

/* ════════════════════════════════════
   CHAT WINDOW
════════════════════════════════════ */
#ivpai-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 370px;
  max-height: 560px;
  background: var(--ivp-white);
  border-radius: var(--ivp-radius);
  box-shadow: var(--ivp-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s ease;
  border: 1px solid rgba(196,154,90,0.15);
}

#ivpai-window.ivpai-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── HEADER ── */
#ivpai-header {
  background: linear-gradient(135deg, var(--ivp-primary) 0%, #2C1A10 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  border-bottom: 2px solid var(--ivp-accent);
}

#ivpai-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23C49A5A' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

#ivpai-avatar {
  width: 40px;
  height: 40px;
  background: rgba(196,154,90,0.15);
  border: 1.5px solid rgba(196,154,90,0.4);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
  z-index: 1;
}

#ivpai-header-info {
  flex: 1;
  z-index: 1;
}

#ivpai-header-name {
  display: block;
  font-family: var(--ivp-font-display);
  font-size: 1rem;
  font-weight: 600;
  color: var(--ivp-accent);
  letter-spacing: 0.02em;
}

#ivpai-header-subtitle {
  display: block;
  font-size: 0.68rem;
  color: rgba(250,247,242,0.6);
  letter-spacing: 0.04em;
  margin-top: 1px;
  font-weight: 300;
}

#ivpai-close-btn {
  background: none;
  border: none;
  color: rgba(250,247,242,0.5);
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  z-index: 1;
}
#ivpai-close-btn:hover { color: #fff; background: rgba(255,255,255,0.1); }

/* ── MESSAGES ── */
#ivpai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--ivp-light);
  scroll-behavior: smooth;
}

#ivpai-messages::-webkit-scrollbar { width: 4px; }
#ivpai-messages::-webkit-scrollbar-track { background: transparent; }
#ivpai-messages::-webkit-scrollbar-thumb { background: rgba(74,55,40,0.15); border-radius: 4px; }

/* ── INDIVIDUAL MESSAGE BUBBLES ── */
.ivpai-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  animation: ivp-fadein 0.25s ease;
}

@keyframes ivp-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ivpai-msg-bot {
  align-self: flex-start;
  background: var(--ivp-bubble-bot);
  color: var(--ivp-text);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(196,154,90,0.12);
}

.ivpai-msg-user {
  align-self: flex-end;
  background: var(--ivp-bubble-user);
  color: #FAF7F2;
  border-bottom-right-radius: 4px;
}

/* ── TYPING INDICATOR ── */
.ivpai-typing {
  align-self: flex-start;
  background: var(--ivp-bubble-bot);
  border: 1px solid rgba(196,154,90,0.12);
  padding: 10px 16px;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.ivpai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ivp-accent);
  animation: ivp-bounce 1.2s infinite;
}
.ivpai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ivpai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ivp-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* ── INPUT AREA ── */
#ivpai-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: var(--ivp-white);
  border-top: 1px solid rgba(196,154,90,0.15);
}

#ivpai-input {
  flex: 1;
  border: 1.5px solid rgba(74,55,40,0.15);
  border-radius: 12px;
  padding: 9px 13px;
  font-family: var(--ivp-font-body);
  font-size: 0.875rem;
  color: var(--ivp-text);
  background: var(--ivp-light);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s;
}

#ivpai-input:focus {
  border-color: var(--ivp-accent);
}

#ivpai-input::placeholder { color: var(--ivp-muted); }

#ivpai-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--ivp-primary), #2C1A10);
  color: var(--ivp-accent);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s, opacity 0.2s;
}

#ivpai-send:hover { transform: scale(1.08); }
#ivpai-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
#ivpai-send svg { width: 18px; height: 18px; fill: var(--ivp-accent); }

/* ── FOOTER NOTE ── */
#ivpai-footer-note {
  text-align: center;
  font-size: 0.62rem;
  color: var(--ivp-muted);
  padding: 4px 0 8px;
  letter-spacing: 0.04em;
  background: var(--ivp-white);
}

/* ── RESPONSIVE ── */
@media (max-width: 420px) {
  #ivpai-root { bottom: 16px; right: 16px; }
  #ivpai-window { width: calc(100vw - 32px); right: 0; }
}
