/**
 * Module 19 : Bouton WhatsApp flottant
 * Thème Storefront Child - TAMISIER MACHINES AGRICOLES
 */

/* ==========================================================================
   1. BOUTON FLOTTANT
   ========================================================================== */

.tma-wa {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.tma-wa-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: #25d366;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 10px 24px -8px rgba(37, 211, 102, 0.75), 0 2px 8px rgba(15, 23, 42, 0.16);
  transition: transform 0.16s ease, background-color 0.16s ease;
}

.tma-wa-btn svg {
  width: 30px;
  height: 30px;
  display: block;
}

.tma-wa-btn:hover {
  background-color: #1ebe5b;
  transform: scale(1.06);
}

.tma-wa-btn:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.45);
  outline-offset: 3px;
}

/* ==========================================================================
   2. BOÎTE DE DIALOGUE
   ========================================================================== */

.tma-wa-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 336px;
  max-width: calc(100vw - 44px);
  background-color: #ffffff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 24px 48px -18px rgba(15, 23, 42, 0.45), 0 2px 8px rgba(15, 23, 42, 0.1);
  transform-origin: bottom right;
  animation: tma-wa-in 0.18s ease-out;
}

.tma-wa-panel[hidden] {
  display: none;
}

@keyframes tma-wa-in {
  from { opacity: 0; transform: scale(0.92) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* --- en-tête --- */

.tma-wa-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1rem;
  background-color: #075e54;
  color: #ffffff;
}

.tma-wa-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  background-color: #25d366;
  color: #ffffff;
  font-weight: 700;
  font-size: 1rem;
}

.tma-wa-id {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  flex: 1 1 auto;
  min-width: 0;
}

.tma-wa-name {
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tma-wa-status {
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.78);
}

.tma-wa-close {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.tma-wa-close:hover {
  background-color: rgba(255, 255, 255, 0.26);
}

/* --- corps --- */

.tma-wa-body {
  padding: 1rem;
  background-color: #ece5dd;
  background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px);
  background-size: 12px 12px;
}

.tma-wa-bubble {
  position: relative;
  margin: 0 !important;
  padding: 0.7rem 0.85rem;
  background-color: #ffffff;
  border-radius: 10px 10px 10px 2px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: #1e2322;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

/* --- bouton d'action --- */

.tma-wa-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.85rem 1rem;
  background-color: #25d366;
  color: #ffffff !important;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none !important;
  transition: background-color 0.15s ease;
}

.tma-wa-cta:hover {
  background-color: #1ebe5b;
  color: #ffffff !important;
}

.tma-wa-cta:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.45);
  outline-offset: -3px;
}

/* ==========================================================================
   3. RESPONSIVE
   ========================================================================== */

@media (max-width: 640px) {
  .tma-wa {
    right: 16px;
    bottom: 16px;
  }

  .tma-wa-btn {
    width: 52px;
    height: 52px;
  }

  .tma-wa-btn svg {
    width: 27px;
    height: 27px;
  }

  .tma-wa-panel {
    width: calc(100vw - 32px);
    max-width: 360px;
    bottom: 66px;
  }
}

/* Respect des préférences d'animation */
@media (prefers-reduced-motion: reduce) {
  .tma-wa-panel {
    animation: none;
  }

  .tma-wa-btn,
  .tma-wa-cta,
  .tma-wa-close {
    transition: none;
  }
}
