/* =============================================================================
   MLT WhatsApp Widget v1.1
   Built for tradespeople by My Local Trades
   ============================================================================= */

/* ── Colour schemes ────────────────────────────────────────────────────────── */
.mlt-wa--whatsapp-green {
  --mlt-wa-bg: #25D366; --mlt-wa-bg-hover: #1ebe5a; --mlt-wa-text: #fff;
  --mlt-wa-card-bg: #fff; --mlt-wa-card-text: #1a1a1a; --mlt-wa-card-sub: #555;
  --mlt-wa-card-border: #e5e5e5; --mlt-wa-cta-bg: #25D366; --mlt-wa-cta-hover: #1ebe5a;
  --mlt-wa-cta-text: #fff; --mlt-wa-shadow: rgba(37,211,102,0.35);
  --mlt-wa-ping: rgba(37,211,102,0.6);
}
.mlt-wa--dark {
  --mlt-wa-bg: #2d2d2d; --mlt-wa-bg-hover: #3a3a3a; --mlt-wa-text: #fff;
  --mlt-wa-card-bg: #2d2d2d; --mlt-wa-card-text: #fff; --mlt-wa-card-sub: #b0b0b0;
  --mlt-wa-card-border: #444; --mlt-wa-cta-bg: #25D366; --mlt-wa-cta-hover: #1ebe5a;
  --mlt-wa-cta-text: #fff; --mlt-wa-shadow: rgba(0,0,0,0.3);
  --mlt-wa-ping: rgba(37,211,102,0.6);
}
.mlt-wa--brand-blue {
  --mlt-wa-bg: #1a73e8; --mlt-wa-bg-hover: #1565c0; --mlt-wa-text: #fff;
  --mlt-wa-card-bg: #fff; --mlt-wa-card-text: #1a1a1a; --mlt-wa-card-sub: #555;
  --mlt-wa-card-border: #e5e5e5; --mlt-wa-cta-bg: #25D366; --mlt-wa-cta-hover: #1ebe5a;
  --mlt-wa-cta-text: #fff; --mlt-wa-shadow: rgba(26,115,232,0.35);
  --mlt-wa-ping: rgba(26,115,232,0.6);
}

/* ── Container ─────────────────────────────────────────────────────────────── */
.mlt-wa {
  position: fixed;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
  animation: mlt-wa-entrance 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.5s both;
}

/* ── 6 Positions ───────────────────────────────────────────────────────────── */
.mlt-wa--bottom-right { bottom: 24px; right: 24px;  align-items: flex-end; }
.mlt-wa--bottom-left  { bottom: 24px; left: 24px;   align-items: flex-start; }
.mlt-wa--middle-right { top: 50%; right: 24px;  transform: translateY(-50%); align-items: flex-end; }
.mlt-wa--middle-left  { top: 50%; left: 24px;   transform: translateY(-50%); align-items: flex-start; }
.mlt-wa--top-right    { top: 90px;  right: 24px;  align-items: flex-end; }
.mlt-wa--top-left     { top: 90px;  left: 24px;   align-items: flex-start; }

/* Fix entrance animation for middle positions */
.mlt-wa--middle-right,
.mlt-wa--middle-left {
  animation: mlt-wa-entrance-middle 0.5s cubic-bezier(0.34,1.56,0.64,1) 0.5s both;
}

/* ── Card popup ────────────────────────────────────────────────────────────── */
.mlt-wa__card {
  position: relative;
  background: var(--mlt-wa-card-bg);
  border-radius: 16px;
  padding: 20px 20px 16px;
  width: 280px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid var(--mlt-wa-card-border);
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: all 0.3s cubic-bezier(0.34,1.56,0.64,1);
  pointer-events: auto;
}

/* Hidden state */
.mlt-wa__card.mlt-wa--hidden-card {
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
}

/* Triangle pointers */
.mlt-wa--bottom-right .mlt-wa__card::after,
.mlt-wa--middle-right .mlt-wa__card::after,
.mlt-wa--top-right .mlt-wa__card::after {
  content: "";
  position: absolute;
  bottom: -8px;
  right: 26px;
  width: 16px; height: 16px;
  background: var(--mlt-wa-card-bg);
  border-right: 1px solid var(--mlt-wa-card-border);
  border-bottom: 1px solid var(--mlt-wa-card-border);
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0,0,0,0.04);
}
.mlt-wa--bottom-left .mlt-wa__card::after,
.mlt-wa--middle-left .mlt-wa__card::after,
.mlt-wa--top-left .mlt-wa__card::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 26px;
  width: 16px; height: 16px;
  background: var(--mlt-wa-card-bg);
  border-right: 1px solid var(--mlt-wa-card-border);
  border-bottom: 1px solid var(--mlt-wa-card-border);
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0,0,0,0.04);
}

/* Close button */
.mlt-wa__close {
  position: absolute; top: 10px; right: 10px;
  width: 24px; height: 24px;
  border: none; background: transparent;
  color: var(--mlt-wa-card-sub);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; padding: 0;
  transition: background 0.2s, color 0.2s;
}
.mlt-wa__close:hover {
  background: rgba(0,0,0,0.06);
  color: var(--mlt-wa-card-text);
}

/* Card body */
.mlt-wa__card-body {
  display: flex; flex-direction: column;
  gap: 4px; margin-bottom: 14px; padding-right: 20px;
}
.mlt-wa__heading {
  font-size: 16px; font-weight: 700;
  color: var(--mlt-wa-card-text); margin: 0; line-height: 1.3;
}
.mlt-wa__body {
  font-size: 13px; color: var(--mlt-wa-card-sub); margin: 0;
}

