/* Chat Widget & Lead Tracker – WhatsApp-style UI + Chaty-inspired effects */
@font-face {
  font-family: "WALT-System";
  src: local("Segoe UI"), local("Helvetica Neue"), local("Arial"), local("Roboto");
}

.walt-widget {
  --wa-green: #25d366;
  --wa-green-dark: #1da851;
  --wa-dark: #075e54;
  --wa-header: #008069;
  --wa-header-end: #006e5a;
  --wa-text: #111b21;
  --wa-muted: #667781;
  --wa-bubble: #ffffff;
  --wa-bg: #efeae2;
  --wa-composer-bg: #f0f2f5;
  --shadow-strong: 0 12px 40px rgba(0, 0, 0, 0.28);
  --shadow-soft: 0 4px 16px rgba(0, 0, 0, 0.12);
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: "WALT-System", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
}

.walt-widget * {
  box-sizing: border-box;
}

/* ========== Floating launcher (Chaty-style attention) ========== */
.walt-launcher {
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #25d366 0%, #128c7e 100%);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.45);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.22s ease;
  outline: none;
  animation: walt-attention-pulse 2.4s ease-in-out infinite;
}

.walt-launcher::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(37, 211, 102, 0.35);
  z-index: -1;
  animation: walt-ripple 2.4s ease-out infinite;
  pointer-events: none;
}

.walt-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 28px rgba(37, 211, 102, 0.55);
  animation: none;
}

.walt-launcher:hover::before {
  animation: none;
  opacity: 0;
}

.walt-launcher:active {
  transform: scale(0.96);
}

.walt-launcher:focus-visible {
  outline: 3px solid rgba(37, 211, 102, 0.5);
  outline-offset: 4px;
}

.walt-whatsapp-mark {
  width: 32px;
  height: 32px;
  display: block;
  position: relative;
  transition: transform 0.25s ease;
}

.walt-widget.walt-open .walt-whatsapp-mark {
  transform: rotate(90deg) scale(0.9);
  opacity: 0.85;
}

.walt-whatsapp-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: #fff;
}

.walt-badge {
  position: absolute;
  right: -3px;
  top: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #ff3b30;
  color: #fff;
  font: 700 11px/16px Arial, sans-serif;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  animation: walt-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ========== Chat panel ========== */
.walt-panel {
  width: 360px;
  max-width: calc(100vw - 40px);
  height: min(540px, calc(100vh - 100px));
  min-height: 380px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 16px;
  background: var(--wa-bg);
  box-shadow: var(--shadow-strong);
  display: flex;
  flex-direction: column;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(18px) scale(0.94);
  pointer-events: none;
  visibility: hidden;
  transition:
    opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.32s cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0.32s;
}

.walt-widget.walt-open .walt-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

.walt-panel[hidden] {
  display: none !important;
}

/* Header – WhatsApp green bar */
.walt-header {
  height: 64px;
  min-height: 64px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(180deg, #008069 0%, #006e5a 100%);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  position: relative;
  z-index: 2;
}

.walt-avatar {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  overflow: hidden;
  background: #d9e5e2;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.walt-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.walt-avatar-fallback {
  font-size: 12px;
  font-weight: 700;
  color: #087c68;
  letter-spacing: 0.02em;
}

.walt-header-info {
  flex: 1;
  min-width: 0;
}

.walt-header-info strong {
  display: block;
  font-size: 16px;
  line-height: 20px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.01em;
}

.walt-header-info small {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 12.5px;
  line-height: 16px;
  opacity: 0.95;
  font-weight: 400;
}

.walt-online {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #25d366;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.35);
  animation: walt-online-pulse 2s ease-in-out infinite;
}

.walt-close {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 26px;
  font-weight: 300;
  line-height: 34px;
  transition: background 0.15s ease;
}

.walt-close:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Chat area – WhatsApp wallpaper style */
.walt-chat-area {
  flex: 1;
  min-height: 0;
  padding: 14px 16px 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  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='%23d4cbc3' fill-opacity='0.4'%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");
  background-size: 60px 60px;
  position: relative;
}

.walt-date {
  text-align: center;
  margin: 4px 0 16px;
}

.walt-date span {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 8px;
  background: #e1f2fb;
  color: #54656f;
  font-size: 11.5px;
  font-weight: 500;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
  letter-spacing: 0.02em;
}

/* Incoming bubble – true WhatsApp shape */
.walt-bubble {
  position: relative;
  display: inline-block;
  max-width: 85%;
  padding: 8px 10px 6px 12px;
  border-radius: 0 10px 10px 10px;
  background: var(--wa-bubble);
  color: var(--wa-text);
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  font-size: 14.5px;
  line-height: 20px;
  word-break: break-word;
  animation: walt-bubble-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.walt-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 0;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 8px 10px 0;
  border-color: transparent #fff transparent transparent;
  filter: drop-shadow(-1px 1px 0.5px rgba(0, 0, 0, 0.06));
}

.walt-time {
  float: right;
  margin: 6px 0 0 12px;
  color: #8696a0;
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
}

.walt-check {
  color: #53bdeb;
  font-weight: 700;
  margin-left: 3px;
  letter-spacing: -1px;
}

/* Composer */
.walt-form {
  flex: 0 0 auto;
  padding: 8px 10px 6px;
  background: var(--wa-composer-bg);
  margin: 0;
  border-top: 1px solid rgba(0, 0, 0, 0.04);
}

.walt-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: #fff;
  border-radius: 24px;
  padding: 5px 6px 5px 10px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  transition: box-shadow 0.2s ease;
}

.walt-composer:focus-within {
  box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.25);
}

