/* ===== AI Agent — Floating Chat Widget ===== */
@import url('https://fonts.googleapis.com/css2?family=Permanent+Marker&display=swap');

.ai-agent-wrapper {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  font-family: 'Source Sans 3', 'Helvetica Neue', Arial, sans-serif;
}

/* ---- Floating Button ---- */
.ai-agent-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #1a1a2e;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  z-index: 2;
}

.ai-agent-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.35);
}

.ai-agent-btn svg {
  width: 34px;
  height: 34px;
}

/* ---- Thought Bubble ---- */
.ai-thought-bubble {
  position: absolute;
  bottom: 88px;
  right: 0;
  background: #fff;
  border: 3.5px solid #222;
  border-radius: 26px;
  padding: 18px 22px;
  min-width: 210px;
  max-width: 250px;
  text-align: center;
  font-family: 'Permanent Marker', cursive;
  font-weight: 400;
  font-size: 1rem;
  color: #1a1a2e;
  line-height: 1.55;
  animation: thoughtFadeIn 0.6s ease;
  pointer-events: none;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.08));
}

.ai-thought-dot-0 {
  position: absolute;
  bottom: 80px;
  right: 32px;
  width: 20px;
  height: 20px;
  background: #fff;
  border: 3.5px solid #222;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.ai-thought-dot-1 {
  position: absolute;
  bottom: 66px;
  right: 23px;
  width: 13px;
  height: 13px;
  background: #fff;
  border: 3px solid #222;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.ai-thought-dot-2 {
  position: absolute;
  bottom: 55px;
  right: 16px;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 2px solid #222;
  border-radius: 50%;
  z-index: 3;
  pointer-events: none;
}

.ai-thought-bubble.hidden {
  display: none;
}

.ai-thought-dot-0.hidden,
.ai-thought-dot-1.hidden,
.ai-thought-dot-2.hidden {
  display: none;
}

@keyframes thoughtFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Chat Panel ---- */
.ai-chat-panel {
  position: absolute;
  bottom: 88px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border: 2px solid #dee2e6;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ai-chat-panel.active {
  display: flex;
}

/* Header */
.ai-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: #1a1a2e;
  color: #fff;
}

.ai-chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-avatar {
  width: 32px;
  height: 32px;
  background: #2d2d4e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-chat-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.ai-chat-status {
  font-size: 0.75rem;
  opacity: 0.7;
}

.ai-chat-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
  transition: background 0.2s;
  line-height: 1;
}

.ai-chat-close:hover {
  background: rgba(255,255,255,0.15);
}

/* Progress Bar */
.ai-loading-bar {
  padding: 10px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #eee;
  display: none;
}

.ai-loading-bar.active {
  display: block;
}

.ai-loading-text {
  font-size: 0.78rem;
  color: #666;
  margin-bottom: 5px;
}

.ai-progress-track {
  height: 4px;
  background: #e9ecef;
  border-radius: 2px;
  overflow: hidden;
}

.ai-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #333, #555);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

/* Messages */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 260px;
  max-height: 340px;
}

.ai-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-msg-bot {
  background: #f1f3f4;
  color: #222;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.ai-msg-user {
  background: #1a1a2e;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ai-msg-system {
  background: #fff3cd;
  color: #856404;
  align-self: center;
  text-align: center;
  font-size: 0.8rem;
  padding: 8px 14px;
  border-radius: 8px;
  max-width: 95%;
}

/* Typing indicator */
.ai-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  margin: 0 2px;
  animation: typingBounce 1.2s infinite;
}

.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Input */
.ai-chat-input {
  display: flex;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  gap: 8px;
}

.ai-chat-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  font-size: 0.88rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}

.ai-chat-input input:focus {
  border-color: #555;
}

.ai-chat-input button {
  padding: 10px 18px;
  background: #1a1a2e;
  color: #fff;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.2s;
  font-family: inherit;
}

.ai-chat-input button:hover {
  background: #333;
}

.ai-chat-input button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .ai-agent-wrapper {
    bottom: 14px;
    right: 14px;
  }

  .ai-agent-btn {
    width: 48px;
    height: 48px;
  }

  .ai-agent-btn svg {
    width: 20px;
    height: 20px;
  }

  .ai-thought-bubble {
    min-width: 135px;
    max-width: 160px;
    font-size: 0.78rem;
    padding: 10px 12px;
    border-radius: 18px;
    bottom: 64px;
  }

  .ai-thought-dot-0 {
    width: 13px;
    height: 13px;
    bottom: 54px;
    right: 22px;
  }

  .ai-thought-dot-1 {
    width: 9px;
    height: 9px;
    bottom: 44px;
    right: 16px;
  }

  .ai-thought-dot-2 {
    width: 6px;
    height: 6px;
    bottom: 36px;
    right: 11px;
  }

  .ai-chat-panel {
    width: calc(100vw - 28px);
    right: -7px;
    bottom: 64px;
    max-height: 70vh;
  }

  .ai-chat-messages {
    max-height: 50vh;
  }
}
