/* ============================================================
   MDG Agentic Chat Widget
   ============================================================ */

/* ── Launch button ── */
.mdg-chat-launcher {
  position: fixed;
  bottom: 1.75rem;
  left: 1.75rem;
  z-index: 990;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #0D1B2A;
  border: 2px solid #FF5C35;
  border-radius: 50px;
  padding: 0.7rem 1.1rem 0.7rem 0.85rem;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0,0,0,0.35), 0 0 0 0 rgba(255,92,53,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  text-decoration: none;
  animation: chat-pulse 3.5s ease-in-out infinite;
}
.mdg-chat-launcher:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 8px 32px rgba(255,92,53,0.35);
  animation: none;
}
@keyframes chat-pulse {
  0%, 100% { box-shadow: 0 4px 24px rgba(0,0,0,0.35), 0 0 0 0 rgba(255,92,53,0.4); }
  50%       { box-shadow: 0 4px 24px rgba(0,0,0,0.35), 0 0 0 8px rgba(255,92,53,0); }
}
.mdg-chat-launcher.open { animation: none; }

.mdg-chat-launcher-icon {
  width: 32px;
  height: 32px;
  background: #FF5C35;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: transform 0.25s;
}
.mdg-chat-launcher.open .mdg-chat-launcher-icon { transform: rotate(45deg); }

