/* ==========================================================================
   MESPROSOFT ENTERPRISE AI CHATBOT & CONSULTANT WIDGET
   ========================================================================== */

:root {
  --mes-ai-primary: var(--blue, #0762e5);
  --mes-ai-secondary: var(--blue-dark, #0550bd);
  --mes-ai-dark: var(--navy, #151f30);
  --mes-ai-red: #e00818;
  --mes-ai-bg: var(--bg-soft, #f6f8fb);
  --mes-ai-border: var(--line, #e3e7ee);
  --mes-ai-text: var(--text, #3b4556);
  --mes-ai-muted: var(--muted, #6b7484);
  --mes-ai-font: 'Inter', sans-serif;
}

/* Floating Launcher Button */
.mes-ai-launcher {
  position: fixed;
  bottom: 25px;
  left: 20px;
  right: auto;
  z-index: 99990;
  display: flex;
  align-items: center;
  gap: 10px;
}

.mes-ai-launcher-btn {
  width: 43px;
  height: 43px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0051a4 0%, #087da8 100%);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  box-shadow: 0 10px 30px rgba(0, 81, 164, 0.4);
  transition: all 0.35s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
}

.mes-ai-launcher-btn:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 14px 36px rgba(0, 81, 164, 0.55);
}

.mes-ai-launcher-btn .mes-ai-icon-open,
.mes-ai-launcher-btn .mes-ai-icon-close {
  position: absolute;
  transition: all 0.3s ease;
}

.mes-ai-launcher-btn .mes-ai-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

.mes-ai-widget.open .mes-ai-launcher-btn .mes-ai-icon-open {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

.mes-ai-widget.open .mes-ai-launcher-btn .mes-ai-icon-close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Pulse Animation Ring */
.mes-ai-launcher-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(8, 125, 168, 0.6);
  animation: mesAiPulse 2.2s infinite cubic-bezier(0.24, 0, 0.38, 1);
  pointer-events: none;
}

@keyframes mesAiPulse {
  0% {
    transform: scale(0.95);
    opacity: 0.9;
  }

  70% {
    transform: scale(1.35);
    opacity: 0;
  }

  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* Tooltip Badge */
.mes-ai-launcher-tooltip {
  background: #0d113a;
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  white-space: nowrap;
  pointer-events: none;
  animation: mesAiFloat 3s infinite ease-in-out;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mes-ai-launcher-tooltip span.pulse-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  display: inline-block;
}

@keyframes mesAiFloat {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-4px);
  }
}

/* Chat Window Container */
.mes-ai-window {
  position: fixed;
  bottom: 95px;
  left: 20px;
  right: auto;
  width: 390px;
  height: 590px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(13, 17, 58, 0.22), 0 0 0 1px rgba(0, 81, 164, 0.08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99991;
  font-family: var(--mes-ai-font);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
}

.mes-ai-widget.open .mes-ai-window {
  display: flex !important;
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: mesAiSlideUp 0.3s cubic-bezier(0.165, 0.84, 0.44, 1) forwards;
}

@keyframes mesAiSlideUp {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Chat Header */
.mes-ai-header {
  background: linear-gradient(135deg, #0d113a 0%, #0051a4 100%);
  color: #ffffff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mes-ai-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mes-ai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, #087da8, #0051a4);
  border: 2px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.mes-ai-header-info h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.2px;
}

.mes-ai-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 2px;
}

.mes-ai-status-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

.mes-ai-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mes-ai-consultant-btn {
  background: rgba(224, 8, 24, 0.9);
  color: #ffffff;
  border: none;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
  letter-spacing: 0.3px;
}

.mes-ai-consultant-btn:hover {
  background: #e00818;
  transform: scale(1.05);
}

.mes-ai-close-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  opacity: 0.8;
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s;
}

.mes-ai-close-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* Message Body Area */
.mes-ai-body {
  flex: 1;
  padding: 18px 16px;
  overflow-y: auto;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Custom Scrollbar */
.mes-ai-body::-webkit-scrollbar {
  width: 5px;
}

.mes-ai-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

/* Messages */
.mes-ai-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: mesAiFadeIn 0.3s ease;
}

@keyframes mesAiFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mes-ai-msg.bot {
  align-self: flex-start;
}

.mes-ai-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.mes-ai-msg-bubble {
  padding: 12px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
}

.mes-ai-msg.bot .mes-ai-msg-bubble {
  background: #ffffff;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 14px rgba(13, 17, 58, 0.06);
  border: 1px solid #e2e8f0;
}

.mes-ai-msg.user .mes-ai-msg-bubble {
  background: linear-gradient(135deg, #0051a4, #087da8);
  color: #ffffff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(0, 81, 164, 0.25);
}

.mes-ai-msg-bubble p {
  margin: 0 0 8px;
}

.mes-ai-msg-bubble p:last-child {
  margin-bottom: 0;
}

.mes-ai-msg-bubble ul {
  margin: 6px 0 8px 18px;
  padding: 0;
}

.mes-ai-msg-bubble li {
  margin-bottom: 4px;
}

.mes-ai-msg-bubble a {
  color: #0051a4;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mes-ai-msg.user .mes-ai-msg-bubble a {
  color: #ffffff;
}

/* Quick Suggestion Pills */
.mes-ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.mes-ai-pill {
  background: #ffffff;
  border: 1px solid #dce9f5;
  color: #0051a4;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 81, 164, 0.05);
}

.mes-ai-pill:hover {
  background: #0051a4;
  color: #ffffff;
  border-color: #0051a4;
  transform: translateY(-1px);
}

.mes-ai-pill.expert-pill {
  background: #fef2f2;
  border-color: #fecaca;
  color: #e00818;
}

.mes-ai-pill.expert-pill:hover {
  background: #e00818;
  color: #ffffff;
  border-color: #e00818;
}

/* Consultant Connect Interactive Card */
.mes-ai-consultant-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #e00818;
  border-radius: 12px;
  padding: 14px;
  margin-top: 6px;
  box-shadow: 0 6px 16px rgba(13, 17, 58, 0.07);
}

.mes-ai-consultant-card h5 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: #0d113a;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mes-ai-consultant-card p {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 10px;
  line-height: 1.4;
}

.mes-ai-form-group {
  margin-bottom: 8px;
}

.mes-ai-form-group input,
.mes-ai-form-group textarea {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
  box-sizing: border-box;
}

.mes-ai-form-group input:focus,
.mes-ai-form-group textarea:focus {
  border-color: #0051a4;
}

.mes-ai-submit-btn {
  width: 100%;
  padding: 9px;
  background: #e00818;
  color: #ffffff;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.2s;
}

.mes-ai-submit-btn:hover {
  background: #be0714;
}

.mes-ai-wa-btn {
  width: 100%;
  padding: 9px;
  background: #25d366;
  color: #ffffff;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 8px;
  transition: background 0.2s;
}

.mes-ai-wa-btn:hover {
  background: #1eb956;
  color: #ffffff;
}

/* Typing Bouncing Dots */
.mes-ai-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  width: fit-content;
}

.mes-ai-typing span {
  width: 6px;
  height: 6px;
  background: #087da8;
  border-radius: 50%;
  animation: mesAiBounce 1.4s infinite ease-in-out both;
}

.mes-ai-typing span:nth-child(1) {
  animation-delay: -0.32s;
}

.mes-ai-typing span:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes mesAiBounce {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

/* Chat Footer / Input */
.mes-ai-footer {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
}

.mes-ai-input-wrap {
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border-radius: 25px;
  padding: 4px 6px 4px 14px;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.mes-ai-input-wrap:focus-within {
  border-color: #0051a4;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(0, 81, 164, 0.1);
}

.mes-ai-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: #1e293b;
  font-family: inherit;
}

.mes-ai-input-wrap input::placeholder {
  color: #94a3b8;
}

.mes-ai-send-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #0051a4;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.2s ease;
}

.mes-ai-send-btn:hover {
  background: #087da8;
  transform: scale(1.05);
}

.mes-ai-footer-note {
  text-align: center;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 6px;
}

@media (max-width: 1399.98px) {
  .mes-ai-launcher {
    bottom: 85px !important;
    left: 16px !important;
    right: auto !important;
  }

  .mes-ai-launcher-tooltip {
    display: none !important;
  }

  .mes-ai-window {
    bottom: 145px !important;
  }
}

@media (max-width: 576px) {
  .mes-ai-window {
    right: 12px !important;
    left: 12px !important;
    bottom: 82px !important;
    width: auto !important;
    max-width: calc(100vw - 24px) !important;
    height: 75vh !important;
    max-height: 560px !important;
    border-radius: 16px !important;
  }

  .mes-ai-launcher {
    bottom: 82px !important;
    left: 12px !important;
    right: auto !important;
  }

  .mes-ai-launcher-btn {
    width: 44px !important;
    height: 44px !important;
    font-size: 18px !important;
  }

  .mes-ai-launcher-tooltip {
    display: none !important;
  }
}