/* ============================================================
   AGAHL Post Chatbot — aghl-chatbot.css
   Brand: #111111 (red) · white · black
   ============================================================ */

:root {
  --aghl-red:       #111111;
  --aghl-red-dark:  #333333;
  --aghl-white:     #ffffff;
  --aghl-black:     #111111;
  --aghl-gray-bg:   #f5f5f5;
  --aghl-gray-text: #555555;
  --aghl-radius:    16px;
  --aghl-shadow:    0 8px 32px rgba(0, 0, 0, 0.18);
  --aghl-font:      'Georgia', 'Times New Roman', serif;
  --aghl-font-ui:   system-ui, -apple-system, sans-serif;
  --aghl-width:     360px;
  --aghl-z:         99999;
}

/* ── Widget wrapper ─────────────────────────────────────────── */
#aghl-chat-widget {
  position: fixed;
  bottom: 28px;
  left: 28px;
  z-index: var(--aghl-z);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  font-family: var(--aghl-font-ui);
}

/* ── Toggle bubble button ───────────────────────────────────── */
#aghl-chat-toggle {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--aghl-red);
  color: var(--aghl-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}

#aghl-chat-toggle:hover {
  background: var(--aghl-red-dark);
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.35);
}

#aghl-chat-toggle:active {
  transform: scale(0.96);
}

#aghl-chat-toggle svg {
  width: 24px;
  height: 24px;
}

.aghl-icon { display: flex; }
.aghl-icon[hidden] { display: none; }

/* ── Chat panel ─────────────────────────────────────────────── */
#aghl-chat-panel {
  width: var(--aghl-width);
  max-height: 520px;
  background: var(--aghl-white);
  border-radius: var(--aghl-radius);
  box-shadow: var(--aghl-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.08);

  /* Slide-in animation */
  animation: aghl-slide-up 0.28s cubic-bezier(0.22, 1, 0.36, 1) both;
}

#aghl-chat-panel[hidden] {
  display: none;
}

@keyframes aghl-slide-up {
  from { opacity: 0; transform: translateY(18px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* ── Header ─────────────────────────────────────────────────── */
#aghl-chat-header {
  background: var(--aghl-red);
  color: var(--aghl-white);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.aghl-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}

.aghl-header-text strong {
  font-size: 15px;
  font-family: var(--aghl-font);
  letter-spacing: 0.01em;
}

.aghl-header-text span {
  font-size: 12px;
  opacity: 0.88;
}

/* ── Messages area ──────────────────────────────────────────── */
#aghl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

/* Scrollbar */
#aghl-chat-messages::-webkit-scrollbar { width: 4px; }
#aghl-chat-messages::-webkit-scrollbar-track { background: transparent; }
#aghl-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

/* Individual message bubbles */
.aghl-msg {
  max-width: 86%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  animation: aghl-pop 0.2s ease both;
}

@keyframes aghl-pop {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

.aghl-msg--user {
  background: var(--aghl-red);
  color: var(--aghl-white);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-family: var(--aghl-font-ui);
}

.aghl-msg--bot {
  background: var(--aghl-gray-bg);
  color: var(--aghl-black);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  font-family: var(--aghl-font);
  font-size: 14px;
}

.aghl-msg--error {
  background: #f5f5f5;
  color: #333;
  border: 1px solid #ddd;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  font-size: 13px;
  font-style: italic;
}

.aghl-msg--error a {
  color: #111111;
  background: #ffe0e0;
  padding: 1px 5px;
  border-radius: 3px;
  text-decoration: none;
  font-weight: 600;
}

.aghl-msg--error a:hover {
  background: #ff214f;
  color: #ffffff;
}

/* Typing indicator */
.aghl-typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 10px 14px;
  background: var(--aghl-gray-bg);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.aghl-typing span {
  width: 7px;
  height: 7px;
  background: var(--aghl-red);
  border-radius: 50%;
  animation: aghl-bounce 1.2s infinite ease-in-out;
  opacity: 0.7;
}

.aghl-typing span:nth-child(1) { animation-delay: 0s; }
.aghl-typing span:nth-child(2) { animation-delay: 0.18s; }
.aghl-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes aghl-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.7; }
  30%           { transform: translateY(-5px); opacity: 1;   }
}

/* Welcome message */
.aghl-msg--welcome {
  background: transparent;
  color: var(--aghl-gray-text);
  font-size: 13px;
  font-style: italic;
  text-align: center;
  align-self: center;
  padding: 4px 0;
  max-width: 100%;
}

/* ── Input area ─────────────────────────────────────────────── */
#aghl-chat-input-area {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #f0f0f0;
  background: var(--aghl-white);
  flex-shrink: 0;
}

#aghl-chat-input {
  flex: 1;
  resize: none;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: var(--aghl-font-ui);
  color: var(--aghl-black);
  background: var(--aghl-gray-bg);
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.2s ease;
}

#aghl-chat-input:focus {
  border-color: var(--aghl-red);
  background: var(--aghl-white);
}

#aghl-chat-input::placeholder {
  color: #aaa;
  font-style: italic;
}

#aghl-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--aghl-black);
  color: var(--aghl-white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  line-height: 1;
  transition: background 0.2s ease, transform 0.15s ease;
}

#aghl-chat-send:hover {
  background: #333;
  transform: scale(1.07);
}

#aghl-chat-send:active {
  transform: scale(0.94);
}

#aghl-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

#aghl-chat-widget .aghl-msg--bot a,
#aghl-chat-widget .aghl-msg--error a {
  color: #ff214f !important;
  background: #fff0f2 !important;
  padding: 1px 6px !important;
  border-radius: 3px !important;
  text-decoration: none !important;
  font-weight: 600 !important;
  display: inline-block !important;
}

#aghl-chat-widget .aghl-msg--bot a:hover,
#aghl-chat-widget .aghl-msg--error a:hover {
  background: #ff214f !important;
  color: #ffffff !important;
}

/* send button uses HTML entity arrow, no SVG needed */

/* ── Mobile ─────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #aghl-chat-widget {
    bottom: 16px;
    left: 16px;
    right: 16px;
    align-items: flex-start;
  }

  #aghl-chat-panel {
    width: 100%;
    max-height: 72vh;
  }
}
