/* AREG Chat Companion — bottom-right bubble + panel */
#areg-chat-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* ---- BUBBLE (collapsed state) ---- */
#areg-chat-bubble {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #1e3a5f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  border: none;
}
#areg-chat-bubble:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0,0,0,0.3);
}
#areg-chat-bubble svg {
  width: 28px;
  height: 28px;
  fill: #fff;
}
#areg-chat-bubble .areg-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e67e22;
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  min-width: 18px;
  text-align: center;
  border: 2px solid #fff;
}

/* ---- PANEL (expanded state) ---- */
#areg-chat-panel {
  width: 380px;
  height: 600px;
  max-height: calc(100vh - 40px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);
}
#areg-chat-panel.open { display: flex; }

/* Panel header */
.areg-chat-header {
  background: #1e3a5f;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.areg-chat-header-title {
  font-weight: 600;
  font-size: 15px;
}
.areg-chat-header-title-sub {
  font-size: 12px;
  opacity: 0.85;
  font-weight: 400;
  margin-top: 2px;
}
.areg-chat-header-actions { display: flex; gap: 8px; }
.areg-chat-header-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.8;
}
.areg-chat-header-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }
.areg-chat-header-btn svg { width: 16px; height: 16px; fill: #fff; }

/* Filter chips bar */
.areg-chat-chips {
  padding: 10px 14px;
  border-bottom: 1px solid #eee;
  background: #f9f9fa;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  min-height: 0;
  max-height: 80px;
  overflow-y: auto;
}
.areg-chat-chips:empty { display: none; }
.areg-chip {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  color: #333;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.areg-chip-remove {
  cursor: pointer;
  opacity: 0.5;
  font-size: 14px;
  line-height: 1;
  padding: 0 2px;
}
.areg-chip-remove:hover { opacity: 1; color: #c00; }

/* Message thread */
.areg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.areg-msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.areg-msg-user {
  align-self: flex-end;
  background: #1e3a5f;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.areg-msg-ai {
  align-self: flex-start;
  background: #f0f1f3;
  color: #222;
  border-bottom-left-radius: 4px;
}
.areg-msg-ai strong { font-weight: 600; color: #1e3a5f; }
.areg-msg-ai a {
  color: #e67e22;
  font-weight: 600;
  text-decoration: none;
}
.areg-msg-ai a:hover { text-decoration: underline; }

/* Typing indicator */
.areg-typing {
  align-self: flex-start;
  background: #f0f1f3;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  gap: 4px;
}
.areg-typing-dot {
  width: 7px;
  height: 7px;
  background: #999;
  border-radius: 50%;
  animation: areg-bounce 1.4s infinite ease-in-out;
}
.areg-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.areg-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes areg-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input area */
.areg-chat-input-wrap {
  padding: 10px 14px;
  border-top: 1px solid #eee;
  background: #fff;
  flex-shrink: 0;
}
.areg-chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.areg-chat-input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 100px;
  min-height: 40px;
  outline: none;
  line-height: 1.4;
}
.areg-chat-input:focus { border-color: #1e3a5f; }
.areg-chat-send {
  background: #e67e22;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.areg-chat-send:hover { background: #d35400; }
.areg-chat-send:disabled { background: #ccc; cursor: not-allowed; }
.areg-chat-send svg { width: 18px; height: 18px; fill: #fff; }

/* Bottom bar with count + CTA */
.areg-chat-bottom {
  padding: 8px 14px;
  background: #f9f9fa;
  border-top: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  flex-shrink: 0;
}
.areg-chat-bottom:empty { display: none; }
.areg-chat-count {
  color: #555;
  font-weight: 500;
}
.areg-chat-count strong { color: #1e3a5f; }
.areg-chat-view-btn {
  background: #e67e22;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
}
.areg-chat-view-btn:hover { background: #d35400; }

/* Inline contact form */
.areg-contact-form {
  align-self: stretch;
  background: #fff8ed;
  border: 1px solid #f4c28a;
  border-radius: 10px;
  padding: 12px;
  margin: 4px 0;
}
.areg-contact-form h4 { margin: 0 0 8px; font-size: 14px; color: #1e3a5f; }
.areg-contact-form input, .areg-contact-form textarea {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 7px 10px;
  margin-bottom: 6px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.areg-contact-form button {
  background: #1e3a5f;
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
}
.areg-contact-form button:hover { background: #15294a; }

/* ---- Mobile bottom-sheet ---- */
@media (max-width: 600px) {
  /* Panel slides up from bottom; ~30% of page stays visible above */
  #areg-chat-root { top: auto; bottom: 0; right: 0; left: 0; }
  #areg-chat-panel {
    width: 100%;
    height: 70vh;
    max-height: 70vh;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.18);
  }
  /* Bubble returns to bottom-right when minimized */
  #areg-chat-bubble { margin: 0 16px 16px auto; }
  /* ADA: 44x44 tap targets for header buttons */
  .areg-chat-header-btn { min-width: 44px; min-height: 44px; }
}
