/* ============================================
   JESS CHAT WIDGET — Shared across all demo sites
   ============================================ */

.jess-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
.jess-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #22c55e;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
}

.jess-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(34, 197, 94, 0.5);
}

.jess-toggle:focus-visible {
  outline: 3px solid #22c55e;
  outline-offset: 3px;
}

.jess-avatar {
  color: #fff;
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
  font-family: 'Georgia', serif;
}

.jess-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid #22c55e;
  animation: jessPulse 2s ease-out infinite;
}

@keyframes jessPulse {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* Chat Panel */
.jess-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: jessSlideUp 0.3s ease;
}

.jess-panel.open {
  display: flex;
}

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

/* Header */
.jess-header {
  background: #22c55e;
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.jess-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.jess-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.25rem;
  font-family: 'Georgia', serif;
}

.jess-header strong {
  display: block;
  font-size: 1rem;
}

.jess-status {
  font-size: 0.75rem;
  opacity: 0.85;
}

.jess-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  border-radius: 4px;
  transition: background 0.2s;
}

.jess-close:hover {
  background: rgba(255,255,255,0.2);
}

/* Messages */
.jess-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 280px;
  max-height: 320px;
  background: #f8faf9;
}

.jess-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  animation: jessFadeIn 0.3s ease;
}

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

.jess-msg.jess {
  background: #22c55e;
  color: #fff;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

.jess-msg.user {
  background: #e8e8e8;
  color: #333;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.jess-msg .jess-name {
  font-weight: 700;
  font-size: 0.75rem;
  margin-bottom: 2px;
  opacity: 0.8;
}

.jess-typing {
  align-self: flex-start;
  padding: 10px 14px;
  background: #22c55e;
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  display: none;
}

.jess-typing span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: rgba(255,255,255,0.6);
  border-radius: 50%;
  margin: 0 2px;
  animation: jessTypingDot 1.4s infinite;
}

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

@keyframes jessTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input */
.jess-input-area {
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}

.jess-input-area input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid #d1d5db;
  border-radius: 24px;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.jess-input-area input:focus {
  border-color: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.jess-input-area button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #22c55e;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.jess-input-area button:hover {
  background: #16a34a;
}

/* Powered By */
.jess-powered {
  text-align: center;
  font-size: 0.7rem;
  color: #9ca3af;
  padding: 8px;
  background: #fff;
  border-top: 1px solid #f3f4f6;
}

.jess-powered strong {
  color: #22c55e;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .jess-panel {
    width: calc(100vw - 32px);
    right: -8px;
    bottom: 76px;
    max-height: 70vh;
  }

  .jess-widget {
    bottom: 80px; /* Above mobile CTA bar */
    right: 16px;
  }

  .jess-toggle {
    width: 56px;
    height: 56px;
  }
}

/* Notification badge */
.jess-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: #fff;
  font-weight: 700;
}
