/* =============================================================================
   CHAMU AI — Chat Widget Styles
   Integrado ao Design System do Grupo Educacional Chamuanga
   ============================================================================= */

/* ----- Floating Action Button ----- */
#chamu-ai-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9998;
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #5B3FE0 0%, #2F6FED 100%);
  color: #fff;
  border: none;
  border-radius: 56px;
  padding: 13px 22px 13px 16px;
  font-family: var(--font-body, 'Inter', sans-serif);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(91, 63, 224, 0.38), 0 2px 8px rgba(0,0,0,0.12);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), box-shadow 0.22s cubic-bezier(.4,0,.2,1), opacity 0.18s;
  user-select: none;
}

#chamu-ai-fab:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 36px rgba(91, 63, 224, 0.45), 0 4px 12px rgba(0,0,0,0.15);
}

#chamu-ai-fab:active {
  transform: scale(0.97);
}

#chamu-ai-fab .cab-icon {
  font-size: 1.28rem;
  line-height: 1;
  animation: chamu-float 2.6s ease-in-out infinite;
}

@keyframes chamu-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-3px); }
}

#chamu-ai-fab .cab-pulse {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.55);
  animation: chamu-pulse 1.8s infinite;
}

@keyframes chamu-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.55); }
  70%  { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

/* ----- Chat Window Wrapper ----- */
#chamu-ai-chat {
  position: fixed;
  bottom: 98px;
  right: 28px;
  z-index: 9999;
  width: 380px;
  max-width: calc(100vw - 32px);

  /* Altura fixa: ocupa até 75% da viewport, nunca ultrapassa 600px */
  height: min(600px, calc(100dvh - 130px));
  max-height: calc(100dvh - 130px);

  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(11, 31, 58, 0.22), 0 4px 18px rgba(91, 63, 224, 0.14);
  overflow: hidden;
  border: 1px solid rgba(91, 63, 224, 0.13);
  transform-origin: bottom right;
  transform: scale(0.92) translateY(14px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(.4,0,.2,1), opacity 0.25s cubic-bezier(.4,0,.2,1);
}

#chamu-ai-chat.chamu-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

#chamu-ai-chat.chamu-minimized {
  height: 0;
  max-height: 0;
  transform: scale(0.9) translateY(16px);
  opacity: 0;
  pointer-events: none;
}

/* ----- Header ----- */
.chamu-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #0B1F3A 0%, #1a3560 100%);
  color: #fff;
  flex-shrink: 0;
}

.chamu-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5B3FE0, #2F6FED);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(91,63,224,0.35);
}

.chamu-header-info {
  flex: 1;
  min-width: 0;
}

.chamu-header-title {
  font-family: var(--font-heading, 'Poppins', sans-serif);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chamu-header-subtitle {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.65);
  font-weight: 400;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chamu-header-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  color: #22c55e;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 3px;
}

.chamu-header-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  animation: chamu-pulse 1.8s infinite;
}

.chamu-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chamu-header-actions button {
  background: rgba(255,255,255,0.10);
  border: none;
  color: rgba(255,255,255,0.75);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  transition: background 0.18s, color 0.18s;
}

.chamu-header-actions button:hover {
  background: rgba(255,255,255,0.22);
  color: #fff;
}

