/* ==========================================================
   WhatsApp Chat Plugin — Frontend Styles
   ========================================================== */

/* ── Variables ─────────────────────────── */
:root {
  --wa-green:        #25d366;
  --wa-dark-green:   #128c7e;
  --wa-deep-green:   #075e54;
  --wa-header-bg:    #075e54;
  --wa-text:         #333;
  --wa-radius:       16px;
  --wa-shadow:       0 8px 32px rgba(0,0,0,.18);
  --wa-btn-size:     70px;
  --wa-anim:         .28s cubic-bezier(.4,0,.2,1);
}

/* ── Widget container ────────────────────── */
.wachat {
  position: fixed;
  bottom: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.wachat--right { right: 24px; align-items: flex-end; }
.wachat--left  { left: 24px;  align-items: flex-start; }

/* ── Popup ───────────────────────────────── */
.wachat__popup {
  width: 320px;
  background: #fff;
  border-radius: var(--wa-radius);
  box-shadow: var(--wa-shadow);
  overflow: hidden;
  transform: scale(.85) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--wa-anim), transform var(--wa-anim);
}

.wachat--left .wachat__popup {
  transform-origin: bottom left;
}

.wachat__popup.wachat__popup--open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── Header ──────────────────────────────── */
.wachat__header {
  background: var(--wa-header-bg);
  padding: 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wachat__header-icon {
  background: rgba(255,255,255,.15);
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wachat__header-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wachat__header-title {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.wachat__header-sub {
  color: rgba(255,255,255,.75);
  font-size: 12px;
  line-height: 1.4;
}

.wachat__close {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 50%;
  transition: color var(--wa-anim), background var(--wa-anim);
  flex-shrink: 0;
}

.wachat__close:hover {
  color: #fff;
  background: rgba(255,255,255,.15);
}

/* ── Contacts list ───────────────────────── */
.wachat__contacts {
  padding: 8px 0;
  max-height: 340px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ddd transparent;
}

.wachat__contacts::-webkit-scrollbar { width: 4px; }
.wachat__contacts::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.wachat__contact {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--wa-text);
  transition: background var(--wa-anim);
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.wachat__contact:last-child { border-bottom: none; }

.wachat__contact:hover {
  background: #f3fdf6;
  text-decoration: none;
  color: var(--wa-text);
}

/* ── Avatar ──────────────────────────────── */
.wachat__avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

.wachat__avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.wachat__online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 11px;
  height: 11px;
  background: #25d366;
  border: 2px solid #fff;
  border-radius: 50%;
}

/* ── Contact info ────────────────────────── */
.wachat__contact-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
}

.wachat__contact-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #1a1a1a;
}

.wachat__contact-label {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wachat__contact-arrow {
  flex-shrink: 0;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--wa-anim), transform var(--wa-anim);
}

.wachat__contact:hover .wachat__contact-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ── Footer ──────────────────────────────── */
.wachat__footer {
  background: #f7f7f7;
  border-top: 1px solid #eee;
  text-align: center;
  padding: 8px 12px;
  font-size: 11px;
  color: #aaa;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* ── Floating button ─────────────────────── */
.wachat__btn {
  width: var(--wa-btn-size);
  height: var(--wa-btn-size);
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(37,211,102,.45);
  transition: transform var(--wa-anim), box-shadow var(--wa-anim);
  position: relative;
  flex-shrink: 0;
  padding: 0;
  overflow: visible;
}

.wachat__btn:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(37,211,102,.65);
}

.wachat__btn:active { transform: scale(.95); }

/* Icon toggle */
.wachat__btn-icon {
  position: absolute;
  transition: opacity var(--wa-anim), transform var(--wa-anim);
}

/* WA icon: fills the full button */
.wachat__btn-icon--wa {
  opacity: 1;
  transform: rotate(0deg) scale(1);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  display: block;
}

/* Close icon: sits centered, hidden by default */
.wachat__btn-icon--close {
  opacity: 0;
  transform: rotate(-90deg) scale(.5);
  background: var(--wa-green);
  border-radius: 50%;
  padding: 6px;
  width: 34px;
  height: 34px;
  box-sizing: content-box;
}

/* Swap on open */
.wachat--open .wachat__btn-icon--wa    { opacity: 0; transform: rotate(90deg) scale(.5); }
.wachat--open .wachat__btn-icon--close { opacity: 1; transform: rotate(0deg) scale(1); }

/* Pulse ring animation */
.wachat__btn::before {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--wa-green);
  animation: wachat-pulse 2.2s ease-out infinite;
  opacity: 0;
  pointer-events: none;
}

@keyframes wachat-pulse {
  0%   { transform: scale(1);   opacity: .7; }
  80%  { transform: scale(1.6); opacity: 0;  }
  100% { transform: scale(1.6); opacity: 0;  }
}

/* ── Notification badge ──────────────────── */
.wachat__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  transition: opacity var(--wa-anim), transform var(--wa-anim);
}

.wachat__badge--hidden {
  opacity: 0;
  transform: scale(0);
  pointer-events: none;
}

/* ── Tooltip ─────────────────────────────── */
.wachat__tooltip {
  background: rgba(0,0,0,.75);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity .2s, transform .2s;
}

.wachat:not(.wachat--open):hover .wachat__tooltip {
  opacity: 1;
  transform: translateY(0);
}

/* ── Mobile ──────────────────────────────── */
@media (max-width: 480px) {
  .wachat { bottom: 16px; }
  .wachat--right { right: 16px; }
  .wachat--left  { left:  16px; }

  .wachat__popup {
    width: calc(100vw - 32px);
    max-width: 340px;
  }

  :root { --wa-btn-size: 62px; }
  .wachat__btn-icon--wa { width: 62px; height: 62px; }
}
