/* ===================================================================
   MADINA PHARMA LINKS — SITE CHATBOT WIDGET
   Uses the same design tokens as the rest of the site (variables.css)
   so it matches the Liquid Glass theme automatically.
   =================================================================== */

#mpl-chat-root {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  font-family: var(--font-body);
}

/* ---------- floating launcher button ---------- */
.mpl-chat-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-fill-strong);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  box-shadow:
    inset 0 1px 1px var(--glass-highlight),
    inset 0 -6px 10px rgba(0,0,0,0.2),
    0 10px 24px rgba(0,0,0,0.4),
    0 0 22px rgba(36,82,232,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .3s ease;
}

.mpl-chat-btn:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow:
    inset 0 1px 1px var(--glass-highlight),
    inset 0 -6px 10px rgba(0,0,0,0.2),
    0 14px 30px rgba(0,0,0,0.45),
    0 0 28px rgba(31,165,114,0.4);
}

.mpl-chat-btn.squish { animation: mplSquish .5s cubic-bezier(.34,1.56,.64,1); }
@keyframes mplSquish {
  0%{transform:scale(1);} 30%{transform:scale(0.86,1.12);}
  50%{transform:scale(1.1,0.9);} 70%{transform:scale(0.97,1.03);} 100%{transform:scale(1);}
}

.mpl-chat-btn svg { width: 26px; height: 26px; color: var(--text-primary); position: relative; z-index: 2; transition: opacity .2s ease, transform .2s ease; }
.mpl-chat-btn .mpl-icon-close { position: absolute; opacity: 0; transform: scale(0.6) rotate(-45deg); }
.mpl-chat-btn.open .mpl-icon-chat { opacity: 0; transform: scale(0.6) rotate(45deg); }
.mpl-chat-btn.open .mpl-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* pulsing glow ring to draw attention when idle */
.mpl-chat-btn::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--brand-green);
  opacity: 0;
  animation: mplPulseRing 2.6s ease-out infinite;
}
@keyframes mplPulseRing {
  0% { opacity: .55; transform: scale(0.9); }
  100% { opacity: 0; transform: scale(1.5); }
}

/* notification dot */
.mpl-chat-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--brand-red);
  border: 2px solid var(--bg-base);
  z-index: 3;
}
.mpl-chat-dot.hide { display: none; }

/* ---------- chat panel ---------- */
.mpl-chat-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 500px;
  max-height: 70vh;
  border-radius: var(--radius-l);
  border: 1px solid var(--glass-border);
  background: var(--glass-fill-strong);
  backdrop-filter: blur(var(--glass-blur-lg)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur-lg)) saturate(150%);
  box-shadow:
    inset 0 1px 1px var(--glass-highlight),
    0 20px 50px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  opacity: 0;
  transform: translateY(16px) scale(0.94);
  pointer-events: none;
  transform-origin: bottom right;
  transition: opacity .3s cubic-bezier(.22,1,.36,1), transform .3s cubic-bezier(.22,1,.36,1);
}

.mpl-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* header */
.mpl-chat-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--glass-border-soft);
  background: linear-gradient(90deg, rgba(36,82,232,0.14), rgba(31,165,114,0.1) 50%, rgba(230,57,70,0.12));
  flex-shrink: 0;
}

.mpl-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-green));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.mpl-chat-header-text { flex: 1; min-width: 0; }
.mpl-chat-header-text h4 {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0;
}
.mpl-chat-status {
  font-size: var(--fs-tiny);
  color: var(--brand-green-light);
  display: flex;
  align-items: center;
  gap: 5px;
}
.mpl-chat-status::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand-green-light);
  box-shadow: 0 0 6px var(--brand-green-light);
}

.mpl-chat-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.2rem; line-height: 1; padding: 4px;
  transition: color .2s ease;
}
.mpl-chat-close:hover { color: var(--text-primary); }

/* messages */
.mpl-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-2) var(--sp-1);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.mpl-chat-messages::-webkit-scrollbar { width: 5px; }
.mpl-chat-messages::-webkit-scrollbar-thumb { background: var(--glass-border); border-radius: 10px; }

.mpl-msg {
  max-width: 82%;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-m);
  font-size: 0.88rem;
  line-height: 1.45;
  animation: mplMsgIn .3s cubic-bezier(.22,1,.36,1) both;
}
@keyframes mplMsgIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

.mpl-msg a { color: var(--brand-green-light); text-decoration: underline; }

.mpl-msg.bot {
  align-self: flex-start;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border-soft);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
}
.mpl-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-blue-light));
  color: #fff;
  border-bottom-right-radius: 6px;
}

.mpl-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.7rem 0.9rem;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-m);
  border-bottom-left-radius: 6px;
}
.mpl-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: mplTypingBounce 1.2s ease-in-out infinite;
}
.mpl-typing span:nth-child(2) { animation-delay: .15s; }
.mpl-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mplTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* quick replies */
.mpl-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.2rem 0.1rem 0.6rem;
}
.mpl-chip {
  border: 1px solid var(--glass-border);
  background: var(--glass-fill);
  color: var(--text-secondary);
  font-size: var(--fs-tiny);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.mpl-chip:hover {
  background: var(--glass-fill-strong);
  color: var(--text-primary);
  border-color: var(--brand-green-light);
  transform: translateY(-1px);
}

/* input row */
.mpl-chat-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: var(--sp-2);
  border-top: 1px solid var(--glass-border-soft);
  flex-shrink: 0;
}
.mpl-chat-input {
  flex: 1;
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 0.6rem 1rem;
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  transition: border-color .2s ease;
}
.mpl-chat-input:focus { border-color: var(--brand-blue-light); }
.mpl-chat-input::placeholder { color: var(--text-muted); }

.mpl-chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--brand-blue), var(--brand-green));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.mpl-chat-send:hover { transform: scale(1.08); }
.mpl-chat-send:active { transform: scale(0.92); }
.mpl-chat-send svg { width: 16px; height: 16px; }

/* mobile */
@media (max-width: 480px) {
  #mpl-chat-root { right: 14px; bottom: 14px; }
  .mpl-chat-panel {
    width: calc(100vw - 28px);
    height: 65vh;
    bottom: 74px;
  }
}