/* CTA button */
.mlt-wa__cta {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 10px 16px;
  background: var(--mlt-wa-cta-bg); color: var(--mlt-wa-cta-text);
  border: none; border-radius: 10px;
  font-size: 14px; font-weight: 600; text-decoration: none;
  cursor: pointer; transition: background 0.2s, transform 0.15s;
  letter-spacing: 0.2px;
}
.mlt-wa__cta:hover, .mlt-wa__cta:focus {
  background: var(--mlt-wa-cta-hover);
  color: var(--mlt-wa-cta-text);
  text-decoration: none;
  transform: translateY(-1px);
}
.mlt-wa__cta:active { transform: translateY(0); }
.mlt-wa__cta-icon { flex-shrink: 0; }

/* ── FAB (floating action button) ──────────────────────────────────────────── */
.mlt-wa__fab {
  position: relative;
  width: 60px; height: 60px;
  border-radius: 50%; border: none;
  background: var(--mlt-wa-bg); color: var(--mlt-wa-text);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px var(--mlt-wa-shadow), 0 2px 6px rgba(0,0,0,0.1);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  padding: 0; outline: none; text-decoration: none;
}
.mlt-wa__fab:hover {
  background: var(--mlt-wa-bg-hover);
  color: var(--mlt-wa-text);
  transform: scale(1.08);
  box-shadow: 0 6px 20px var(--mlt-wa-shadow), 0 3px 8px rgba(0,0,0,0.12);
  text-decoration: none;
}
.mlt-wa__fab:active { transform: scale(1); }

/* Icon toggle (popup style only) */
.mlt-wa__fab-icon {
  transition: opacity 0.25s, transform 0.25s;
  position: absolute;
}
.mlt-wa__fab-icon--wa    { opacity: 1; transform: rotate(0) scale(1); }
.mlt-wa__fab-icon--close { opacity: 0; transform: rotate(-90deg) scale(0.5); }

/* When popup card is visible, show X on FAB */
.mlt-wa--style-popup .mlt-wa__fab.mlt-wa--fab-open .mlt-wa__fab-icon--wa {
  opacity: 0; transform: rotate(90deg) scale(0.5);
}
.mlt-wa--style-popup .mlt-wa__fab.mlt-wa--fab-open .mlt-wa__fab-icon--close {
  opacity: 1; transform: rotate(0) scale(1);
}

/* ── Pill style ────────────────────────────────────────────────────────────── */
.mlt-wa__pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--mlt-wa-bg);
  color: var(--mlt-wa-text);
  text-decoration: none;
  border-radius: 50px;
  padding: 12px 22px 12px 16px;
  box-shadow: 0 4px 14px var(--mlt-wa-shadow), 0 2px 6px rgba(0,0,0,0.1);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
}
.mlt-wa__pill:hover, .mlt-wa__pill:focus {
  background: var(--mlt-wa-bg-hover);
  color: var(--mlt-wa-text);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--mlt-wa-shadow), 0 3px 8px rgba(0,0,0,0.12);
}
.mlt-wa__pill:active { transform: translateY(0); }

.mlt-wa__pill-icon {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; min-width: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  transition: background 0.2s;
}
.mlt-wa__pill:hover .mlt-wa__pill-icon { background: rgba(255,255,255,0.3); }
.mlt-wa__pill-icon svg { fill: currentColor; }
.mlt-wa__pill-text { line-height: 1; }

/* ── Ping pulse ────────────────────────────────────────────────────────────── */
.mlt-wa__fab-ping {
  position: absolute; inset: 0; border-radius: 50%;
  animation: mlt-wa-ping 2.5s cubic-bezier(0,0,0.2,1) infinite;
  background: var(--mlt-wa-ping); pointer-events: none;
}
/* Pill ping needs pill shape */
.mlt-wa__pill .mlt-wa__fab-ping {
  border-radius: 50px;
}
/* Stop ping when popup is open */
.mlt-wa--style-popup .mlt-wa__fab.mlt-wa--fab-open .mlt-wa__fab-ping {
  animation: none; opacity: 0;
}

@keyframes mlt-wa-ping {
  0%        { transform: scale(1);   opacity: 0.5; }
  75%, 100% { transform: scale(1.5); opacity: 0;   }
}

/* ── Entrance animations ───────────────────────────────────────────────────── */
@keyframes mlt-wa-entrance {
  from { opacity: 0; transform: translateY(30px) scale(0.8); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes mlt-wa-entrance-middle {
  from { opacity: 0; transform: translateY(-50%) scale(0.8); }
  to   { opacity: 1; transform: translateY(-50%) scale(1); }
}

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 575.98px) {
  .mlt-wa--hide-mobile { display: none !important; }

  .mlt-wa { bottom: 16px !important; top: auto !important; transform: none !important; }
  .mlt-wa--bottom-right,
  .mlt-wa--middle-right,
  .mlt-wa--top-right    { right: 16px; }
  .mlt-wa--bottom-left,
  .mlt-wa--middle-left,
  .mlt-wa--top-left     { left: 16px; }

  .mlt-wa__card { width: 260px; padding: 16px 16px 14px; }
  .mlt-wa__fab  { width: 54px; height: 54px; }
  .mlt-wa__pill { padding: 10px 18px 10px 12px; font-size: 13px; }
}

/* ── Accessibility: reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .mlt-wa, .mlt-wa__card, .mlt-wa__fab,
  .mlt-wa__fab-icon, .mlt-wa__cta, .mlt-wa__pill {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .mlt-wa__fab-ping { animation: none !important; display: none; }
}
