/* ============================================================
   CHAT-WIDGET.CSS — Floating Messenger / WhatsApp / Viber Widget
   MWeb Design V2
   
   TO DISABLE: Comment out the <link> tag in your HTML
   ============================================================ */

/* ============================================================
   WIDGET WRAPPER — bottom-left, clear of scroll-to-top button
   ============================================================ */
.mwd-chat-widget {
  position: fixed;
  left: 28px;
  bottom: max(28px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  z-index: calc(var(--z-navbar) - 5);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;

  /* Hidden until JS triggers it */
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px);
  transition:
    opacity 0.55s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.55s linear,
    transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

/* Visible state — JS adds .is-visible */
.mwd-chat-widget.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: all;
}

/* ============================================================
   BOTTOM ROW — just the trigger button
   ============================================================ */
.mwd-chat-bottom-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

/* ============================================================
   CALLOUT BUBBLE — "Message Us"
   Hidden by default. Appears above the platform panel
   when the trigger is clicked. Hides when closed.
   ============================================================ */
.mwd-chat-callout {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--clr-black);
  color: var(--clr-white);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: var(--fw-medium);
  letter-spacing: 0.01em;
  padding: 10px 14px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  white-space: nowrap;

  /* Hidden by default — shown only when open */
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.92);
  transform-origin: bottom left;
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.35s linear,
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* Show callout when widget is open */
.mwd-chat-widget.is-open .mwd-chat-callout {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: all;
  /* Slight delay so panel animates in first */
  transition-delay: 0.08s;
  /* Subtle float */
  animation: callout-float 4s ease-in-out 0.5s infinite;
}

.mwd-chat-callout__dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  flex-shrink: 0;
  animation: online-pulse 2s ease-in-out infinite;
}

.mwd-chat-callout__text {
  line-height: 1;
}

/* is-hidden no longer needed — state is controlled by is-open */
.mwd-chat-callout.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ============================================================
   MAIN TRIGGER BUTTON
   ============================================================ */
.mwd-chat-trigger {
  position: relative;
  width: 58px;
  height: 58px;
  background: linear-gradient(135deg, var(--clr-accent) 0%, var(--clr-accent-glow) 100%);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-blue);
  transition:
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    background 0.25s ease;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
}

.mwd-chat-trigger:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: var(--shadow-blue-lg);
  background: linear-gradient(135deg, var(--clr-accent-glow) 0%, var(--clr-accent) 100%);
}

/* Pulse ring — blue tinted */
.mwd-chat-trigger::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--clr-accent-glow);
  opacity: 0;
  animation: trigger-pulse 2.8s cubic-bezier(0.16, 1, 0.3, 1) 1.5s infinite;
}

/* Icon — default chat bubble */
.mwd-chat-trigger__icon {
  font-size: 1.5rem;
  color: var(--clr-white);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.25s ease;
  line-height: 1;
}

/* Close icon (hidden by default) */
.mwd-chat-trigger__icon--close {
  position: absolute;
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
  font-size: 1.1rem;
}

/* Open state */
.mwd-chat-widget.is-open .mwd-chat-trigger__icon--default {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}
.mwd-chat-widget.is-open .mwd-chat-trigger__icon--close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Notification badge */
.mwd-chat-trigger__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid var(--clr-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.5625rem;
  font-weight: var(--fw-bold);
  color: #fff;
  animation: badge-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) 0.8s both;
}

/* ============================================================
   PLATFORM OPTIONS PANEL
   ============================================================ */
.mwd-chat-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;

  /* Hidden by default */
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.92);
  transform-origin: bottom left;
  transition:
    opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.35s linear,
    transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* Open state */
.mwd-chat-widget.is-open .mwd-chat-panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Stagger each platform button */
.mwd-chat-widget.is-open .mwd-chat-platform:nth-child(1) { transition-delay: 0.04s; }
.mwd-chat-widget.is-open .mwd-chat-platform:nth-child(2) { transition-delay: 0.10s; }
.mwd-chat-widget.is-open .mwd-chat-platform:nth-child(3) { transition-delay: 0.16s; }

