/* ── ADC AI Assistant Chat Widget ────────────────────────────────────────── */

:root {
  --chat-primary:    #0d2044;
  --chat-accent:     #c9a84c;
  --chat-accent2:    #e8c97a;
  --chat-bg:         #ffffff;
  --chat-user-bg:    #0d2044;
  --chat-user-text:  #ffffff;
  --chat-bot-bg:     #f4f6fa;
  --chat-bot-text:   #1a1a2e;
  --chat-radius:     18px;
  --chat-shadow:     0 8px 40px rgba(13,32,68,0.22);
  --chat-z:          9999;
}

/* ── Toggle button ───────────────────────────────────────────────────────── */
/* Animations defined before they're used */
@keyframes adc-bounce-in {
  0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
  60%  { transform: scale(1.18) rotate(3deg); opacity: 1; }
  80%  { transform: scale(0.95); }
  100% { transform: scale(1); }
}
@keyframes adc-pulse {
  0%   { box-shadow: 0 6px 24px rgba(13,32,68,0.35), 0 0 0 0 rgba(201,168,76,0.9), 0 0 0 0 rgba(201,168,76,0.4); }
  50%  { box-shadow: 0 6px 24px rgba(13,32,68,0.35), 0 0 0 16px rgba(201,168,76,0.3), 0 0 0 32px rgba(201,168,76,0.1); }
  100% { box-shadow: 0 6px 24px rgba(13,32,68,0.35), 0 0 0 32px rgba(201,168,76,0), 0 0 0 52px rgba(201,168,76,0); }
}

#adc-chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  box-sizing: border-box;
  overflow: hidden;
  /* bounce-in runs once; pulse loops after 2s */
  animation: adc-bounce-in 0.55s cubic-bezier(.34,1.56,.64,1) 0.6s both,
             adc-pulse 2.6s ease-out 2s infinite;
  /* transition only for hover scale — does NOT restart animations */
  transition: transform 0.18s ease, filter 0.18s ease;
}
#adc-chat-toggle:hover {
  transform: scale(1.1);
  filter: brightness(1.15);
}
#adc-chat-toggle.open {
  animation: none;
  transform: scale(1);
  filter: none;
}

/* Logo image fills the button */
#adc-chat-toggle .icon-chat {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
  display: block;
}
#adc-chat-toggle .icon-close {
  display: none;
  font-size: 26px;
  color: #e8c97a;
  pointer-events: none;
  line-height: 1;
}
#adc-chat-toggle.open {
  background: linear-gradient(145deg, #162e5a, #0d2044);
  border: 3px solid #c9a84c;
  overflow: visible;
  box-shadow: 0 6px 28px rgba(13,32,68,0.45);
}
#adc-chat-toggle.open .icon-chat {
  display: none;
}
#adc-chat-toggle.open .icon-close {
  display: inline-block;
}

/* ── Greeting speech bubble ──────────────────────────────────────────────── */
@keyframes adc-bubble-in {
  0%   { opacity: 0; transform: scale(0.7) translateY(8px); }
  60%  { opacity: 1; transform: scale(1.05) translateY(-2px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes adc-bubble-out {
  0%   { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.85) translateY(6px); }
}
#adc-chat-bubble {
  position: fixed;
  bottom: 108px;
  right: 24px;
  z-index: 99998;
  background: #ffffff;
  color: #0d2044;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 20px 20px 4px 20px;
  box-shadow: 0 4px 20px rgba(13,32,68,0.18);
  border: 1.5px solid rgba(201,168,76,0.4);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  max-width: 220px;
}
/* Tail pointing toward button */
#adc-chat-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 18px;
  border: 5px solid transparent;
  border-top-color: #ffffff;
  filter: drop-shadow(0 2px 2px rgba(13,32,68,0.1));
}
#adc-chat-bubble.adc-bubble-show {
  animation: adc-bubble-in 0.4s cubic-bezier(.34,1.56,.64,1) forwards;
}
#adc-chat-bubble.adc-bubble-hide {
  animation: adc-bubble-out 0.35s ease forwards;
}

/* Notification dot */
#adc-chat-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #e63946;
  border-radius: 50%;
  border: 2px solid #fff;
  display: none;
}
@keyframes adc-dot-ping {
  0%   { transform: scale(1); opacity: 1; }
  70%  { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(2.2); opacity: 0; }
}
#adc-chat-dot.visible {
  display: block;
  animation: adc-dot-ping 1.4s ease-out infinite;
}

/* ── Chat panel ──────────────────────────────────────────────────────────── */
#adc-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 99998;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  border: 1px solid rgba(13,32,68,0.1);
}
#adc-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#adc-chat-header {
  background: var(--chat-primary);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#adc-chat-header-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid var(--chat-accent);
  object-fit: cover;
  flex-shrink: 0;
  display: block;
}
#adc-chat-header-info {
  flex: 1;
}
#adc-chat-header-title {
  font-family: 'Playfair Display', 'Georgia', serif;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--chat-accent2);
  line-height: 1.2;
  display: flex;
  align-items: center;
  gap: 6px;
}
.adc-title-logo {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  vertical-align: middle;
}
#adc-chat-header-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.6);
  margin-top: 2px;
}
#adc-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.55);
}
#adc-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4caf50;
  flex-shrink: 0;
}

