/* PBAI Chat + Voice Styles v1.0.0 */
/* Scoped under .pbai-* to avoid conflicts with landing page */

/* ==================== JOY WIDGET (floating bubble) ==================== */
.pbai-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: 'Lato', sans-serif;
}

.pbai-bubble-wrap {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
}

.pbai-bubble-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid #b65b34;
  background: #fff;
  cursor: pointer;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transition: transform 0.2s, box-shadow 0.2s;
  animation: pbai-pulse 3s ease-in-out infinite;
}

.pbai-bubble-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.2);
}

.pbai-bubble-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

@keyframes pbai-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(182,91,52,0.2); }
  50% { box-shadow: 0 4px 28px rgba(182,91,52,0.5); }
}

/* Tooltip */
.pbai-tooltip {
  position: absolute;
  bottom: 80px;
  right: 0;
  background: #2d2420;
  color: #fff;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s, transform 0.4s;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.pbai-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 28px;
  width: 12px;
  height: 12px;
  background: #2d2420;
  transform: rotate(45deg);
}

.pbai-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Widget Panel */
.pbai-widget-panel {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-height: 560px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
  animation: pbai-slide-up 0.3s ease-out;
}

@keyframes pbai-slide-up {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ==================== CHAT PANEL (shared widget + modal) ==================== */
.pbai-chat-panel {
  display: flex;
  flex-direction: column;
  height: 520px;
  background: #faf9f6;
  font-family: 'Lato', sans-serif;
}

.pbai-chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #2d2420;
  color: #fff;
  flex-shrink: 0;
}

.pbai-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #b65b34;
}

.pbai-header-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.pbai-header-name {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  font-weight: 700;
}

.pbai-header-niche {
  font-size: 0.75rem;
  opacity: 0.7;
}

.pbai-speaking {
  animation: pbai-speak-pulse 0.8s ease-in-out infinite alternate;
  font-size: 0.9rem;
}

@keyframes pbai-speak-pulse {
  from { opacity: 0.5; }
  to { opacity: 1; }
}

.pbai-mute-btn, .pbai-close-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.pbai-mute-btn:hover, .pbai-close-btn:hover { opacity: 1; }

/* Messages */
.pbai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pbai-msg {
  display: flex;
  gap: 8px;
  max-width: 85%;
  animation: pbai-msg-in 0.3s ease-out;
}

@keyframes pbai-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.pbai-msg-persona { align-self: flex-start; }
.pbai-msg-system { align-self: center; }

.pbai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.pbai-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.pbai-msg-user .pbai-bubble {
  background: #b65b34;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.pbai-msg-persona .pbai-bubble {
  background: #fff;
  color: #2d2420;
  border: 1px solid #e8e4de;
  border-bottom-left-radius: 4px;
}

.pbai-msg-system .pbai-bubble {
  background: #f5f0eb;
  color: #9a948d;
  font-size: 0.8rem;
  font-style: italic;
}

/* Typing indicator */
.pbai-typing {
  padding: 8px 16px;
  display: flex;
  gap: 5px;
  align-items: center;
}

.pbai-typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #b65b34;
  animation: pbai-dot-bounce 1.2s ease-in-out infinite;
}

.pbai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.pbai-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pbai-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* BUY NOW */
.pbai-buy-btn {
  display: block;
  text-align: center;
  background: #b65b34;
  color: #fff;
  padding: 14px 16px;
  font-family: 'Lato', sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.2s;
}

.pbai-buy-btn:hover { background: #8d3f22; }

.pbai-msg-hidden {
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  margin: 0;
  padding: 0;
  transition: opacity 0.3s, max-height 0.3s;
}
.pbai-msg-hidden.pbai-msg-persona {
  max-height: 0;
}
.pbai-msg-persona:not(.pbai-msg-hidden) {
  max-height: 500px;
  transition: opacity 0.3s ease, max-height 0.3s ease;
}

.pbai-mode-btn {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.pbai-mode-btn:hover {
  background: rgba(255,255,255,0.15);
}

.pbai-buy-pulse {
  animation: buyPulse 0.6s ease-in-out 3;
  box-shadow: 0 0 0 0 rgba(182, 91, 52, 0.7);
}
@keyframes buyPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(182, 91, 52, 0.7); }
  50% { transform: scale(1.03); box-shadow: 0 0 16px 4px rgba(182, 91, 52, 0.4); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(182, 91, 52, 0); }
}

/* Input bar */
.pbai-input-bar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e8e4de;
  flex-shrink: 0;
}

.pbai-input {
  flex: 1;
  border: 1px solid #e8e4de;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 16px; /* prevents iOS zoom */
  font-family: 'Lato', sans-serif;
  color: #2d2420;
  background: #faf9f6;
  outline: none;
  transition: border-color 0.2s;
}

.pbai-input:focus { border-color: #b65b34; }
.pbai-input::placeholder { color: #9a948d; }

.pbai-mic-btn, .pbai-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

.pbai-mic-btn {
  background: #f5f0eb;
  color: #2d2420;
}

.pbai-mic-btn.recording {
  background: #e74c3c;
  color: #fff;
  animation: pbai-rec-pulse 1s ease-in-out infinite;
}

@keyframes pbai-rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(231,76,60,0); }
}