.walt-form textarea {
  flex: 1;
  min-height: 36px;
  max-height: 100px;
  width: 100%;
  resize: none;
  overflow-y: auto;
  border: 0;
  outline: 0;
  padding: 8px 4px;
  color: var(--wa-text);
  background: transparent;
  font: 15px/19px "WALT-System", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

.walt-form textarea::placeholder {
  color: #8696a0;
}

.walt-emoji {
  width: 32px;
  height: 36px;
  flex: 0 0 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #667781;
  font-size: 22px;
  cursor: default;
  opacity: 0.7;
  line-height: 1;
}

.walt-send {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #25d366, #1da851);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.walt-send:hover {
  filter: brightness(1.05);
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.45);
}

.walt-send:active {
  transform: scale(0.95);
}

.walt-send:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.walt-status {
  min-height: 16px;
  padding: 3px 6px 0;
  color: #667781;
  font-size: 11px;
  transition: color 0.2s ease;
}

.walt-footer-note {
  text-align: center;
  padding: 5px 10px 9px;
  background: var(--wa-composer-bg);
  color: #8696a0;
  font-size: 10px;
  letter-spacing: 0.02em;
}

/* ========== Keyframes (Chaty-style attention + smooth UI) ========== */
@keyframes walt-attention-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes walt-ripple {
  0% {
    transform: scale(0.85);
    opacity: 0.55;
  }
  70% {
    transform: scale(1.35);
    opacity: 0;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@keyframes walt-badge-pop {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes walt-online-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.35); }
  50% { box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.15); }
}

@keyframes walt-bubble-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ========== Mobile ========== */
@media (max-width: 600px) {
  .walt-widget {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  .walt-launcher {
    width: 56px;
    height: 56px;
  }

  .walt-whatsapp-mark {
    width: 30px;
    height: 30px;
  }

  .walt-panel {
    position: fixed;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    top: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-width: none;
    height: min(62vh, 520px);
    min-height: 360px;
    max-height: 540px;
    margin: 0;
    border-radius: 16px;
    transform-origin: bottom center;
  }

  .walt-header {
    height: 58px;
    min-height: 58px;
    padding: 8px 10px;
  }

  .walt-avatar {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .walt-header-info strong {
    font-size: 15px;
  }

  .walt-chat-area {
    padding: 12px 14px 16px;
  }

  .walt-form {
    padding: 7px 8px 5px;
  }

  .walt-footer-note {
    padding-bottom: 7px;
  }

  /* Hide launcher while chat is open on mobile (like Chaty) */
  .walt-widget.walt-open .walt-launcher {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.6);
    transition: opacity 0.2s ease, transform 0.2s ease;
  }
}

@media (max-width: 380px) {
  .walt-panel {
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    height: min(72vh, 540px);
  }

  .walt-bubble {
    max-width: 90%;
    font-size: 14px;
  }

  .walt-form textarea {
    font-size: 14px;
  }
}

@media (max-width: 600px) and (max-height: 600px) {
  .walt-panel {
    height: min(64vh, 440px);
    min-height: 300px;
  }

  .walt-header {
    height: 52px;
    min-height: 52px;
  }

  .walt-avatar {
    width: 36px;
    height: 36px;
    flex-basis: 36px;
  }

  .walt-chat-area {
    padding: 10px 12px;
  }

  .walt-form {
    padding: 5px 7px 3px;
  }

  .walt-footer-note {
    display: none;
  }
}

/* Prevent iOS Safari zoom on focus */
@media (max-width: 600px) {
  .walt-form textarea,
  .walt-form input {
    font-size: 16px !important;
  }
}
