body, button, input {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  color: #000;
}
body { 
  overflow: hidden; 
  background-color: transparent;
}
canvas { 
  display: block; 
}

/* Profile Image - Moved to top left */
#profileImage {
  position: fixed;
  top: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #20e1ea;
  z-index: 1001;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Native-style back button for mobile */
#backButton {
  position: fixed;
  top: 20px;
  left: 20px;
  background-color: rgba(0, 0, 0, 0.6);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: none;
  justify-content: center;
  align-items: center;
  font-size: 22px;
  z-index: 1500;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}

#backButton.active {
  display: flex;
}

.popup {
  display: none;
  position: fixed;
  top: 10px; /* Top positioning */
  right: 10px; /* Right positioning */
  background-color: #0ef3fe;
  color: black;
  padding: 10px 12px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  font-family: 'Poppins', sans-serif;
  font-size: 13px;
  z-index: 1000;
  display: flex;
  align-items: center;
  max-width: 250px;
  width: calc(100% - 40px);
}

.popup-logo {
  width: 22px;
  height: 22px;
  margin-right: 8px;
  border-radius: 50%;
  object-fit: cover;
}

.popup-text {
  flex: 1;
}

.popup a {
  color: black;
  text-decoration: none;
  font-weight: 500;
}

.popup a:hover {
  text-decoration: underline;
}

.close-btn {
  margin-left: 6px;
  cursor: pointer;
  font-size: 14px;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.1);
  color: black;
  transition: background-color 0.2s;
}

.close-btn:hover {
  background-color: rgba(0, 0, 0, 0.2);
}

/* Media queries to adjust the popup position for different screen sizes */
@media (max-width: 768px) {
  .popup {
    top: 60px; /* Position below the profile image in top corner */
    width: calc(100% - 20px);
    max-width: 200px;
  }
}

@media (max-width: 480px) {
  .popup {
    top: 70px; /* Adjusted to avoid overlapping with back button and profile image */
    font-size: 12px;
    max-width: 180px;
    padding: 8px 10px;
  }
  
  .popup-logo {
    width: 18px;
    height: 18px;
  }
}

/* Chat Interface - Completely revised */
#chatInterface {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  pointer-events: none;
  z-index: 1000;
  box-sizing: border-box;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  background: transparent;
}

#chatInterface.active {
  transform: translateX(0);
}

/* Header Section - Removed level badge */
.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px;
  pointer-events: auto;
}

/* Messages Container */
#messagesContainer {
  flex: 1;
  width: 100%;
  overflow-y: auto;
  padding: 10px 15px 70px 15px; /* Bottom padding for input */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

/* Message Bubbles */
.message {
  max-width: 70%;
  margin: 5px 0;
  padding: 12px 16px;
  border-radius: 18px;
  word-break: break-word;
  animation: fadeIn 0.3s forwards;
  font-size: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
  clear: both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.user-message {
  background-color: #0ef3fe; /* Blue for user */
  color: #000;
  align-self: flex-end;
  margin-left: 30%; /* Push user messages to the right */
}

.assistant-message {
  background-color: white;
  color: #000;
  align-self: flex-start;
  margin-right: 30%; /* Keep AI messages away from avatar */
}

.date-marker {
  background-color: rgba(230, 230, 230, 0.8);
  color: #666;
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 12px;
  margin: 10px auto;
  text-align: center;
  align-self: center;
}

/* Input Area */
#inputArea {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #f0f0f0;
  padding: 10px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  pointer-events: auto;
  z-index: 1100;
  border-top: 1px solid #ddd;
}

#chatInput {
  flex: 1;
  padding: 10px 15px;
  border: none;
  border-radius: 20px;
  background-color: white;
  font-size: 16px;
  margin-right: 10px;
}

#chatInput:focus {
  outline: none;
}

#sendButton {
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.send-icon {
  width: 24px;
  height: 24px;
  fill: #0084ff;
}

/* Chat Input Field (replacing toggle chat button) */
#chatInputField {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 70%;
  max-width: 500px;
  padding: 12px 24px;
  background-color: white;
  color: #000;
  border: 2px solid #e01b87;
  border-radius: 20px;
  font-weight: normal;
  font-size: 16px;
  z-index: 1002;
  transition: all 0.2s, opacity 0.3s, visibility 0.3s;
  outline: none;
  visibility: visible;
  opacity: 1;
}

