*,
*:before,
*:after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Container (for both icon and chat box) */
#chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: Arial, sans-serif;
  }
  
  /* Floating icon */
  #chatbot-icon {
    width: 60px;
    height: 60px;
    background-color: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0,0,0,0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    will-change: transform;
    /* Subtle attention-drawing animation while icon is visible (chat closed) */
    animation: chatbotIconFloat 3s ease-in-out infinite, chatbotIconPulse 2.6s ease-in-out infinite;
  }
  #chatbot-icon:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 22px rgba(0,0,0,0.28);
  }
  
  /* Hidden chat box (initially closed) */
  #chatbot-box {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 320px;
    height: 450px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.3);
    overflow: hidden;
    flex-direction: column;
    transform-origin: 90% 100%;
    will-change: transform, opacity;
    /* Play opening animation whenever the box becomes visible */
    animation: chatbotBoxIn 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  
  /* Header */
  #chatbot-header {
    background: var(--color-primary);
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  #chatbot-header button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
  }
  
  /* Chat messages */
  #chat-messages {
    flex: 1;
    height: 330px;
    overflow-y: auto;
    padding: 10px;
    background: #f5f5f5;
  }
  .message {
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
  }
  .user-message {
    background: var(--color-primary);
    color: white;
    margin-left: auto;
  }
  .bot-message {
    background: #e1e1e1;
    color: black;
    margin-right: auto;
  }
  
  /* Input area */
  #chat-input-area {
    display: flex;
    border-top: 1px solid #ccc;
  }
  #chat-input {
    flex: 1;
    border: none;
    padding: 10px;
    outline: none;
  }
  #chat-send {
    border: none;
    background: var(--color-primary);
    color: white;
    padding: 0 15px;
    cursor: pointer;
  }
  #chat-send:hover {
    background: var(--color-primary-dark);
  }
  
  /* Animations */
  @keyframes chatbotIconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
  }
  
  @keyframes chatbotIconPulse {
    0% { box-shadow: 0 8px 18px rgba(0,0,0,0.20), 0 0 0 0 rgba(52,184,193,0.35); }
    70% { box-shadow: 0 10px 22px rgba(0,0,0,0.24), 0 0 0 12px rgba(52,184,193,0); }
    100% { box-shadow: 0 8px 18px rgba(0,0,0,0.20), 0 0 0 0 rgba(52,184,193,0); }
  }
  
  @keyframes chatbotBoxIn {
    0% { opacity: 0; transform: translateY(10px) scale(0.98); box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
    100% { opacity: 1; transform: translateY(0) scale(1); box-shadow: 0 8px 20px rgba(0,0,0,0.30); }
  }
  
  /* Respect reduced motion preferences */
  @media (prefers-reduced-motion: reduce) {
    #chatbot-icon {
      animation: none;
    }
    #chatbot-box {
      animation: none;
    }
  }