/* ============================================================
   INDIVIDUAL PLATFORM BUTTON
   ============================================================ */
.mwd-chat-platform {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--clr-white);
  border: 1px solid var(--clr-warm-200);
  border-radius: var(--radius-full);
  padding: 9px 18px 9px 9px;
  text-decoration: none;
  color: var(--clr-black);
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: var(--fw-medium);
  white-space: nowrap;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition:
    transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    border-color 0.25s ease,
    background 0.25s ease;

  /* Each starts slightly below and invisible (panel animates them in) */
  opacity: 0;
  transform: translateX(-12px);
}

.mwd-chat-widget.is-open .mwd-chat-platform {
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 0.35s ease,
    transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.3s ease,
    border-color 0.25s ease,
    background 0.25s ease;
}

.mwd-chat-platform:hover {
  transform: translateX(5px);
  box-shadow: var(--shadow-lg);
}

/* Icon circle */
.mwd-chat-platform__icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1rem;
  color: #fff;
  transition: transform 0.36s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.mwd-chat-platform:hover .mwd-chat-platform__icon {
  transform: scale(1.12) rotate(-5deg);
}

/* Platform-specific icon colors */
.mwd-chat-platform--messenger .mwd-chat-platform__icon {
  background: linear-gradient(135deg, #0099ff, #a033ff);
}
.mwd-chat-platform--whatsapp .mwd-chat-platform__icon {
  background: linear-gradient(135deg, #25d366, #128c7e);
}
.mwd-chat-platform--viber .mwd-chat-platform__icon {
  background: linear-gradient(135deg, #7360f2, #5b2d8e);
}

/* Platform hover colors */
.mwd-chat-platform--messenger:hover {
  border-color: #a033ff;
  background: #faf5ff;
}
.mwd-chat-platform--whatsapp:hover {
  border-color: #25d366;
  background: #f0fdf4;
}
.mwd-chat-platform--viber:hover {
  border-color: #7360f2;
  background: #f5f3ff;
}

/* Label */
.mwd-chat-platform__label {
  line-height: 1;
}
.mwd-chat-platform__label strong {
  display: block;
  font-size: 0.8125rem;
  font-weight: var(--fw-semibold);
  color: var(--clr-black);
  margin-bottom: 2px;
}
.mwd-chat-platform__label span {
  font-size: 0.6875rem;
  color: var(--clr-warm-500);
  font-weight: var(--fw-regular);
}

/* ============================================================
   KEYFRAMES
   ============================================================ */
@keyframes callout-enter {
  from { opacity: 0; transform: translateX(-20px) scale(0.9); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes callout-float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-5px); }
}

@keyframes online-pulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50%       { opacity: 0.7; transform: scale(0.85); box-shadow: 0 0 0 5px rgba(34,197,94,0); }
}

@keyframes trigger-pulse {
  0%   { opacity: 0.6; transform: scale(1); }
  70%  { opacity: 0;   transform: scale(1.5); }
  100% { opacity: 0;   transform: scale(1.5); }
}

@keyframes badge-pop {
  from { opacity: 0; transform: scale(0) rotate(-45deg); }
  to   { opacity: 1; transform: scale(1) rotate(0deg); }
}

/* ============================================================
   MOBILE ADJUSTMENTS
   ============================================================ */
@media (max-width: 575px) {
  .mwd-chat-widget {
    left: 16px;
    bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px));
  }
  .mwd-chat-trigger {
    width: 52px;
    height: 52px;
  }
  .mwd-chat-callout {
    font-size: 0.75rem;
    padding: 9px 14px 9px 10px;
  }
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .mwd-chat-widget,
  .mwd-chat-callout,
  .mwd-chat-panel,
  .mwd-chat-platform,
  .mwd-chat-trigger {
    transition: none !important;
    animation: none !important;
  }
  .mwd-chat-trigger::before { display: none; }
  .mwd-chat-callout__dot { animation: none !important; }
  .mwd-chat-trigger__badge { animation: none !important; }
}