/* Metafortech — premium floating WhatsApp CTA */
:root {
  --wa-ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --wa-ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --wa-green: #25d366;
  --wa-green-light: #3ee07a;
  --wa-brand: #c24bda;
  --wa-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 16px 48px rgba(0, 0, 0, 0.45),
    0 0 32px rgba(194, 75, 218, 0.12);
  --wa-shadow-hover:
    0 0 0 1px rgba(255, 255, 255, 0.1) inset,
    0 22px 56px rgba(0, 0, 0, 0.5),
    0 0 48px rgba(37, 211, 102, 0.2),
    0 0 32px rgba(194, 75, 218, 0.25);
}

.whatsapp-float {
  position: fixed;
  z-index: 99999;
  bottom: max(24px, env(safe-area-inset-bottom));
  inset-inline-end: max(24px, env(safe-area-inset-right));
  inset-inline-start: auto;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  width: auto !important;
  height: auto !important;
  min-height: 56px;
  min-width: max-content;
  padding: 10px 16px 10px 10px;
  max-width: min(360px, calc(100vw - 32px));
  background: linear-gradient(135deg, rgba(18, 17, 35, 0.97) 0%, rgba(28, 27, 51, 0.95) 100%);
  border-radius: 999px !important;
  border: 1px solid rgba(194, 75, 218, 0.35);
  box-shadow: var(--wa-shadow);
  color: #fff;
  text-decoration: none !important;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translate3d(0, 28px, 0);
  transition:
    transform 0.35s var(--wa-ease-out),
    box-shadow 0.35s ease,
    border-color 0.35s ease,
    opacity 0.4s ease;
  flex-shrink: 0;
}

.whatsapp-float.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate3d(0, 0, 0);
}

.whatsapp-float.is-visible:hover,
.whatsapp-float.is-visible:focus-visible {
  /* رفع خفيف فقط — بدون scale حتى لا ينكمش شكل الكبسولة لدائرة */
  transform: translate3d(0, -4px, 0);
  border-color: rgba(194, 75, 218, 0.65);
  box-shadow: var(--wa-shadow-hover);
  color: #fff;
  width: auto !important;
  height: auto !important;
  min-width: max-content;
  border-radius: 999px !important;
}

.whatsapp-float.is-attention:not(:hover):not(:focus-visible) {
  animation: wa-attention-glow 1.1s var(--wa-ease-out);
}

.whatsapp-float__glow {
  position: absolute;
  inset: -40%;
  background: radial-gradient(circle at 30% 50%, rgba(37, 211, 102, 0.18) 0%, transparent 55%),
    radial-gradient(circle at 80% 50%, rgba(194, 75, 218, 0.14) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0.8;
}

.whatsapp-float__shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 38%,
    rgba(255, 255, 255, 0.07) 48%,
    transparent 58%
  );
  transform: translateX(-120%);
  animation: wa-shine 5s ease-in-out 2.5s infinite;
  pointer-events: none;
}

.whatsapp-float__ring {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  border-radius: 50%;
  border: 2px solid rgba(37, 211, 102, 0.45);
  pointer-events: none;
  opacity: 0;
}

.whatsapp-float.is-visible .whatsapp-float__ring--1 {
  animation: wa-ring 2.4s var(--wa-ease-out) 0.8s infinite;
}

.whatsapp-float.is-visible .whatsapp-float__ring--2 {
  animation: wa-ring 2.4s var(--wa-ease-out) 1.6s infinite;
}

.whatsapp-float__icon-wrap {
  position: relative;
  z-index: 2;
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
}

.whatsapp-float__icon {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--wa-green-light) 0%, var(--wa-green) 50%, #1aad56 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 24px rgba(37, 211, 102, 0.45),
    0 0 0 3px rgba(37, 211, 102, 0.15);
  transform: scale(1);
  transition: transform 0.3s var(--wa-ease-out), box-shadow 0.3s ease;
}

.whatsapp-float.is-visible .whatsapp-float__icon {
  animation: wa-icon-pop 0.7s var(--wa-ease-expo) 0.35s forwards;
}

.whatsapp-float.is-visible:hover .whatsapp-float__icon,
.whatsapp-float.is-visible:focus-visible .whatsapp-float__icon {
  animation: none;
  transform: scale(1.06);
  box-shadow:
    0 10px 28px rgba(37, 211, 102, 0.55),
    0 0 0 4px rgba(37, 211, 102, 0.2);
}

.whatsapp-float__icon svg {
  display: block;
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

.whatsapp-float__status {
  position: absolute;
  top: 2px;
  inset-inline-end: 2px;
  z-index: 3;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid #121123;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.7);
}

.whatsapp-float.is-visible .whatsapp-float__status {
  animation: wa-status-pulse 2s ease-in-out 1s infinite;
}

.whatsapp-float__copy {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  text-align: start;
  flex-shrink: 0;
  opacity: 0;
  transform: translate3d(-8px, 0, 0);
  transition: opacity 0.45s var(--wa-ease-out) 0.55s, transform 0.45s var(--wa-ease-out) 0.55s;
}

.whatsapp-float.is-visible .whatsapp-float__copy {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.whatsapp-float:hover .whatsapp-float__copy,
.whatsapp-float:focus-visible .whatsapp-float__copy {
  opacity: 1;
  transform: translate3d(0, 0, 0);
  visibility: visible;
}

.whatsapp-float__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4ade80;
  line-height: 1.2;
}

.whatsapp-float__eyebrow::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: wa-status-pulse 2s ease-in-out infinite;
}