/* ── Language pills ──────────────────────────────────────────────────────── */
#adc-chat-langs {
  background: rgba(13,32,68,0.04);
  padding: 6px 14px;
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(13,32,68,0.07);
}
.adc-lang-pill {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid rgba(13,32,68,0.18);
  background: transparent;
  color: #555;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.adc-lang-pill:hover,
.adc-lang-pill.active {
  background: var(--chat-primary);
  color: var(--chat-accent2);
  border-color: var(--chat-primary);
}

/* ── Messages area ───────────────────────────────────────────────────────── */
#adc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
#adc-chat-messages::-webkit-scrollbar { width: 4px; }
#adc-chat-messages::-webkit-scrollbar-track { background: transparent; }
#adc-chat-messages::-webkit-scrollbar-thumb { background: rgba(13,32,68,0.15); border-radius: 4px; }

/* Individual messages */
.adc-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  animation: adc-msg-in 0.2s ease;
}
@keyframes adc-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.adc-msg.user {
  background: var(--chat-user-bg);
  color: var(--chat-user-text);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.adc-msg.bot {
  background: var(--chat-bot-bg);
  color: var(--chat-bot-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.adc-msg.bot.rtl,
.adc-msg.user.rtl {
  direction: rtl;
  text-align: right;
  font-family: 'Scheherazade New', 'Noto Naskh Arabic', serif;
  font-size: 1rem;
  line-height: 1.9;
}

/* Typing indicator */
.adc-typing {
  background: var(--chat-bot-bg);
  color: #888;
  align-self: flex-start;
  padding: 10px 16px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}
.adc-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-primary);
  opacity: 0.4;
  animation: adc-bounce 1.2s infinite;
}
.adc-typing span:nth-child(2) { animation-delay: 0.2s; }
.adc-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes adc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Welcome message */
.adc-welcome {
  text-align: center;
  padding: 10px 6px 4px;
}
.adc-welcome-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2.5px solid var(--chat-accent);
  margin: 0 auto 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(13,32,68,0.18);
}
.adc-welcome-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.adc-welcome h4 {
  font-family: 'Playfair Display', serif;
  font-size: 0.95rem;
  color: var(--chat-primary);
  margin: 0 0 6px;
}
.adc-welcome p {
  font-size: 0.78rem;
  color: #666;
  margin: 0 0 12px;
  line-height: 1.5;
}

/* Quick reply chips */
.adc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  padding: 0 4px 4px;
}
.adc-chip {
  font-size: 0.72rem;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--chat-primary);
  background: transparent;
  color: var(--chat-primary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.adc-chip:hover {
  background: var(--chat-primary);
  color: var(--chat-accent2);
}

/* ── Input area ──────────────────────────────────────────────────────────── */
#adc-chat-footer {
  padding: 12px 12px 14px;
  border-top: 1px solid rgba(13,32,68,0.07);
  background: #fff;
  flex-shrink: 0;
}
#adc-chat-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
#adc-chat-input {
  flex: 1;
  border: 1.5px solid rgba(13,32,68,0.18);
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 0.875rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  color: #1a1a2e;
  background: #f9fafc;
  transition: border-color 0.2s;
}
#adc-chat-input:focus {
  border-color: var(--chat-primary);
  background: #fff;
}
#adc-chat-input.rtl {
  direction: rtl;
  text-align: right;
  font-family: 'Scheherazade New', 'Noto Naskh Arabic', serif;
  font-size: 1rem;
}
#adc-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chat-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
}
#adc-chat-send:hover {
  background: #1a3a6e;
  transform: scale(1.05);
}
#adc-chat-send:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
}
#adc-chat-send i {
  font-size: 15px;
  color: #fff;
}
#adc-chat-footer-note {
  text-align: center;
  font-size: 0.65rem;
  color: #aaa;
  margin-top: 6px;
}

/* ── Error banner ────────────────────────────────────────────────────────── */
#adc-chat-error {
  display: none;
  margin: 0 14px 8px;
  padding: 8px 12px;
  background: #fff3f3;
  border: 1px solid #ffcccc;
  border-radius: 8px;
  font-size: 0.75rem;
  color: #c0392b;
  flex-shrink: 0;
}

/* ── Mobile adjustments ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #adc-chat-panel {
    right: 12px;
    bottom: 88px;
    width: calc(100vw - 24px);
    height: calc(100vh - 120px);
  }
  #adc-chat-toggle {
    right: 16px;
    bottom: 20px;
  }
}