#chatInputField.hidden {
  visibility: hidden;
  opacity: 0;
}

#chatInputField:focus {
  box-shadow: 0 0 8px rgba(224, 27, 135, 0.5);
}

/* Hide the original toggle chat button */
#toggleChat {
  display: none;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  background-color: #f0f0f0;
  border-radius: 18px;
  align-self: flex-start;
  margin-right: 30%; /* Match assistant message alignment */
}

.typing-dot {
  width: 8px;
  height: 8px;
  background-color: #999;
  border-radius: 50%;
  margin: 0 2px;
  animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Social Links Panel (hidden) */
#socialLinksWrapper {
  position: fixed;
  left: 20px;
  top: 120px;
  z-index: 1001;
}
#toggleLinks {
  display: none; /* Hidden as requested */
  background: #ff008a;
  color: #000;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
}
#socialLinksPanel {
  display: none;
  margin-top: 8px;
  background: rgba(255,255,255,0.95);
  border: 1px solid #00f4ff;
  border-radius: 8px;
  padding: 10px;
}
#socialLinksPanel.active {
  display: block;
}
#socialLinksPanel a {
  display: block;
  margin: 5px 0;
  color: #000;
  text-decoration: none;
  font-weight: 500;
}

/* Product recommendations in chat */
.product-bubble {
  background-color: white;
  border-radius: 12px;
  padding: 10px;
  margin: 5px 0;
  align-self: flex-start;
  max-width: 80%;
  margin-right: 30%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.product-item {
  display: flex;
  margin-bottom: 10px;
  border-bottom: 1px solid #eee;
  padding-bottom: 10px;
}

.product-item:last-child {
  margin-bottom: 0;
  border-bottom: none;
  padding-bottom: 0;
}

.product-image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  margin-right: 10px;
}

.product-details {
  flex: 1;
}

.product-title {
  font-weight: bold;
  margin-bottom: 2px;
}

.product-price {
  color: #ff008a;
  font-weight: bold;
  margin-bottom: 5px;
}

.product-link {
  color: #00f4ff;
  text-decoration: none;
}

/* Kinetic Bloom Effect */
#bloomContainer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  perspective: 1000px;
  visibility: hidden;
}

#bloomOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  transition: background 0.5s ease;
}

#bloomContent {
  position: relative;
  width: 0;
  height: 0;
  background: linear-gradient(135deg, #00f4ff, #ff008a);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow: hidden;
  transform: translateZ(-100px) scale(0);
  transform-origin: center;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              width 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              height 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              border-radius 0.5s ease;
  box-shadow: 0 0 0 rgba(0, 244, 255, 0);
}

#bloomHeader {
  width: 100%;
  padding: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
  z-index: 10;
}

#bloomTitle {
  color: white;
  font-weight: 600;
  font-size: 18px;
  margin: 0;
  flex-grow: 1;
  text-align: center;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#bloomCloseBtn {
  background: transparent;
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s ease;
}

#bloomCloseBtn::before {
  content: ">";
}

#bloomCloseBtn:hover {
  background: rgba(255, 255, 255, 0.2);
}

#bloomBody {
  flex-grow: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
  box-sizing: border-box;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.bloom-ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: ripple 1s ease-out forwards;
}

@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Bloom Stage Classes */
#bloomContainer.stage-1 {
  visibility: visible;
  pointer-events: all;
}

#bloomContainer.stage-1 #bloomOverlay {
  background: rgba(0, 0, 0, 0.3);
}

#bloomContainer.stage-1 #bloomContent {
  width: 300px;
  height: 400px;
  transform: translateZ(0) scale(1);
  box-shadow: 0 0 30px rgba(0, 244, 255, 0.5);
}

#bloomContainer.stage-1 #bloomTitle,
#bloomContainer.stage-1 #bloomCloseBtn {
  opacity: 1;
  transform: translateY(0) scale(1);
}

#bloomContainer.stage-1 #bloomBody {
  opacity: 1;
  transform: translateY(0);
}

