/* =================================================
   WEBAIFACTORY DESIGN SYSTEM (CSS VARIABLES)
================================================= */
:root {
  --waif-primary: #4f46e5;
  --waif-secondary: #6366f1;
  --waif-accent: #22d3ee;

  --waif-bg-main: #f8fafc;
  --waif-bg-soft: #eef2ff;

  --waif-text-main: #0f172a;
  --waif-text-muted: #475569;

  --waif-user-bubble: #4f46e5;
  --waif-bot-bubble: #e0e7ff;

  --waif-radius: 14px;
  --waif-shadow: 0 10px 30px rgba(79, 70, 229, 0.25);
}

/* RESET */
#ai-chat-root * {
  box-sizing: border-box;
  font-family: system-ui, -apple-system, BlinkMacSystemFont;
}

/* =================================================
   CHAT BUBBLE (FLOATING)
================================================= */
.ai-chat-bubble {
  position: fixed;
  right: 20px;
  bottom: 20px;

  width: 56px;
  height: 56px;
  border-radius: 50%;

  background: linear-gradient(
    135deg,
    var(--waif-primary),
    var(--waif-secondary)
  );
  color: #fff;
  font-size: 24px;

  display: flex;
  align-items: center;
  justify-content: center;

  cursor: pointer;
  z-index: 999999;

  box-shadow: var(--waif-shadow);
  transition: transform 0.2s ease;
}

.ai-chat-bubble:hover {
  transform: scale(1.08);
}

/* =================================================
   CHAT WIDGET
================================================= */
.ai-chat-widget {
  position: fixed;
  right: 20px;
  bottom: 90px;

  width: 320px;
  height: 420px;

  background: #fff;
  border-radius: var(--waif-radius);
  box-shadow: var(--waif-shadow);

  display: none;
  flex-direction: column;
  overflow: hidden;

  z-index: 999999;
}

.ai-chat-widget.open {
  display: flex;
}

/* =================================================
   HEADER
================================================= */
.ai-chat-header {
  padding: 12px;
  background: linear-gradient(
    135deg,
    var(--waif-primary),
    var(--waif-secondary)
  );
  color: #fff;

  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-chat-close {
  cursor: pointer;
  font-size: 18px;
}

/* =================================================
   MESSAGE AREA
================================================= */
.ai-chat-messages {
  flex: 1;
  padding: 10px;
  background: var(--waif-bg-main);
  overflow-y: auto;
}

/* MESSAGE BUBBLE */
.ai-msg {
  max-width: 80%;
  padding: 8px 12px;
  margin-bottom: 8px;

  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;

  word-wrap: break-word;
  animation: fadeIn 0.15s ease-out;
}

.ai-msg.user {
  margin-left: auto;
  background: var(--waif-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg.bot {
  margin-right: auto;
  background: var(--waif-bot-bubble);
  color: var(--waif-text-main);
  border-bottom-left-radius: 4px;
}

/* =================================================
   INPUT AREA
================================================= */
.ai-chat-input {
  display: flex;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.ai-chat-input input {
  flex: 1;
  border: none;
  padding: 10px;
  outline: none;
  color: var(--waif-text-main);
}

.ai-chat-input button {
  border: none;
  padding: 0 16px;
  background: var(--waif-primary);
  color: #fff;
  cursor: pointer;
}

/* =================================================
   LOADING
================================================= */
.ai-loading {
  font-size: 12px;
  color: var(--waif-text-muted);
  margin-bottom: 6px;
}

/* =================================================
   ANIMATION
================================================= */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =================================================
   MOBILE RESPONSIVE
================================================= */
@media (max-width: 480px) {
  .ai-chat-widget {
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}