.mdg-chat-launcher-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.mdg-chat-launcher-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
  animation: blink-dot 2s ease infinite;
}
@keyframes blink-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Chat panel ── */
.mdg-chat-panel {
  position: fixed;
  bottom: 5.5rem;
  left: 1.75rem;
  z-index: 995;
  width: 380px;
  max-width: calc(100vw - 2rem);
  height: 560px;
  max-height: calc(100vh - 8rem);
  background: #fff;
  border-radius: 1.25rem;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22), 0 0 0 1px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.25s ease;
}
.mdg-chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Panel header ── */
.mdg-chat-header {
  background: #0D1B2A;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}
.mdg-chat-header-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.mdg-chat-header-avatar img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.92;
}
.mdg-chat-header-info { flex: 1; min-width: 0; }
.mdg-chat-header-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
  margin-bottom: 0.1rem;
}
.mdg-chat-header-status {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.55);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.mdg-chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
}
.mdg-chat-header-close {
  background: rgba(255,255,255,0.08);
  border: none;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.mdg-chat-header-close:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ── Department tabs ── */
.mdg-chat-dept-bar {
  background: #F8F9FA;
  border-bottom: 1px solid #E5E7EB;
  display: flex;
  gap: 0;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.mdg-chat-dept-bar::-webkit-scrollbar { display: none; }
.mdg-chat-dept-btn {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.5rem;
  border: none;
  background: transparent;
  font-size: 0.7rem;
  font-weight: 600;
  color: #9CA3AF;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: 'Montserrat', sans-serif;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  position: relative;
}
.mdg-chat-dept-btn:hover { color: #0D1B2A; }
.mdg-chat-dept-btn.active {
  color: #00557e;
  border-bottom-color: #FF5C35;
}

/* ── Messages area ── */
.mdg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
}
.mdg-chat-messages::-webkit-scrollbar { width: 4px; }
.mdg-chat-messages::-webkit-scrollbar-track { background: transparent; }
.mdg-chat-messages::-webkit-scrollbar-thumb { background: #E5E7EB; border-radius: 2px; }

/* Message bubbles */
.mdg-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  animation: msg-in 0.25s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.mdg-msg.bot { justify-content: flex-start; }
.mdg-msg.user { justify-content: flex-end; }

.mdg-msg-avatar {
  width: 28px;
  height: 28px;
  background: #0A0F1E;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-bottom: 2px;
  overflow: hidden;
}
.mdg-msg-avatar img {
  width: 18px;
  height: 18px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 0.85;
}

.mdg-msg-bubble {
  max-width: 78%;
  padding: 0.65rem 0.9rem;
  border-radius: 1rem;
  font-size: 0.87rem;
  line-height: 1.55;
}
.mdg-msg.bot .mdg-msg-bubble {
  background: #F3F4F6;
  color: #1F2937;
  border-bottom-left-radius: 3px;
}
.mdg-msg.user .mdg-msg-bubble {
  background: #0D1B2A;
  color: #fff;
  border-bottom-right-radius: 3px;
}
.mdg-msg-bubble strong { font-weight: 700; }
.mdg-msg-bubble a { color: #00A3C4; }

/* Typing indicator */
.mdg-typing {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
}
.mdg-typing-dots {
  background: #F3F4F6;
  border-radius: 1rem;
  border-bottom-left-radius: 3px;
  padding: 0.75rem 1rem;
  display: flex;
  gap: 4px;
  align-items: center;
}
.mdg-typing-dots span {
  width: 7px;
  height: 7px;
  background: #9CA3AF;
  border-radius: 50%;
  animation: typing-bounce 1.2s ease infinite;
}
.mdg-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.mdg-typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes typing-bounce {
  0%, 100% { transform: translateY(0); }
  40%       { transform: translateY(-5px); }
}

/* Quick replies */
.mdg-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.25rem 0.5rem;
}
.mdg-quick-reply {
  padding: 0.4rem 0.85rem;
  border-radius: 50px;
  border: 1.5px solid #E5E7EB;
  background: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Inter', sans-serif;
  white-space: nowrap;
}
.mdg-quick-reply:hover {
  border-color: #00557e;
  color: #00557e;
  background: rgba(0,85,126,0.04);
}
.mdg-quick-reply.cta {
  border-color: #FF5C35;
  color: #FF5C35;
}
.mdg-quick-reply.cta:hover {
  background: rgba(255,92,53,0.06);
}

/* ── Input area ── */
.mdg-chat-input-area {
  padding: 0.875rem 1.25rem 1rem;
  border-top: 1px solid #F3F4F6;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: #fff;
  flex-shrink: 0;
}
.mdg-chat-input {
  flex: 1;
  border: 1.5px solid #E5E7EB;
  border-radius: 50px;
  padding: 0.6rem 1rem;
  font-size: 0.87rem;
  font-family: 'Inter', sans-serif;
  color: #1F2937;
  background: #F9FAFB;
  outline: none;
  transition: border-color 0.2s;
  min-height: 0;
}
.mdg-chat-input:focus {
  border-color: #00557e;
  background: #fff;
}
.mdg-chat-input::placeholder { color: #9CA3AF; }
.mdg-chat-send {
  width: 36px;
  height: 36px;
  background: #FF5C35;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
  flex-shrink: 0;
}
.mdg-chat-send:hover { background: #D94520; transform: scale(1.08); }
.mdg-chat-send:disabled { background: #E5E7EB; color: #9CA3AF; cursor: default; transform: none; }

/* ── Escalation confirmation ── */
.mdg-escalation-card {
  background: linear-gradient(135deg, #0D1B2A, #00557e);
  border-radius: 0.75rem;
  padding: 1rem;
  color: #fff;
  margin: 0 1.25rem 0.75rem;
  flex-shrink: 0;
}
.mdg-escalation-card h4 {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  color: #fff;
}
.mdg-escalation-card p {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.5;
}

/* ── Empty state ── */
.mdg-chat-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: #9CA3AF;
  font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .mdg-chat-panel {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    bottom: 5rem;
  }
  .mdg-chat-launcher {
    left: 1rem;
    bottom: 1rem;
  }
  .whatsapp-float {
    bottom: 1rem;
    right: 1rem;
  }
  /* Touch-friendly quick replies */
  .mdg-quick-reply {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
}

/* ── Landscape mobile — keep launcher visible ── */
@media (max-height: 500px) {
  .mdg-chat-launcher { bottom: 0.5rem; left: 0.75rem; }
  .mdg-chat-panel    { bottom: 4rem; max-height: calc(100vh - 5rem); overflow-y: auto; }
  .whatsapp-float    { bottom: 0.5rem; right: 0.75rem; }
}