/* ----- Message List ----- */
.chamu-messages {
  flex: 1 1 0;
  min-height: 0;          /* critical: allows flex child to shrink below content size */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f7f7fb;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.chamu-messages::-webkit-scrollbar { width: 4px; }
.chamu-messages::-webkit-scrollbar-track { background: transparent; }
.chamu-messages::-webkit-scrollbar-thumb { background: rgba(91,63,224,0.25); border-radius: 4px; }

/* Welcome card */
.chamu-welcome {
  background: linear-gradient(135deg, #ede9ff, #e8f0fe);
  border: 1px solid rgba(91,63,224,0.14);
  border-radius: 14px;
  padding: 14px 14px 12px;
  font-size: 0.83rem;
  color: #1a1a40;
  line-height: 1.55;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.chamu-welcome .welcome-icon {
  font-size: 1.4rem;
  flex-shrink: 0;
  margin-top: 1px;
}

/* Message Bubbles */
.chamu-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: chamu-fadein 0.28s ease;
}

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

.chamu-msg.chamu-bot {
  flex-direction: row;
}

.chamu-msg.chamu-user {
  flex-direction: row-reverse;
}

.chamu-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5B3FE0, #2F6FED);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #fff;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.chamu-bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 44px);
}

.chamu-msg.chamu-user .chamu-bubble-wrap {
  align-items: flex-end;
}

.chamu-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 0.84rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.chamu-msg.chamu-bot .chamu-bubble {
  background: #fff;
  border: 1px solid rgba(91,63,224,0.1);
  color: #151B3B;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chamu-msg.chamu-user .chamu-bubble {
  background: linear-gradient(135deg, #5B3FE0, #2F6FED);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 3px 10px rgba(91,63,224,0.22);
}

.chamu-bubble-actions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.chamu-msg:hover .chamu-bubble-actions {
  opacity: 1;
}

.chamu-copy-btn {
  background: rgba(91,63,224,0.08);
  border: none;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 0.69rem;
  color: #5B3FE0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
  font-family: var(--font-body, 'Inter', sans-serif);
}

.chamu-copy-btn:hover {
  background: rgba(91,63,224,0.16);
}

.chamu-copy-btn.copied {
  color: #22c55e;
}

/* Typing indicator */
.chamu-typing {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: chamu-fadein 0.25s ease;
}

.chamu-typing-bubble {
  background: #fff;
  border: 1px solid rgba(91,63,224,0.1);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.chamu-typing-bubble span {
  font-size: 0.74rem;
  color: #5a5f73;
  font-style: italic;
}

.chamu-dots {
  display: flex;
  gap: 3px;
}

.chamu-dots i {
  width: 6px;
  height: 6px;
  background: #5B3FE0;
  border-radius: 50%;
  animation: chamu-bounce 1.2s infinite;
}

.chamu-dots i:nth-child(2) { animation-delay: 0.2s; }
.chamu-dots i:nth-child(3) { animation-delay: 0.4s; }

@keyframes chamu-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* ----- Suggestions Quick Chips ----- */
.chamu-suggestions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 8px 14px 4px;
  background: #f7f7fb;
}

.chamu-chip {
  background: #fff;
  border: 1px solid rgba(91,63,224,0.2);
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 0.73rem;
  color: #5B3FE0;
  cursor: pointer;
  font-family: var(--font-body, 'Inter', sans-serif);
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  white-space: nowrap;
  font-weight: 500;
}

.chamu-chip:hover {
  background: #5B3FE0;
  color: #fff;
  border-color: #5B3FE0;
}

/* ----- Input Area ----- */
.chamu-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  background: #fff;
  border-top: 1px solid rgba(91,63,224,0.08);
  flex-shrink: 0;
}

#chamu-input {
  flex: 1;
  border: 1.5px solid rgba(91,63,224,0.2);
  border-radius: 22px;
  padding: 9px 15px;
  font-size: 0.84rem;
  font-family: var(--font-body, 'Inter', sans-serif);
  color: #151B3B;
  resize: none;
  outline: none;
  line-height: 1.45;
  max-height: 96px;
  overflow-y: auto;
  background: #f7f7fb;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}

#chamu-input:focus {
  border-color: #5B3FE0;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(91,63,224,0.1);
}

#chamu-input::placeholder {
  color: #8C91A5;
}

#chamu-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, #5B3FE0, #2F6FED);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.98rem;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(91,63,224,0.28);
  transition: transform 0.18s, box-shadow 0.18s, opacity 0.18s;
}

#chamu-send-btn:hover:not(:disabled) {
  transform: scale(1.08);
  box-shadow: 0 6px 18px rgba(91,63,224,0.38);
}

#chamu-send-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ----- Footer Note ----- */
.chamu-footer-note {
  padding: 5px 12px 8px;
  text-align: center;
  font-size: 0.66rem;
  color: #8C91A5;
  background: #fff;
  border-top: 1px solid rgba(91,63,224,0.05);
  flex-shrink: 0;
}

.chamu-footer-note a {
  color: #5B3FE0;
  text-decoration: none;
}

/* ----- Error state ----- */
.chamu-error-bubble {
  background: #fff2f2;
  border-color: rgba(220,38,38,0.2);
  color: #b91c1c;
}

/* ----- Responsive (mobile) ----- */
@media (max-width: 768px) {
  #chamu-ai-chat {
    right: 12px !important;
    left: 12px !important;
    bottom: 74px !important;
    width: auto !important;
    max-width: 100% !important;
    height: min(520px, calc(100dvh - 145px)) !important;
    max-height: calc(100dvh - 145px) !important;
    z-index: 9999 !important;
  }

  #chamu-ai-fab {
    right: 16px !important;
    bottom: 74px !important;
    padding: 10px 16px 10px 12px !important;
    font-size: 0.84rem !important;
    z-index: 9995 !important;
  }
}

