/*!
 * Floating WhatsApp CTA card.
 * Markup: components/whatsapp_cta_card.html
 * The card chrome lives here; the copy comes from the
 * "whatsapp_float_button" django CMS Alias (or the i18n fallback).
 */

#wa-cta-card,
#wa-cta-card *,
#wa-cta-bubble,
#wa-cta-bubble * {
  box-sizing: border-box;
}

#wa-cta-card {
  --wa-cta-green: #25d366;
  --wa-cta-green-dark: #1ebe5b;
  --wa-cta-surface: #0b1220;
  --wa-cta-text: #f8fafc;
  --wa-cta-muted: #cbd5e1;

  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  width: 360px;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  z-index: 1060;
  padding: 0;
  background: var(--wa-cta-surface);
  color: var(--wa-cta-text);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(2, 6, 23, 0.55), 0 2px 8px rgba(2, 6, 23, 0.35);
  font-family: inherit;
  text-align: left;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
}

/* With JavaScript enabled the card starts hidden and is revealed by the
   component script; without JS it stays visible as a plain floating card. */
.wa-cta-js #wa-cta-card {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(16px) scale(0.98);
}

.wa-cta-js #wa-cta-card.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* CMS edit mode: keep it in the flow so the Alias stays editable. */
#wa-cta-card.wa-cta--edit {
  position: static;
  width: 100%;
  max-width: 420px;
  max-height: none;
  margin: 32px auto;
  overflow: visible;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  border: 1px dashed rgba(255, 255, 255, 0.45);
  box-shadow: none;
  z-index: auto;
}

#wa-cta-card.wa-cta--edit .wa-cta__body {
  max-height: none;
  overflow: visible;
}

#wa-cta-card .wa-cta__edit-hint {
  margin: 0;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.4;
}

/* ---------- Header ---------- */

#wa-cta-card .wa-cta__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 52px 8px 16px;
}

#wa-cta-card .wa-cta__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--wa-cta-green);
  box-shadow: 0 8px 18px -6px rgba(37, 211, 102, 0.65);
}

#wa-cta-card .wa-cta__avatar svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: #ffffff;
}

#wa-cta-card .wa-cta__status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #4ade80;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-transform: uppercase;
}

#wa-cta-card .wa-cta__dot {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

#wa-cta-card .wa-cta__close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease;
}

#wa-cta-card .wa-cta__close:hover {
  background: rgba(255, 255, 255, 0.18);
}

#wa-cta-card .wa-cta__close:focus-visible {
  outline: 2px solid var(--wa-cta-green);
  outline-offset: 2px;
}

#wa-cta-card.wa-cta--edit .wa-cta__close {
  display: none;
}

/* ---------- Alias / fallback content ---------- */

#wa-cta-card .wa-cta__body {
  max-height: min(60vh, 420px);
  overflow-y: auto;
  padding: 4px 16px 16px;
  overflow-wrap: anywhere;
}

#wa-cta-card .wa-cta__body > :first-child {
  margin-top: 0;
}

#wa-cta-card .wa-cta__body > :last-child {
  margin-bottom: 0;
}

#wa-cta-card .wa-cta__body h1,
#wa-cta-card .wa-cta__body h2,
#wa-cta-card .wa-cta__body h3,
#wa-cta-card .wa-cta__body h4,
#wa-cta-card .wa-cta__body h5,
#wa-cta-card .wa-cta__body h6 {
  margin: 0 0 8px;
  padding: 0;
  color: var(--wa-cta-text);
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.35;
}

#wa-cta-card .wa-cta__body p,
#wa-cta-card .wa-cta__body li {
  margin: 0 0 10px;
  color: var(--wa-cta-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1.5;
}

#wa-cta-card .wa-cta__body ul,
#wa-cta-card .wa-cta__body ol {
  margin: 0 0 10px;
  padding-left: 18px;
}

#wa-cta-card .wa-cta__body img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 0 10px;
  border-radius: 10px;
}

#wa-cta-card .wa-cta__body p a {
  display: inline;
  width: auto;
  padding: 0;
  border-radius: 0;
  background: transparent !important;
  color: var(--wa-cta-green) !important;
  font-weight: 600;
  text-decoration: underline !important;
}

/* Any WhatsApp link inside the alias content becomes the primary button. */
#wa-cta-card .wa-cta__body a[href*="wa.me"],
#wa-cta-card .wa-cta__body a[href*="api.whatsapp.com"],
#wa-cta-card .wa-cta__body a[href*="whatsapp://"],
#wa-cta-card .wa-cta__body .wa-cta__action {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin: 4px 0 0;
  padding: 11px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--wa-cta-green) !important;
  color: #ffffff !important;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none !important;
  box-shadow: 0 10px 20px -10px rgba(37, 211, 102, 0.8);
  transition: background 0.2s ease, transform 0.2s ease;
}

#wa-cta-card .wa-cta__body a[href*="wa.me"]:hover,
#wa-cta-card .wa-cta__body a[href*="api.whatsapp.com"]:hover,
#wa-cta-card .wa-cta__body a[href*="whatsapp://"]:hover,
#wa-cta-card .wa-cta__body .wa-cta__action:hover {
  background: var(--wa-cta-green-dark) !important;
  color: #ffffff !important;
  transform: translateY(-1px);
}

#wa-cta-card .wa-cta__body a:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

#wa-cta-card .wa-cta__body a svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* ---------- Minimized bubble ---------- */

#wa-cta-bubble {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 1059;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--wa-cta-green, #25d366);
  color: #ffffff;
  box-shadow: 0 16px 32px -10px rgba(37, 211, 102, 0.7), 0 4px 12px rgba(2, 6, 23, 0.2);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#wa-cta-bubble.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: scale(1);
}

#wa-cta-bubble:hover {
  transform: scale(1.06);
}

#wa-cta-bubble:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 3px;
}

#wa-cta-bubble svg {
  display: block;
  width: 30px;
  height: 30px;
  fill: #ffffff;
}

/* ---------- Responsive ---------- */

@media (max-width: 575.98px) {
  #wa-cta-card {
    right: 12px;
    left: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-width: none;
  }

  #wa-cta-card .wa-cta__body {
    max-height: 55vh;
  }

  #wa-cta-bubble {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 359.98px) {
  #wa-cta-card .wa-cta__header {
    padding: 14px 48px 6px 14px;
  }

  #wa-cta-card .wa-cta__body {
    padding: 4px 14px 14px;
  }
}

/* ---------- Preferences ---------- */

@media (prefers-reduced-motion: reduce) {
  #wa-cta-card,
  #wa-cta-bubble,
  #wa-cta-card .wa-cta__body a,
  #wa-cta-card .wa-cta__body a[href*="wa.me"] {
    transition: none !important;
    transform: none !important;
  }
}

@media print {
  #wa-cta-card,
  #wa-cta-bubble {
    display: none !important;
  }
}