.whatsapp-float__title {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
  letter-spacing: -0.01em;
  background: linear-gradient(90deg, #fff 0%, #f0e6ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.whatsapp-float__subtitle {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  color: rgba(255, 255, 255, 0.62);
}

.whatsapp-float__arrow {
  position: relative;
  z-index: 2;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-inline-start: -4px;
  flex-shrink: 0;
  color: var(--wa-brand);
  opacity: 0;
  transform: translate3d(-6px, 0, 0);
  transition: opacity 0.35s ease 0.7s, transform 0.35s var(--wa-ease-out) 0.7s, color 0.25s ease;
}

.whatsapp-float.is-visible .whatsapp-float__arrow {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.whatsapp-float.is-visible:hover .whatsapp-float__arrow,
.whatsapp-float.is-visible:focus-visible .whatsapp-float__arrow {
  transform: translate3d(4px, 0, 0);
  color: var(--wa-green-light);
}

.whatsapp-float__arrow svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes wa-ring {
  0% {
    transform: scale(0.75);
    opacity: 0.7;
  }
  100% {
    transform: scale(1.65);
    opacity: 0;
  }
}

@keyframes wa-shine {
  0%, 72% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(120%);
  }
}

@keyframes wa-icon-pop {
  0% {
    transform: scale(0.6);
    opacity: 0;
  }
  70% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes wa-status-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.15);
    opacity: 0.85;
  }
}

@keyframes wa-attention-glow {
  0%, 100% {
    box-shadow: var(--wa-shadow);
  }
  50% {
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.08) inset,
      0 20px 52px rgba(0, 0, 0, 0.48),
      0 0 56px rgba(37, 211, 102, 0.28),
      0 0 40px rgba(194, 75, 218, 0.22);
  }
}

@media screen and (max-width: 991px) {
  .whatsapp-float {
    min-width: max-content !important;
  }
}

@media screen and (max-width: 575px) {
  .whatsapp-float {
    gap: 10px;
    padding: 8px 14px 8px 8px;
    bottom: max(16px, env(safe-area-inset-bottom));
    inset-inline-end: max(16px, env(safe-area-inset-right));
    max-width: min(320px, calc(100vw - 24px));
  }

  .whatsapp-float__icon-wrap {
    flex-basis: 46px;
    width: 46px;
    height: 46px;
  }

  .whatsapp-float__ring {
    width: 46px;
    height: 46px;
    margin-top: -23px;
    inset-inline-start: 8px;
  }

  .whatsapp-float__icon svg {
    width: 24px;
    height: 24px;
  }

  .whatsapp-float__title {
    font-size: 13px;
  }

  .whatsapp-float__subtitle {
    font-size: 10px;
  }

  .whatsapp-float__eyebrow {
    font-size: 9px;
  }
}

@media screen and (max-width: 380px) {
  .whatsapp-float__subtitle {
    display: none;
  }

  .whatsapp-float__arrow {
    display: none;
  }
}

[dir="rtl"] .whatsapp-float__copy {
  transform: translate3d(8px, 0, 0);
}

[dir="rtl"] .whatsapp-float.is-visible .whatsapp-float__copy {
  transform: translate3d(0, 0, 0);
}

[dir="rtl"] .whatsapp-float:hover .whatsapp-float__copy,
[dir="rtl"] .whatsapp-float:focus-visible .whatsapp-float__copy {
  transform: translate3d(0, 0, 0);
}

[dir="rtl"] .whatsapp-float__arrow {
  transform: translate3d(6px, 0, 0);
}

[dir="rtl"] .whatsapp-float.is-visible .whatsapp-float__arrow {
  transform: translate3d(0, 0, 0);
}

[dir="rtl"] .whatsapp-float.is-visible:hover .whatsapp-float__arrow,
[dir="rtl"] .whatsapp-float.is-visible:focus-visible .whatsapp-float__arrow {
  transform: translate3d(-4px, 0, 0);
}

[dir="rtl"] .whatsapp-float__arrow svg {
  transform: scaleX(-1);
}

@media (prefers-reduced-motion: reduce) {
  .whatsapp-float {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
  }

  .whatsapp-float.is-visible .whatsapp-float__copy,
  .whatsapp-float.is-visible .whatsapp-float__arrow {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .whatsapp-float,
  .whatsapp-float__ring,
  .whatsapp-float__shine,
  .whatsapp-float__icon,
  .whatsapp-float__status,
  .whatsapp-float__eyebrow::before,
  .whatsapp-float.is-attention {
    animation: none !important;
  }
}
