/* Chat Icon */
#chatIcon {
  position: fixed;
  bottom: 50px;
  right: 0px;
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #d14900, #ff3d00);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 10000;
  transition: transform 0.2s ease;
}

#chatIcon:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

/* Hide by default */
.chat-name {
  position: absolute;
  right: 45px;
  color: #d14900;
  font-weight: 600;
  padding: 6px 12px;
  opacity: 0;
  transform: translateX(10px); /* start slightly below */
  pointer-events: none;
  transition: all 0.4s ease;
  font-family: "Poppins", sans-serif;
  white-space: nowrap;
  font-size: 14px;
}

/* Show on hover */
.chat-icon:hover .chat-name {
  opacity: 1;
  transform: translateX(0);
}

/* --- Chat Card --- */
.chat-card {
  position: fixed;
  bottom: 50px;
  right: 20px;
  width: 280px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  padding: 15px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
}

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

.chat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-card-header img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 8px;
}

.chat-card-header h4 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.chat-card-body {
  margin-top: 8px;
  font-size: 13px;
  color: #555;
  line-height: 1.4;
}

.chat-card-footer {
  margin-top: 12px;
  text-align: right;
}

.chat-card-footer button {
  background-color: #d14900;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 5px 10px;
  font-weight: bold;
  cursor: pointer;
  font-size: 16px;
}

/* --- Chat Popup --- */
.chat-popup {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 50px;
  right: 20px;
  width: 500px;
  max-height: 600px;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  z-index: 10000;
  font-family: Arial, sans-serif;
}

.chat-popup.show {
  animation: popupFade 0.3s ease;
}

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

/* Header */
.chat-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #d14900;
  padding: 10px 15px;
  border-bottom: 1px solid #ddd;
}

.chat-title {
  display: flex;
  align-items: center;
  gap: 8px; /* perfect spacing between icon & text */
  font-weight: 600;
  color: #fff;
}

.chat-title i {
  color: #fff;
  font-size: 18px;
}
#closeChatCard {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
}

#closePopup {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #fff;
}

/* Messages area */
.chat-popup-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  max-height: 60vh;
  overflow-y: auto;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    "Helvetica Neue",
    Arial;
  background-color: #fff;
  box-sizing: border-box;
  font-size: 14px;
}

.chat-popup-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-popup-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 8px;
}

/* Each message */
.summary-item {
  display: flex;
  align-items: flex-end;
}

/* AI messages: left aligned */
.summary-item.ai-message {
  justify-content: flex-start;
}

/* User messages: right aligned */
.summary-item.user-message {
  justify-content: flex-end;
}

/* Bubble base style */
.summary-item p {
  margin: 0;
  padding: 10px 14px;
  line-height: 1.35;
  border-radius: 16px;
  max-width: 90%;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
  position: relative;
  background: #c1c1c1;
  color: #000;
}

/* AI bubble */
.summary-item.ai-message p {
  background: #f1f5f9;
  color: #0f172a;
  border-top-left-radius: 6px;
}

@media (max-width: 420px) {
  .summary-item.ai-message::before {
    display: none;
  }
}

/* User bubble */
.summary-item.user-message p {
  background: #d14900;
  color: #fff;
  border-top-right-radius: 6px;
}

/* Bubble pointers */
.summary-item.ai-message p::after,
.summary-item.user-message p::after {
  content: "";
  position: absolute;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  bottom: 6px;
}

.summary-item.ai-message p::after {
  left: -8px;
  border-right-color: #f1f5f9;
}

.summary-item.user-message p::after {
  right: -8px;
  border-left-color: #d14900;
}

/* Input area */
.chat-popup-input {
  display: flex;
  border-top: 1px solid #ddd;
  padding: 8px;
  background-color: #f9f9f9;
}

.chat-popup-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #ccc;
  border-radius: 20px;
  outline: none;
  font-size: 14px;
}

.chat-popup-input button {
  margin-left: 8px;
  padding: 5px 10px;
  background-color: #d14900;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: bold;
}

.chat-popup-input button:hover {
  background-color: #d14900;
}

/* Footer */
.chat-popup-footer {
  padding: 10px;
  border-top: 1px solid #ddd;
}

.chat-popup-footer button {
  background-color: #d14900;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-weight: bold;
  cursor: pointer;
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .chat-popup {
    width: 90%;
    right: 5%;
  }
  .summary-item p {
    max-width: 86%;
    padding: 10px 12px;
  }
}