.pbai-send-btn {
  background: #b65b34;
  color: #fff;
}

.pbai-send-btn:hover { background: #8d3f22; }
.pbai-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ==================== TEAM PAGE GRID ==================== */
.pbai-team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1rem;
}

.pbai-persona-card {
  position: relative;
  background: #fff;
  border: 1px solid #e8e4de;
  border-radius: 16px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.pbai-persona-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.pbai-badge {
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  background: #b65b34;
  color: #fff;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.pbai-card-thumb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #b65b34;
  margin-bottom: 1rem;
}

.pbai-card-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.2rem;
  color: #2d2420;
  margin: 0 0 4px 0;
}

.pbai-card-niche {
  color: #b65b34;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 8px 0;
}

.pbai-card-bio {
  color: #5a5652;
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 0 0 1.25rem 0;
}

.pbai-card-btn {
  background: #2d2420;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 24px;
  font-family: 'Lato', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.pbai-card-btn:hover { background: #b65b34; }

/* ==================== MODAL (expanded persona) ==================== */
.pbai-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(45,36,32,0.7);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: pbai-fade-in 0.3s ease-out;
}

@keyframes pbai-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pbai-modal {
  display: flex;
  gap: 0;
  width: 100%;
  max-width: 900px;
  max-height: 85vh;
  background: #faf9f6;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 16px 60px rgba(0,0,0,0.3);
  animation: pbai-modal-in 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pbai-modal-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.pbai-modal-left {
  width: 320px;
  flex-shrink: 0;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: #fff;
  border-right: 1px solid #e8e4de;
}

.pbai-modal-img {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid #b65b34;
  margin-bottom: 1.25rem;
}

.pbai-modal-name {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  color: #2d2420;
  margin: 0 0 4px 0;
}

.pbai-modal-niche {
  color: #b65b34;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0 0 12px 0;
}

.pbai-modal-bio {
  color: #5a5652;
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 0 0 1.5rem 0;
}

.pbai-buy-btn-side {
  border-radius: 24px;
  padding: 12px 24px;
  font-size: 0.85rem;
  margin-top: auto;
}

.pbai-modal-right {
  flex: 1;
  min-width: 0;
}

.pbai-modal-right .pbai-chat-panel {
  height: 100%;
  max-height: 85vh;
  border-radius: 0;
}

/* ==================== MOBILE ==================== */
@media (max-width: 768px) {
  .pbai-widget {
    bottom: 16px;
    right: 16px;
  }

  .pbai-bubble-btn {
    width: 60px;
    height: 60px;
  }

  .pbai-widget-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }

  .pbai-chat-panel {
    height: 80vh;
  }

  .pbai-tooltip {
    right: -8px;
    font-size: 0.78rem;
  }

  .pbai-team-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .pbai-modal {
    flex-direction: column;
    max-height: 95vh;
    border-radius: 16px 16px 0 0;
  }

  .pbai-modal-overlay {
    padding: 0;
    align-items: flex-end;
  }

  .pbai-modal-left {
    width: 100%;
    flex-direction: row;
    padding: 1rem;
    gap: 1rem;
    text-align: left;
    align-items: center;
    border-right: none;
    border-bottom: 1px solid #e8e4de;
  }

  .pbai-modal-img {
    width: 64px;
    height: 64px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .pbai-modal-bio { display: none; }
  .pbai-buy-btn-side { display: none; }

  .pbai-modal-right .pbai-chat-panel {
    height: 65vh;
  }

  .pbai-modal-right .pbai-buy-btn {
    display: block;
  }
}

@media (max-width: 480px) {
  .pbai-persona-card {
    padding: 1.5rem 1rem;
  }

  .pbai-card-bio {
    font-size: 0.8rem;
  }
}

/* Scrollbar styling */
.pbai-messages::-webkit-scrollbar { width: 4px; }
.pbai-messages::-webkit-scrollbar-track { background: transparent; }
.pbai-messages::-webkit-scrollbar-thumb { background: #e8e4de; border-radius: 4px; }
.pbai-messages::-webkit-scrollbar-thumb:hover { background: #b65b34; }

/* ==================== INLINE EMBED MODE ==================== */
/* When Joy's chat widget is embedded inside .joy-chat-embed on the landing page */
.joy-chat-embed .pbai-widget {
  position: static;
  bottom: auto;
  right: auto;
  z-index: auto;
}

.joy-chat-embed .pbai-bubble-wrap {
  display: none; /* Hide the floating bubble — chat opens inline automatically */
}

.joy-chat-embed .pbai-widget-panel {
  position: static;
  bottom: auto;
  right: auto;
  left: auto;
  width: 100%;
  max-height: none;
  border-radius: 20px;
  box-shadow: none;
  animation: none;
}

.joy-chat-embed .pbai-chat-panel {
  height: 480px;
  border-radius: 20px;
}

.joy-chat-embed .pbai-tooltip {
  display: none;
}

@media (max-width: 600px) {
  .joy-chat-embed .pbai-widget-panel {
    border-radius: 16px;
  }
  .joy-chat-embed .pbai-chat-panel {
    height: 420px;
    border-radius: 16px;
  }
}
