/**
 * AZADIGI Floating UI Styles
 * WhatsApp floating button, Back to top controller, and Honest Activity popup.
 *
 * Designed for 0px horizontal overflow, strict non-collision on mobile,
 * and WCAG AA accessible contrast & touch targets.
 */

/* Container wrapper */
.az-floating-ui-wrapper {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
  z-index: 9990;
}

/* ==========================================================================
   1. Bottom-Right Floating Controls Stack (WhatsApp + Back to Top)
   ========================================================================== */
.az-floating-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  pointer-events: auto;
  z-index: 9995;
}

/* Floating WhatsApp Button */
.az-floating-whatsapp {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  min-width: 44px;
  min-height: 44px;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #ffffff !important;
  border-radius: 50%;
  box-shadow: 0 4px 14px rgba(18, 140, 126, 0.4), 0 2px 6px rgba(0, 0, 0, 0.1);
  text-decoration: none !important;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.az-floating-whatsapp:hover,
.az-floating-whatsapp:focus {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(18, 140, 126, 0.5), 0 3px 8px rgba(0, 0, 0, 0.15);
  color: #ffffff !important;
}

.az-floating-whatsapp:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 3px;
}

.az-floating-whatsapp svg {
  width: 30px;
  height: 30px;
  fill: #ffffff;
  transition: transform 0.2s ease;
}

.az-floating-whatsapp:hover svg {
  transform: rotate(5deg) scale(1.05);
}

/* Online Pulse Dot */
.az-floating-online-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background-color: #22c55e;
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: azPulse 2.5s infinite;
}

@keyframes azPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(34, 197, 94, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* Back to Top Button */
.az-back-to-top {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  background-color: #0f172a;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s ease, background-color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.az-back-to-top.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.az-back-to-top:hover,
.az-back-to-top:focus {
  background-color: #1e293b;
  color: #38bdf8;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.az-back-to-top:focus-visible {
  outline: 3px solid #0284c7;
  outline-offset: 3px;
}

.az-back-to-top svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
}

/* ==========================================================================
   2. Bottom-Left Honest Activity / Discovery Popup
   ========================================================================== */
.az-activity-popup {
  position: fixed;
  bottom: 24px;
  left: 24px;
  width: 350px;
  max-width: calc(100vw - 100px);
  pointer-events: auto;
  z-index: 9992;
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.az-activity-popup.is-active {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.az-activity-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.az-activity-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 12px 28px -5px rgba(15, 23, 42, 0.16);
}

/* Media / Icon Thumbnail */
.az-activity-media {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  overflow: hidden;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.az-activity-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.az-activity-icon-badge {
  font-size: 1.25rem;
  line-height: 1;
}

/* Card Body */
.az-activity-body {
  flex: 1;
  min-width: 0;
}

.az-activity-headline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.az-activity-tag {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #16a34a;
  background-color: #f0fdf4;
  padding: 2px 6px;
  border-radius: 4px;
}

.az-activity-tag.is-discovery {
  color: #0284c7;
  background-color: #f0f9ff;
}

.az-activity-time {
  font-size: 0.6875rem;
  color: #64748b;
  white-space: nowrap;
}

.az-activity-msg {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.35;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Controls (Mute & Close) — Touch target >= 44px */
.az-activity-controls {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-left: 2px;
}

.az-activity-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: 1.25rem;
  line-height: 1;
  transition: color 0.15s ease, background-color 0.15s ease;
  -webkit-tap-highlight-color: transparent;
}

.az-activity-btn:hover {
  color: #0f172a;
  background-color: #f1f5f9;
}

.az-activity-btn:focus-visible {
  outline: 2px solid #0284c7;
  color: #0f172a;
}

/* ==========================================================================
   3. Strict Mobile Responsive Spacing & Non-Collision Guard
   ========================================================================== */
@media (max-width: 768px) {
  .az-floating-stack {
    bottom: 16px;
    right: 16px;
    gap: 8px;
  }

  .az-floating-whatsapp {
    width: 48px;
    height: 48px;
    min-width: 44px;
    min-height: 44px;
  }

  .az-floating-whatsapp svg {
    width: 26px;
    height: 26px;
  }

  /* Back to Top mobile target strictly >= 44px */
  .az-back-to-top {
    width: 46px;
    height: 46px;
    min-width: 44px;
    min-height: 44px;
  }

  /* Activity Popup on mobile docks to bottom-left with safe distance from WhatsApp */
  .az-activity-popup {
    bottom: 16px;
    left: 12px;
    width: calc(100vw - 84px);
    max-width: 310px;
  }

  .az-activity-card {
    padding: 8px 10px;
    gap: 8px;
  }

  .az-activity-media {
    width: 38px;
    height: 38px;
  }

  .az-activity-msg {
    font-size: 0.75rem;
  }
}

@media (max-width: 390px) {
  .az-activity-popup {
    left: 8px;
    width: calc(100vw - 78px);
    max-width: 290px;
  }

  .az-activity-card {
    padding: 6px 8px;
    gap: 6px;
  }

  .az-activity-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
}

@media (max-width: 320px) {
  .az-floating-stack {
    right: 8px;
    bottom: 12px;
    gap: 6px;
  }

  .az-floating-whatsapp {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .az-back-to-top {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .az-activity-popup {
    left: 6px;
    bottom: 12px;
    width: calc(100vw - 70px);
    max-width: 244px;
  }

  .az-activity-tag {
    font-size: 0.625rem;
  }

  .az-activity-time {
    display: none; /* Hide time on extreme narrow screens to prevent text wrapping */
  }

  .az-activity-msg {
    font-size: 0.6875rem;
    -webkit-line-clamp: 2;
  }

  .az-activity-media {
    width: 32px;
    height: 32px;
  }
}
