/*
 * WhatsApp Chat widget — frontend styles.
 *
 * Scoped under .wachat to keep the namespace clean. All themable values
 * are CSS custom properties, set from the template via the `style`
 * attribute so a single hex override re-themes the whole widget.
 *
 * Visual reference: WhatsApp Business "Click to Chat" widget.
 */

.wachat {
  --wachat-accent: #1c7f70;
  --wachat-accent-dark: color-mix(in srgb, var(--wachat-accent) 85%, #000);
  --wachat-text: #1a1a1a;
  --wachat-muted: #6b7280;
  --wachat-border: #eef0f4;
  --wachat-bg: #fff;
  --wachat-shadow: 0 12px 32px rgba(20, 30, 50, 0.18);

  position: fixed;
  z-index: 2147483600; /* sit above most overlays; below browser UI */
  bottom: 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--wachat-text);
  line-height: 1.4;
  /* The container is just a positioning anchor — on mobile it stretches
   * full-width so the FAB can right-align via margin-left:auto. Without
   * this, the transparent area on the left intercepts taps on neighbours
   * (e.g. the gdpr cookie button at bottom-left). */
  pointer-events: none;
}
.wachat__panel--closed,
.wachat__panel--open { pointer-events: auto; }

.wachat--bottom-right { right: 20px; }
.wachat--bottom-left  { left:  20px; }

/* ----------------------------------------------------------------
   Closed state — circular FAB
   ---------------------------------------------------------------- */
.wachat__panel--closed {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border: 0;
  border-radius: 50%;
  background: var(--wachat-accent);
  cursor: pointer;
  box-shadow: var(--wachat-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  padding: 0;
}
.wachat__panel--closed:hover,
.wachat__panel--closed:focus-visible {
  background: var(--wachat-accent-dark);
  transform: translateY(-2px);
  outline: none;
  box-shadow: 0 16px 36px rgba(20, 30, 50, 0.22);
}
.wachat__panel--closed:focus-visible {
  box-shadow: var(--wachat-shadow), 0 0 0 3px rgba(28, 127, 112, 0.25);
}
.wachat__logo { width: 26px; height: 26px; }
.wachat__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* When the panel is open, the FAB hides. */
.wachat.is-open .wachat__panel--closed { display: none; }

/* ----------------------------------------------------------------
   Open state — panel
   ---------------------------------------------------------------- */
.wachat__panel--open[hidden] { display: none; }
.wachat__panel--open {
  width: min(420px, calc(100vw - 32px));
  max-height: min(640px, calc(100vh - 80px));
  background: var(--wachat-bg);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--wachat-shadow);
  display: flex;
  flex-direction: column;
  animation: wachat-open 0.18s ease-out;
}

@keyframes wachat-open {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ----------------------------------------------------------------
   Header
   ---------------------------------------------------------------- */
.wachat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--wachat-accent), var(--wachat-accent-dark));
  color: #fff;
}
.wachat__avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.wachat__avatar svg { width: 22px; height: 22px; }
.wachat__title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.wachat__title strong {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.1px;
}
/* The wrapper + inner text are both forced — themes commonly target
 * the `small` element with !important, and may also target colour
 * inside dark backgrounds. We're inside a header with white-on-teal,
 * so be explicit. */
.wachat__status,
.wachat .wachat__status,
.wachat .wachat__status .wachat__status-text {
  font-size: 12px !important;
  font-weight: 500 !important;
  color: #fff !important;
  opacity: 1 !important;
  line-height: 1.2 !important;
}
.wachat__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.wachat__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4), 0 0 6px rgba(74, 222, 128, 0.6);
  animation: wachat-pulse 2s ease-in-out infinite;
}
@keyframes wachat-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.4), 0 0 6px rgba(74, 222, 128, 0.6); }
  50%      { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.5), 0 0 10px rgba(74, 222, 128, 0.9); }
}
.wachat__close {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.15s ease;
}
.wachat__close:hover,
.wachat__close:focus-visible { background: rgba(255, 255, 255, 0.28); outline: none; }
.wachat__close svg { width: 12px; height: 12px; }

/* ----------------------------------------------------------------
   Body
   ---------------------------------------------------------------- */
.wachat__body {
  padding: 16px;
  overflow-y: auto;
  background: #f6f8fa;
}
.wachat__greeting {
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid var(--wachat-border);
}
.wachat__topics-heading {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--wachat-muted);
  margin: 6px 0 8px;
}

.wachat__topics {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.wachat__topic {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--wachat-border);
  border-radius: 10px;
  color: var(--wachat-text);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.wachat__topic:hover,
.wachat__topic:focus-visible {
  border-color: var(--wachat-accent);
  box-shadow: 0 2px 8px rgba(28, 127, 112, 0.12);
  transform: translateY(-1px);
  text-decoration: none;
  outline: none;
}
.wachat__topic-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  color: var(--wachat-accent);
}
.wachat__topic-label { flex: 1; }
.wachat__topic-chevron { color: var(--wachat-muted); }
.wachat__topic-chevron svg { width: 12px; height: 12px; display: block; }

.wachat__topic--solo {
  justify-content: center;
  background: var(--wachat-accent);
  color: #fff;
  border-color: var(--wachat-accent);
  font-weight: 700;
}
.wachat__topic--solo:hover,
.wachat__topic--solo:focus-visible {
  background: var(--wachat-accent-dark);
  border-color: var(--wachat-accent-dark);
  color: #fff;
}

/* ----------------------------------------------------------------
   Injected contact line — see widget.js hydrateContactLists().
   Lives inside the theme's existing ul.contact, so it inherits
   padding/font/layout from .info-toolbar .contact li. We only
   override the icon color to WhatsApp green so the item reads as
   a WhatsApp action rather than another generic phone.
   ---------------------------------------------------------------- */
ul.contact li.wachat-line i.fa-whatsapp,
ul.contact li.wachat-line i.fab.fa-whatsapp {
  color: #25d366;
}
ul.contact li.wachat-line a:hover {
  color: #25d366;
}

/* ----------------------------------------------------------------
   Mobile
   ---------------------------------------------------------------- */
@media (max-width: 480px) {
  .wachat--bottom-right,
  .wachat--bottom-left {
    right: 12px;
    left:  12px;
    bottom: 12px;
  }
  .wachat__panel--closed {
    margin-left: auto;
    display: flex;
  }
  .wachat__panel--open {
    width: auto;
    max-height: calc(100vh - 24px);
  }
}
