/* Shared WhatsApp icon — scales with parent font-size */
.wa-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.125em;
  height: 1.125em;
  flex-shrink: 0;
  line-height: 0;
}

.wa-icon svg {
  display: block;
  width: 100%;
  height: 100%;
}

.wa-icon--md {
  width: 1.25em;
  height: 1.25em;
}

.wa-icon--lg {
  width: 1.35em;
  height: 1.35em;
}

.incomax-chat {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.incomax-chat-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: min(360px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(20, 184, 166, 0.35);
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  backdrop-filter: blur(18px);
  overflow: hidden;
  transform-origin: bottom right;
  animation: chatPanelIn 0.28s ease;
}

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

@keyframes chatPanelIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.incomax-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, rgba(13, 110, 122, 0.45), rgba(10, 85, 96, 0.25));
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.incomax-chat-header-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.incomax-chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: linear-gradient(135deg, #14b8a6, #0a5560);
  color: #fff;
  font-weight: 800;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(20, 184, 166, 0.35);
  flex-shrink: 0;
}

.incomax-chat-title {
  display: block;
  font-size: 0.92rem;
  color: #f8fafc;
}

.incomax-chat-status {
  display: block;
  font-size: 0.72rem;
  color: #86efac;
  margin-top: 2px;
}

.incomax-chat-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.incomax-chat-close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.incomax-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  max-height: 280px;
}

.incomax-chat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 0.84rem;
  line-height: 1.5;
  animation: chatMsgIn 0.22s ease;
}

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.incomax-chat-msg.bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(148, 163, 184, 0.12);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}

.incomax-chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.35), rgba(13, 110, 122, 0.45));
  border: 1px solid rgba(20, 184, 166, 0.35);
  color: #f0fdfa;
  border-bottom-right-radius: 4px;
}

.incomax-chat-msg a {
  color: #5eead4;
  font-weight: 600;
}

.incomax-chat-msg strong { color: #f8fafc; }

.incomax-chat-quick {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
}

.incomax-chat-chip {
  border: 1px solid rgba(20, 184, 166, 0.35);
  background: rgba(20, 184, 166, 0.1);
  color: #99f6e4;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.incomax-chat-chip:hover {
  background: rgba(20, 184, 166, 0.2);
  transform: translateY(-1px);
}

.incomax-chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
}

.incomax-chat-input-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(3, 7, 18, 0.55);
  color: #f8fafc;
  padding: 10px 12px;
  font-size: 0.84rem;
}

.incomax-chat-input-row input::placeholder { color: #64748b; }

.incomax-chat-input-row input:focus {
  outline: none;
  border-color: rgba(20, 184, 166, 0.5);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.incomax-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, #14b8a6, #0d6e7a);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(20, 184, 166, 0.35);
}

.incomax-chat-send svg {
  width: 18px;
  height: 18px;
}

.incomax-chat-send:hover { filter: brightness(1.08); }

.incomax-chat-wa-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 14px 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(37, 211, 102, 0.12);
  border: 1px solid rgba(37, 211, 102, 0.35);
  color: #86efac;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.2s;
}

.incomax-chat-wa-link .wa-icon {
  width: 1.15em;
  height: 1.15em;
}

.incomax-chat-wa-link:hover {
  background: rgba(37, 211, 102, 0.22);
  color: #bbf7d0;
}

.incomax-chat-fab {
  position: relative;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 18px;
  cursor: pointer;
  background: linear-gradient(135deg, #14b8a6, #0d6e7a);
  color: #fff;
  box-shadow: 0 8px 28px rgba(20, 184, 166, 0.45);
  display: grid;
  place-items: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.incomax-chat-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(20, 184, 166, 0.55);
}

.incomax-chat-fab svg {
  width: 26px;
  height: 26px;
}

.incomax-chat-fab-close { display: none; }

.incomax-chat-fab.is-open .incomax-chat-fab-open { display: none; }
.incomax-chat-fab.is-open .incomax-chat-fab-close { display: block; }

.incomax-chat-fab-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 22px;
  border: 2px solid rgba(20, 184, 166, 0.45);
  animation: chatFabPulse 2.4s ease-out infinite;
  pointer-events: none;
}

.incomax-chat-fab.is-open .incomax-chat-fab-pulse,
.incomax-chat-fab.is-seen .incomax-chat-fab-pulse {
  display: none;
}

@keyframes chatFabPulse {
  0% { transform: scale(1); opacity: 0.7; }
  100% { transform: scale(1.18); opacity: 0; }
}

.incomax-chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.incomax-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: chatTyping 1.2s ease-in-out infinite;
}

.incomax-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.incomax-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 480px) {
  .incomax-chat-panel {
    width: calc(100vw - 24px);
    right: -4px;
    max-height: min(70vh, 480px);
  }

  .incomax-chat-fab {
    width: 52px;
    height: 52px;
    border-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .incomax-chat-panel,
  .incomax-chat-msg,
  .incomax-chat-fab-pulse,
  .incomax-chat-typing span {
    animation: none !important;
  }
}
