/* ============================================================
   Registered Agency — Chatbot Widget CSS
   ============================================================ */

/* ── Toggle button ───────────────────────────────────────── */
#chatbot-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1050;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--color-red);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 24px rgba(195, 30, 37, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
#chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(195, 30, 37, 0.55);
}
#chatbot-toggle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.chatbot-btn-icon { flex-shrink: 0; }

/* Notification badge */
.chatbot-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: #fff;
  color: var(--color-red);
  font-size: 0.7rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  border: 2px solid var(--color-red);
}
.chatbot-badge.hidden { display: none; }

/* ── Chat window ─────────────────────────────────────────── */
#chatbot-window {
  position: fixed;
  bottom: 6rem;
  right: 1.5rem;
  z-index: 1049;
  width: 370px;
  max-width: calc(100vw - 2rem);
  height: 530px;
  max-height: calc(100vh - 8rem);
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 16px 60px rgba(3, 30, 80, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Animation */
  transform-origin: bottom right;
  animation: chatWindowIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#chatbot-window[hidden] { display: none !important; }

@keyframes chatWindowIn {
  from { opacity: 0; transform: scale(0.8) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Header ──────────────────────────────────────────────── */
.chatbot-header {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-navy-mid, #0a2d6e) 100%);
  color: #fff;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.chatbot-header-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chatbot-header-info {
  flex: 1;
  min-width: 0;
}

.chatbot-header-name {
  display: block;
  font-weight: 700;
  font-size: 0.92rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-header-status {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.73rem;
  color: rgba(255,255,255,0.7);
  margin-top: 0.1rem;
}

.chatbot-status-dot {
  width: 7px;
  height: 7px;
  background: #4caf50;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.3);
  animation: pulse-dot 2.5s ease infinite;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 2px rgba(76,175,80,0.3); }
  50%       { box-shadow: 0 0 0 4px rgba(76,175,80,0.15); }
}

.chatbot-header-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 6px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.chatbot-header-close:hover {
  color: #fff;
  background: rgba(255,255,255,0.15);
}

/* ── Messages area ───────────────────────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0.9rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: #dce8f5; border-radius: 4px; }

/* Message bubbles */
.chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: 88%;
  animation: msgIn 0.2s ease forwards;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.chat-msg.bot { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: white;
  font-size: 0.7rem;
}

.chat-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.bot .chat-bubble {
  background: var(--color-light-blue, #f2f6ff);
  color: var(--color-text, #1a1a2e);
  border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: var(--color-navy);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-bubble a {
  color: var(--color-red);
  text-decoration: underline;
}
.chat-msg.user .chat-bubble a { color: #a8c4e8; }

/* Typing indicator */
.chat-msg.typing .chat-bubble {
  padding: 0.7rem 1rem;
}
.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-muted, #6b7a99);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1; }
}

/* ── Quick replies ───────────────────────────────────────── */
.chatbot-quick-replies {
  padding: 0 0.9rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  flex-shrink: 0;
  min-height: 0;
  transition: opacity 0.2s;
}

.qr-btn {
  background: #fff;
  border: 1.5px solid var(--color-navy);
  color: var(--color-navy);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.qr-btn:hover {
  background: var(--color-navy);
  color: #fff;
}
.qr-btn.red {
  border-color: var(--color-red);
  color: var(--color-red);
}
.qr-btn.red:hover {
  background: var(--color-red);
  color: #fff;
}

/* ── Input area ──────────────────────────────────────────── */
.chatbot-input-area {
  border-top: 1px solid var(--color-border, #dce8f5);
  padding: 0.7rem 0.9rem 0.5rem;
  flex-shrink: 0;
}

#chatbot-form {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  border: 1.5px solid var(--color-border, #dce8f5);
  border-radius: 22px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  color: var(--color-text, #1a1a2e);
  outline: none;
  transition: border-color 0.2s;
  min-height: 0;
  background: #fff;
}
.chatbot-input:focus {
  border-color: var(--color-navy);
}
.chatbot-input::placeholder { color: #aab; }

.chatbot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--color-red);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.chatbot-send-btn:hover {
  background: var(--color-red-dark, #a01820);
  transform: scale(1.05);
}
.chatbot-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.chatbot-disclaimer {
  font-size: 0.68rem;
  color: var(--color-text-muted, #6b7a99);
  text-align: center;
  margin: 0.35rem 0 0;
}
.chatbot-disclaimer a {
  color: var(--color-text-muted, #6b7a99);
  text-decoration: underline;
}

/* ── Ticket quick-reply button ───────────────────────────── */
.qr-btn.ticket {
  border-color: #7b1fa2;
  color: #7b1fa2;
}
.qr-btn.ticket:hover {
  background: #7b1fa2;
  color: #fff;
}

/* ── Ticket form bubble ──────────────────────────────────── */
.ticket-form-bubble {
  background: var(--color-white);
  border: 1.5px solid var(--color-border, #dce8f5);
  border-radius: 14px;
  padding: 1rem;
  min-width: 240px;
  max-width: 280px;
  box-shadow: 0 2px 12px rgba(3,30,80,0.08);
  animation: msgIn 0.2s ease forwards;
}

.ticket-form-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: #7b1fa2;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 0.85rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border, #dce8f5);
}

.ticket-field {
  margin-bottom: 0.6rem;
}

.ticket-field label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-navy, #031e50);
  margin-bottom: 0.2rem;
}
.ticket-field label span { color: var(--color-red, #c31e25); }

.ticket-field input,
.ticket-field select,
.ticket-field textarea {
  width: 100%;
  border: 1.5px solid var(--color-border, #dce8f5);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font-size: 0.82rem;
  color: var(--color-text, #1a1a2e);
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
}
.ticket-field input:focus,
.ticket-field select:focus,
.ticket-field textarea:focus {
  border-color: #7b1fa2;
  box-shadow: 0 0 0 2px rgba(123,31,162,0.12);
}
.ticket-field textarea {
  resize: vertical;
  min-height: 60px;
}

.ticket-form-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.tk-cancel-btn {
  flex: 1;
  background: none;
  border: 1.5px solid var(--color-border, #dce8f5);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-text-muted, #6b7a99);
  cursor: pointer;
  transition: all 0.15s;
}
.tk-cancel-btn:hover {
  border-color: #aaa;
  color: var(--color-text, #1a1a2e);
}

.tk-submit-btn {
  flex: 2;
  background: #7b1fa2;
  border: none;
  border-radius: 6px;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: background 0.15s;
}
.tk-submit-btn:hover  { background: #6a1b9a; }
.tk-submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.ticket-error {
  font-size: 0.72rem;
  color: var(--color-red, #c31e25);
  margin: 0.4rem 0 0;
  text-align: center;
}

/* ── Date divider ────────────────────────────────────────── */
.chat-date-divider {
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-text-muted, #6b7a99);
  margin: 0.25rem 0;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  #chatbot-window {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
    bottom: 5.5rem;
    height: calc(100vh - 7rem);
  }
  #chatbot-toggle {
    right: 1rem;
    bottom: 1rem;
  }
}
