#ai-chatbot {
  position: fixed;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  font-family: sans-serif;
  z-index: 9999;
  text-align: center;
}

#chat-window {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 5vh;
  left: 50%;
  transform: translateX(-50%);
  width: 90vw;
  height: 80vh;
  max-height: 90vh;
  background: #fff;
  border:0;
  border-radius: 12px;
  box-shadow: 0 0 10px rgba(0,0,0,0.2);
  transition: all 0.3s ease;
  overflow: visible; 
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from { transform: translate(-50%, -100vh); opacity: 0; }
  to   { transform: translate(-50%, 0); opacity: 1; }
}

#chat-window.closing {
  animation: slideUp 0.4s ease-in forwards;
}

@keyframes slideUp {
  from { transform: translate(-50%, 0); opacity: 1; }
  to   { transform: translate(-50%, -100vh); opacity: 0; }
}

#chat-header {
  position: relative;
  background: #0d63c4;
  color: #fff;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 16px;
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

#chat-header::before {
  content: 'AI';
  position: absolute;
  top: -32px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(to bottom, #0d63c4 50%, transparent 50%);
  color: #fff;
  font-size: 20px;
  font-weight: bold;
  line-height: 64px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  z-index: 1;
  animation: pulse 2s ease-out infinite;
}

body.chat-open #chat-toggle {
  display: none !important;
}

#chat-close {
  cursor: pointer;
  font-size: 18px;
  color: #ccc;
  transition: color 0.3s, transform 0.2s;
}

#chat-close:hover {
  color: #06c;
  transform: scale(1.2);
}

#chat-close svg {
  transition: stroke 0.3s, transform 0.2s;
}

#chat-close:hover svg {
  stroke: #f00;
  transform: scale(1.2);
}

.chatbot-avatar {
  display: block;
  width: 65px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background-color: #06c;
  background-image: url('/inc/ai/images/chatbot.png');
  background-size: 90%;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .chatbot-avatar {
	width: 45px;
	background-size: 95%; /* Optional: adjust size for smaller frame */
  }
}

.chatbot-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chatbot-text {
  flex: 1;
}

.chatbot-text strong,
.user-text strong {
  margin-bottom: 4px;
}

.chatbot-output p {
  margin: 0;
}

.user-avatar {
  display: block;
  width: 65px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background-color: #ccc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23888' viewBox='0 0 24 24'%3E%3Cpath d='M12 12c2.7 0 4.8-2.1 4.8-4.8S14.7 2.4 12 2.4 7.2 4.5 7.2 7.2 9.3 12 12 12zm0 2.4c-3.2 0-9.6 1.6-9.6 4.8V22h19.2v-2.8c0-3.2-6.4-4.8-9.6-4.8z'/%3E%3C/svg%3E");
  background-size: 60%;
  background-position: center;
  background-repeat: no-repeat;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .user-avatar {
	width: 45px;
	background-size: 65%;
  }
}

.user-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.user-text {
  flex: 1;
}

@media (max-width: 600px) {
  .chatbot-message,
  .user-message {
	display: flex;
	flex-wrap: nowrap;
	align-items: flex-start;
	gap: 10px;
  }

  .chatbot-avatar,
  .user-avatar {
	flex: 0 0 auto;
	width: 45px;
	height: 45px;
  }

  .chatbot-text,
  .user-text {
	flex: 1 1 auto; 
	text-align: left;
  }
}

#chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  max-height: calc(80vh - 220px); 
  padding: 16px;
  font-size: 14px;
  background: #f8f9fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  scroll-behavior: smooth;
}

#chat-messages .message {
  padding: 10px 14px;
  border-radius: 8px;
  line-height: 1.4;
  word-break: break-word;
}

#chat-messages div strong {
  font-weight: 600;
}

.cta-options {
  padding: 10px 12px;
  border-top: 1px solid #ccc;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;   /* ✅ REQUIRED */
  z-index: 1;
}

.cta-options button {
  padding: 4px 8px;
  font-size: 12px;
  cursor: pointer;
}


#chat-input-area {
  display: flex;
  align-items: center;
  padding: 12px;
  background: #fff;
  border-top: 1px solid #ccc;
  border-bottom-left-radius: 12px;
  border-bottom-right-radius: 12px;
  flex-shrink: 0;  /* ✅ ensures it stays visible */
  z-index: 1;
}

#chat-input-area input {
  flex-grow: 1;
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 20px;
  font-size: 14px;
  outline: none;
  background: rgba(244, 244, 244, 1) !important; 
}

#sendBtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #0d63c4;  /* blue background */
  color: #fff;                /* icon default */
  border: none;
  margin-left: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: background-color 0.3s, color 0.3s;
  border: 1px #0d63c4 solid;
}

#sendBtn svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  fill: currentColor; /* ⬅️ Use currentColor for swap effect */
}

#sendBtn:hover {
  background-color: #fff;     /* white background */
  color: #0d63c4;             /* icon turns blue */
}

#chat-toggle {
  background-color: #0d63c4;
  color: #fff;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  line-height: 48px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% {
	box-shadow:
	  0 0 0 0 rgba(255, 255, 255, 0.5),
	  0 0 0 0 rgba(13, 99, 196, 0.4);
  }
  100% {
	box-shadow:
	  0 0 0 15px rgba(255, 255, 255, 0),
	  0 0 0 25px rgba(13, 99, 196, 0);
  }
}

#chat-warning {
  background-color: #ffeeba;
  color: #856404;
  padding: 10px;
  font-size: 13px;
  border-top: 1px solid #ffeeba;
}

#aibot-status {
  display: none;
  font-style: italic;
  color: #666;
  margin-top: 10px;
  font-size: 14px;
}

#aibot-status::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-left: 6px;
  border-radius: 50%;
  background: #0d63c4;
  animation: pulseDot 1s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes pulseDot {
  0%, 100% {
	transform: scale(1);
	opacity: 1;
  }
  50% {
	transform: scale(1.8);
	opacity: 0.3;
  }
}

/* Modal background overlay when chat is open */
body.chat-open {
  position: relative;
}

body.chat-open::before {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.5);
  z-index: 9998;
}

#chat-messages .message.user {
  align-self: flex-start;
  background-color: #f1f1f1;
  border: 1px solid #ccc;
  color: #000;
  padding: 10px 14px 10px 16px;
}

#chat-messages .message.bot {
  align-self: flex-start;
  background-color: #e0efff;
  border: 1px solid #ccc;
  color: #000;
  padding: 10px 16px 10px 14px;
}

#chat-messages .message.bot:first-of-type {
  width: 100%;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  
  #chat-messages .message.user,
  #chat-messages .message.bot {
	width: 100%;
	box-sizing: border-box;
	align-self: stretch;
  }
  
  .cta-options button {
	all: unset;
	font-size: 12px;
	color: #0d63c4 !important;
	text-decoration: underline;
	cursor: pointer;
	padding: 4px;
  }

  .cta-options button:hover {
	text-decoration: none;
  }

  .cta-options {
	display: flex;
	flex-direction: row;         /* ✅ horizontal layout */
	justify-content: center;
	align-items: center;
	gap: 12px;
	padding: 5px 6px;
  }
}

.chatbot-output h1, .chatbot-output h2, .chatbot-output h3 {
  font-weight: bold;
  margin-top: 1em;
  margin-bottom: 0.5em;
}

.chatbot-output p {
  margin: 0.5em 0;
  line-height: 1.6;
}

.chatbot-output ul {
  margin: 0.5em 0 0.5em 1.2em;
  padding-left: 1em;
}

.chatbot-output a {
  color: #337ab7;
  text-decoration: underline;
}

@media (prefers-color-scheme: dark) {
  #ai-chatbot #chat-window {
	background-color: #1e1e1e;
	border-color: #333;
  }

  #ai-chatbot #chat-header {
	background-color: #0d63c4;
	color: #fff;
  }

  #ai-chatbot #chat-messages {
	background-color: #2a2a2a;
  }

  #ai-chatbot #chat-messages .message.user {
	background-color: #3a3a3a;
	border-color: #555;
	color: #eee;
  }

  #ai-chatbot #chat-messages .message.bot {
	background-color: #2b3f52;
	border-color: #555;
	color: #eee;
  }

  #ai-chatbot #chat-input-area {
	background-color: #1e1e1e;
	border-top: 1px solid #444;
  }

  #ai-chatbot #chat-input-area input {
	background-color: #2c2c2c !important;
	color: #eee;
	border: 1px solid #555;
  }

  #ai-chatbot #sendBtn {
	background-color: #0d63c4;
	color: #fff;
	border-color: #0d63c4;
  }

  #ai-chatbot #sendBtn:hover {
	background-color: #fff;
	color: #0d63c4;
  }
}

#chat-messages h3 {
  display: flex;
}
#chat-messages h3 strong {
  margin-left: 6px;
}