.hidden {
  display: none;
}

#chat-widget-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  flex-direction: column;
  z-index: 9999;
}

#chat-popup {
  height: 65vh;
  max-height: 70vh;
  transition: all 0.3s ease;
  overflow: hidden;

  /* Initial hidden state */
  display: flex; /* Keep flex but make invisible */
  opacity: 0;
  transform: translateY(20px);
  visibility: hidden;
  pointer-events: none;
}

#chat-popup.is-open {
  opacity: 1;
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

@media (max-width: 768px) {
  #chat-popup {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    z-index: 9999!important
  }
}

/* Typing indicator animation */
#typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 10px;
}

#typing-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background: #999;
  border-radius: 50%;
  opacity: 0.4;
  animation: typing 1.4s infinite;
}

#typing-indicator span:nth-child(2) { 
  animation-delay: 0.2s; 
}

#typing-indicator span:nth-child(3) { 
  animation-delay: 0.4s; 
}

@keyframes typing {
  0%, 100% { 
    transform: translateY(0);
    opacity: 0.4;
  }
  50% { 
    transform: translateY(-4px);
    opacity: 1; 
  }
}

/* Tables in chat messages */
#chat-messages table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

#chat-messages th,
#chat-messages td {
  border: 1px solid #ccc;
  padding: 4px 6px;
  text-align: left;
}

#chat-messages th {
  background-color: #f3f4f6;
  font-weight: 600;
}

/* Chat bubble */
.chat-bubble {
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.875rem;
  transition: background-color 0.2s ease;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 50;
  position: relative;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
}

@media (max-width: 768px) {
  .chat-bubble {
    bottom: .5rem;
    right: .5rem;
  }
}

.chat-indicator {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 2px solid white;
}

/* Tooltip */
.chat-tooltip {
  position: absolute;
  background-color: #fff;
  box-shadow: 0 .9px 1.4px -4px rgba(0,0,0,.042),
              0 2.3px 3.3px -4px rgba(0,0,0,.061),
              0 4.7px 6.3px -4px rgba(0,0,0,.075),
              0 9px 11.2px -4px rgba(0,0,0,.089),
              0 18.2px 20.9px -4px rgba(0,0,0,.108),
              0 50px 50px -4px rgba(0,0,0,.15);
  font-size: 16px;
  line-height: 19px;
  animation: slideUp 0.3s ease-in-out;
  z-index: 60;
  font-weight: 700;
  padding: 10px 8px;
  right: 50px;
  bottom: 80px;
  width: 150px;
  border-radius: 32px;
  color: black;
  transition: all 0.2s ease-in-out;
  text-align: center; 
}

.chat-tooltip:after {
  content: "";
  display: block;
  position: absolute;
  right: 25px;
  bottom: -13px;
  width: 0;
  border-top: 1rem solid white;
  border-left: 1.5rem solid transparent;
  border-right: 0.1rem solid transparent;
}

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

/* Suggestion buttons */
.suggestion-btn {
  background-color: transparent;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  margin: 0.25rem;
  text-align: center;
  width: 100%;
  display: inline-block;
}
  
/* AI message styling - CHANGED FROM #ai-msg TO .ai-msg */
.ai-msg p, 
.ai-msg ol, 
.ai-msg ul {
  margin-bottom: 0.6rem;
}

.ai-msg ol {
  list-style: decimal;
}

.ai-msg ul {
  list-style: none;
}

.ai-msg ol li, 
.ai-msg ul li {
  margin-bottom: 0.3rem;
}

.ai-msg ol li p {
  margin-bottom: 0.2rem;
} 

.ai-msg ol li ul {
  margin-top: 0.3rem;
  margin-bottom: 1rem;
}

.ai-msg img {
  max-width: 50%;
  border-radius: 12px;
  margin-top: 0.5rem;
}

.ai-msg a {
  color: #004884;
  text-decoration: underline;
}

.ai-msg a:hover {
  color: #004884;
}

.ai-msg code {
  background-color: #f3f4f6;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.875em;
}

.ai-msg pre {
  background-color: #1f2937;
  color: #f9fafb;
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}

.ai-msg pre code {
  background-color: transparent;
  color: inherit;
  padding: 0;
}

/* Override WordPress/theme styles if needed */
#k-lib-chat-widget .suggestion-btn:hover {
  color: white !important;
}

#k-lib-chat-widget .suggestion-btn {
  cursor: pointer !important;
}

#chat-input { 
  font-size: 14px !important;
}

#chat-input::placeholder {
  color: #B5B8BF !important;
}

#close-popup:hover {
  color: #fff !important;
  background-color: transparent !important;
}