#bloomContainer.stage-2 #bloomContent {
  width: 450px;
  height: 500px;
  box-shadow: 0 0 50px rgba(0, 244, 255, 0.7);
}

#bloomContainer.stage-2 #bloomOverlay {
  background: rgba(0, 0, 0, 0.5);
}

#bloomContainer.stage-3 #bloomContent {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: 0 0 70px rgba(0, 244, 255, 0.9);
}

#bloomContainer.stage-3 #bloomOverlay {
  background: rgba(0, 0, 0, 0.7);
}

.avatar-quip {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: #ff008a;
  color: white;
  padding: 10px 15px;
  border-radius: 20px 20px 0 20px;
  font-weight: 500;
  box-shadow: 0 5px 15px rgba(255, 0, 138, 0.4);
  transform: scale(0);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.5s ease;
  z-index: 10;
}

#bloomContainer.stage-3 .avatar-quip {
  transform: scale(1);
  opacity: 1;
}

/* Platform-specific styling for iframes */
.platform-content {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

.platform-iframe-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.platform-iframe {
  width: 100%;
  height: 100%;
  border: none;
  position: relative;
  z-index: 1;
}

.iframe-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.9);
  z-index: 2;
  transition: opacity 0.3s ease;
}

.iframe-loading-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(0, 244, 255, 0.3);
  border-top-color: #00f4ff;
  animation: spin 1s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.iframe-error {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: white;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
}

.iframe-error h3 {
  color: #ff008a;
  margin-bottom: 10px;
}

.iframe-error p {
  color: #666;
  margin-bottom: 15px;
}

.visit-link-btn {
  display: inline-block;
  padding: 10px 20px;
  background: #00f4ff;
  color: black;
  text-decoration: none;
  border-radius: 5px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.visit-link-btn:hover {
  background: #00d8e0;
  transform: translateY(-2px);
  box-shadow: 0 2px 10px rgba(0, 244, 255, 0.4);
}

/* Platform-specific colors */
.instagram-theme {
  background: linear-gradient(45deg, #405DE6, #5851DB, #833AB4, #C13584, #E1306C, #FD1D1D);
}

.facebook-theme {
  background: linear-gradient(45deg, #3b5998, #4267B2);
}

.tiktok-theme {
  background: linear-gradient(45deg, #000000, #25F4EE, #FE2C55);
}

.youtube-theme {
  background: linear-gradient(45deg, #FF0000, #282828);
}

.twitter-theme {
  background: linear-gradient(45deg, #1DA1F2, #14171A);
}

.snapchat-theme {
  background: linear-gradient(45deg, #FFFC00, #000000);
}

.linkedin-theme {
  background: linear-gradient(45deg, #0077B5, #000000);
}

.generic-theme {
  background: linear-gradient(45deg, #00f4ff, #ff008a);
}

/* Glow effect for bloom */
.bloom-glow {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  box-shadow: inset 0 0 20px rgba(255, 255, 255, 0.6);
  opacity: 0;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

#bloomContainer.stage-1 .bloom-glow {
  opacity: 0.3;
}

#bloomContainer.stage-2 .bloom-glow {
  opacity: 0.5;
}

#bloomContainer.stage-3 .bloom-glow {
  opacity: 0.7;
}

/* Mood Bubble */
.mood-bubble {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: white;
  color: #000;
  padding: 10px 15px;
  border-radius: 20px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  z-index: 1500;
  opacity: 0;
  transform: translateY(-20px) translateX(-50%);
  transition: opacity 0.3s ease, transform 0.3s ease;
  max-width: 80%;
  text-align: center;
}

.mood-bubble.active {
  opacity: 1;
  transform: translateY(0) translateX(-50%);
}

.mood-bubble p {
  margin: 0;
  font-size: 16px;
}

/* Handle chat area for different screen sizes */
@media (max-width: 480px) {
  .user-message {
    margin-left: 20%;
  }
  
  .assistant-message {
    margin-right: 20%;
  }
  
  .product-bubble {
    margin-right: 20%;
  }
  
  .mood-bubble {
    font-size: 14px;
    padding: 8px 12px;
  }
  
  .mood-bubble p {
    font-size: 14px;
  }
}
