/* ── Chattsy Support Chat Widget ────────────────────────────────────────────── */

/* Floating trigger button */
#chattsy-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF6B35, #FF8C42);
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(255, 107, 53, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: chattsy-pulse 5s ease-in-out infinite;
}

#chattsy-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(255, 107, 53, 0.55);
}

#chattsy-chat-btn.open {
  animation: none;
}

#chattsy-chat-btn svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.15s;
}

@keyframes chattsy-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(255, 107, 53, 0.45); }
  50%       { box-shadow: 0 4px 32px rgba(255, 107, 53, 0.75), 0 0 0 10px rgba(255, 107, 53, 0.08); }
}

/* Chat panel */
#chattsy-chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  height: 560px;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  transform: translateY(24px) scale(0.97);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.18s ease;
}

#chattsy-chat-panel.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#chattsy-chat-header {
  background: linear-gradient(135deg, #FF6B35, #FF8C42);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.chattsy-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chattsy-avatar-icon {
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.chattsy-header-text h4 {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.chattsy-header-text p {
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 600;
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

.chattsy-online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #5efb96;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}

#chattsy-close-btn {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  transition: background 0.15s;
  flex-shrink: 0;
  font-family: inherit;
}

#chattsy-close-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}

/* Messages body */
#chattsy-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

#chattsy-messages::-webkit-scrollbar { width: 4px; }
#chattsy-messages::-webkit-scrollbar-track { background: transparent; }
#chattsy-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 4px; }

/* Bubbles */
.chattsy-msg {
  display: flex;
  gap: 8px;
  max-width: 88%;
  align-items: flex-end;
}

.chattsy-msg.bot {
  align-self: flex-start;
}

.chattsy-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chattsy-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  font-family: 'Plus Jakarta Sans', sans-serif;
  word-break: break-word;
}

.chattsy-msg.bot .chattsy-bubble {
  background: #f1f0ef;
  color: #2a2a2a;
  border-bottom-left-radius: 4px;
}

.chattsy-msg.user .chattsy-bubble {
  background: linear-gradient(135deg, #FF6B35, #FF8C42);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.chattsy-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: #f1f0ef;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}

.chattsy-typing span {
  width: 7px;
  height: 7px;
  background: #aaa;
  border-radius: 50%;
  display: inline-block;
  animation: chattsy-bounce 1.2s ease-in-out infinite;
}

.chattsy-typing span:nth-child(2) { animation-delay: 0.2s; }
.chattsy-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chattsy-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* Email capture form */
#chattsy-escalation-form {
  padding: 14px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #fafafa;
  flex-shrink: 0;
}

#chattsy-escalation-form p {
  font-size: 12px;
  font-weight: 700;
  color: #6e625b;
  margin-bottom: 8px;
  font-family: 'Plus Jakarta Sans', sans-serif;
}

#chattsy-email-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(241, 100, 30, 0.24);
  border-radius: 10px;
  font-size: 13px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  outline: none;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

#chattsy-email-input:focus {
  border-color: #FF6B35;
}

#chattsy-escalation-submit {
  width: 100%;
  padding: 9px;
  background: linear-gradient(135deg, #FF6B35, #FF8C42);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  font-family: 'Plus Jakarta Sans', sans-serif;
  transition: opacity 0.15s;
}

#chattsy-escalation-submit:hover { opacity: 0.9; }
#chattsy-escalation-submit:disabled { opacity: 0.55; cursor: not-allowed; }

/* Input footer */
#chattsy-input-area {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#chattsy-input {
  flex: 1;
  border: 1px solid rgba(241, 100, 30, 0.18);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 600;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color 0.15s;
  line-height: 1.45;
}

#chattsy-input:focus {
  border-color: #FF6B35;
}

#chattsy-send-btn {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #FF6B35, #FF8C42);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}

#chattsy-send-btn:hover { transform: scale(1.08); }
#chattsy-send-btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

#chattsy-send-btn svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* Footer chat link */
.chattsy-footer-chat-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #FF6B35;
  font-weight: 700;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  padding: 0;
  transition: opacity 0.15s;
}

.chattsy-footer-chat-link:hover {
  opacity: 0.78;
  text-decoration: underline;
}

/* Mobile */
@media (max-width: 480px) {
  #chattsy-chat-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }

  #chattsy-chat-btn {
    bottom: 16px;
    right: 16px;
  }
}
