/* ================================================================
   WordPress WhatsApp Chat — Widget Styles
   ================================================================ */

/* ── Container ── */
.wwc-widget {
  position: fixed;
  z-index: 99999;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  transition: transform 0.25s ease;
}

.wwc-widget.wwc-bottom-right {
  right: 24px;
  align-items: flex-end;
}

.wwc-widget.wwc-bottom-left {
  left: 24px;
  align-items: flex-start;
}

/* ── Popup ── */
.wwc-popup {
  width: 340px;
  max-height: 480px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0, 0, 0, 0.10);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(1) translateY(0);
  opacity: 1;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.22s ease;
  pointer-events: auto;
}

.wwc-widget.wwc-bottom-left .wwc-popup {
  transform-origin: bottom left;
}

.wwc-popup.wwc-hidden {
  display: none;
}

.wwc-popup.wwc-collapsing {
  transform: scale(0.85) translateY(16px);
  opacity: 0;
  pointer-events: none;
}

/* ── Popup Header ── */
.wwc-popup-header {
  background: #25D366;
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}

.wwc-agent-avatar-wrap {
  position: relative;
  flex-shrink: 0;
}

.wwc-agent-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.5);
  display: block;
}

.wwc-agent-avatar-placeholder {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.wwc-online-dot {
  width: 11px;
  height: 11px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid #fff;
  position: absolute;
  bottom: 1px;
  right: 1px;
}

.wwc-agent-info {
  flex: 1;
  min-width: 0;
}

.wwc-agent-name {
  display: block;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wwc-agent-title {
  display: block;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  line-height: 1.4;
  margin-top: 1px;
}

.wwc-chevron-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
  color: #fff;
}

.wwc-chevron-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.wwc-chevron-btn svg {
  display: block;
  transition: transform 0.2s ease;
}

/* ── Chat Body ── */
.wwc-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background-color: #e5ddd5;
  background-image:
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c8bdb5' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-height: 140px;
}

/* ── Message Bubble ── */
.wwc-message-bubble {
  background: #fff;
  border-radius: 0 12px 12px 12px;
  padding: 10px 12px 8px;
  max-width: 80%;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  position: relative;
}

.wwc-message-bubble::before {
  content: '';
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 8px 0;
  border-color: transparent #fff transparent transparent;
}

.wwc-bubble-agent-name {
  display: block;
  font-weight: 700;
  font-size: 12.5px;
  margin-bottom: 4px;
  line-height: 1;
}

.wwc-bubble-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #111b21;
  word-break: break-word;
}

.wwc-bubble-time {
  display: block;
  font-size: 11px;
  color: #8696a0;
  text-align: right;
  margin-top: 4px;
  line-height: 1;
}

/* ── Chat Footer ── */
.wwc-chat-footer {
  background: #f0f2f5;
  border-top: 1px solid #e9edef;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.wwc-message-input {
  flex: 1;
  border: none;
  outline: none;
  background: #fff;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 15px;
  color: #111b21;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  min-width: 0;
  resize: none;
  height: 38px;
  line-height: 20px;
}

.wwc-message-input::placeholder {
  color: #8696a0;
}

.wwc-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #25D366;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, filter 0.15s;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.wwc-send-btn:hover {
  filter: brightness(1.1);
  transform: scale(1.06);
}

.wwc-send-btn svg {
  display: block;
}

/* ── FAB Row (button + X) ── */
.wwc-fab-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wwc-widget.wwc-bottom-left .wwc-fab-row {
  flex-direction: row-reverse;
}

/* ── Main Floating Button ── */
.wwc-button {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #25D366;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(37, 211, 102, 0.45), 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
  flex-shrink: 0;
  position: relative;
}

.wwc-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 24px rgba(37, 211, 102, 0.55), 0 2px 8px rgba(0,0,0,0.18);
}

.wwc-button svg {
  display: block;
}

/* ── Pulse animation on FAB ── */
.wwc-button::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  opacity: 0;
  animation: wwc-pulse 2.5s ease-out infinite;
}

@keyframes wwc-pulse {
  0%   { transform: scale(1);   opacity: 0.45; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* ── X (Dismiss) Button ── */
.wwc-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
  align-self: flex-end;
  margin-bottom: 4px;
}

.wwc-close-btn:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.1);
}

/* ── Popup open: hide FAB and remove gap ── */
.wwc-widget.wwc-open .wwc-fab-row {
  display: none;
}

.wwc-widget.wwc-open .wwc-popup {
  margin-bottom: 0;
}

/* ── Widget hidden entirely ── */
.wwc-widget.wwc-dismissed {
  display: none !important;
}

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
  .wwc-widget.wwc-bottom-right {
    right: 12px;
  }

  .wwc-widget.wwc-bottom-left {
    left: 12px;
  }

  .wwc-widget {
    bottom: 16px;
  }

  .wwc-popup {
    width: calc(100vw - 24px);
    max-width: 340px;
    max-height: 420px;
  }

  .wwc-button {
    width: 54px;
    height: 54px;
  }
}

@media (max-width: 360px) {
  .wwc-popup {
    width: calc(100vw - 16px);
  }
}
