#kdv-widget-button {
  position: fixed;
  right: 25px;
  bottom: 25px;
  background: linear-gradient(180deg, rgb(227, 0, 67) 3.6%, rgb(255, 156, 101) 102.440002%) !important;
  color: white !important;
  border: none !important;
  padding: 14px 20px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  box-shadow: none !important;
  z-index: 99999;
  transition: all 0.3s ease;
  width: auto;
  min-width: auto;
}

#kdv-widget-button:hover {
  background: linear-gradient(180deg, rgb(200, 0, 50) 3.6%, rgb(230, 140, 90) 102.440002%) !important;
  box-shadow: none !important;
  transform: translateY(-2px);
}

/* Button when chat is open - becomes circular */
#kdv-widget-button.open {
  border-radius: 50%;
  width: 56px;
  height: 56px;
  padding: 0;
  gap: 0;
  background: linear-gradient(180deg, rgb(227, 0, 67) 3.6%, rgb(255, 156, 101) 102.440002%) !important;
}

/* Hide text when button is open (circular) */
#kdv-widget-button.open .button-text {
  display: none;
}

/* Show only icon when open */
#kdv-widget-button.open img {
  margin: 0;
}

#kdv-widget-button svg,
#kdv-widget-button img {
  width: 20px;
  height: auto;
  display: block;
  flex-shrink: 0;
}

#kdv-widget-button svg {
  max-height: 20px;
}

#kdv-widget-panel {
  position: fixed;
  right: 25px;
  bottom: 85px;
  width: 550px;
  height: 700px;
  background: white;
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  transition: all 0.3s ease;
}

/* Mobile view (full screen) */
@media screen and (max-width: 600px) {
  #kdv-widget-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh; /* Use dynamic viewport height if supported */
    border-radius: 0;
  }

  /* Hide the open button on mobile when chat is open to save space */
  #kdv-widget-button.open {
    display: none;
  }
  
  .kdv-log {
    padding: 10px;
  }
  
  .kdv-inputbar {
    padding: 15px 10px;
    padding-bottom: env(safe-area-inset-bottom, 15px);
  }

  /* Prevent auto-zoom on focus by using 16px font-size */
  .kdv-inputbar input {
    font-size: 16px !important;
  }
}

#kdv-widget-panel.open {
  display: flex;
}

.kdv-header {
  background: linear-gradient(180deg, rgb(227, 0, 67) 3.6%, rgb(255, 156, 101) 102.440002%) !important;
  color: white !important;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: none;
  flex-shrink: 0;
}

.kdv-header .title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: white !important;
}

.kdv-header .title strong {
  color: white !important;
}

.kdv-header .title svg,
.kdv-header .title img {
  width: 24px;
  height: auto;
  display: block;
  flex-shrink: 0;
}

.kdv-header .title svg {
  max-height: 24px;
}

.kdv-header .close {
  background: transparent;
  border: none;
  color: white !important;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s ease;
  margin: 0;
}

.kdv-header .close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.kdv-header .close:active {
  background: rgba(255, 255, 255, 0.3);
}

.kdv-log {
  flex: 1;
  padding: 14px;
  overflow-y: auto;
  background: #f6f7f8;
  display: flex;
  flex-direction: column;
}

.u {
  align-self: flex-end;
  background: rgb(0, 102, 153);
  color: white;
  padding: 10px 14px;
  border-radius: 12px;
  margin-bottom: 10px;
  width: fit-content;
  max-width: 65%;
  word-wrap: break-word;
  line-height: 1.5;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Bot message container */
.bot-message {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.bot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.bot-header .bot-avatar {
  width: 20px;
  height: auto;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bot-header .bot-avatar svg,
.bot-header .bot-avatar img {
  width: 20px;
  height: auto;
  display: block;
}

.bot-header .bot-avatar svg {
  max-height: 20px;
}

.bot-header .bot-name {
  font-size: 13px;
  font-weight: 600;
  color: rgb(0, 102, 153);
}

/* Bot message bubble */
.b {
  margin-right: auto;
  background: white;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #ddd;
  max-width: 75%;
  line-height: 1.5;
  color: rgb(0, 40, 70);
}

/* Make bold text less bold in bot messages */
.b strong {
  font-weight: 600;
}

/* Lists in bot messages */
.b ul,
.b ol {
  margin: 8px 0;
  padding-left: 0;
}

.b ul {
  list-style-type: none;
  padding-left: 24px;
}

.b ul li::before {
  content: "- ";
  margin-left: -20px;
  margin-right: 8px;
}

.b ol {
  list-style-type: decimal;
  padding-left: 32px;
  margin-left: 0;
}

.b ol li {
  margin: 8px 0;
  line-height: 1.6;
  display: list-item;
  list-style-position: outside;
  list-style-type: decimal;
}

.b ul li {
  margin: 8px 0;
  line-height: 1.6;
  display: list-item;
  list-style-position: outside;
}

/* Address formatting */
.b address {
  font-style: normal;
  line-height: 1.8;
  margin: 8px 0;
  display: block;
  white-space: pre-line;
}

.bot-message.welcome .b {
  background: #eef5f6;
  border-color: rgb(0, 102, 153);
  border-width: 2px;
}

/* Links in bot messages */
.b a {
  color: rgb(0, 102, 153);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.b a:hover {
  color: rgb(0, 80, 120);
  text-decoration: underline;
}

/* Sources section */
.b .sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #e5e7eb;
  font-size: 12px;
}

.b .sources strong {
  display: inline;
  margin-right: 6px;
  color: #333;
}

.b .sources a {
  color: rgb(0, 102, 153);
  text-decoration: none;
}

.b .sources a:hover {
  color: rgb(0, 80, 120);
  text-decoration: underline;
}

/* Typing indicator */
.typing-indicator {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-top: 6px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgb(0, 102, 153);
  animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  30% {
    transform: translateY(-10px);
    opacity: 1;
  }
}

.kdv-inputbar {
  display: flex;
  border-top: 1px solid #ddd;
  padding: 10px;
  gap: 10px;
  flex-shrink: 0;
}

.kdv-inputbar input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
}

.kdv-inputbar button {
  background: linear-gradient(180deg, rgb(227, 0, 67) 3.6%, rgb(255, 156, 101) 102.440002%) !important;
  border: none;
  color: white !important;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.kdv-inputbar button:hover {
  background: linear-gradient(180deg, rgb(200, 0, 50) 3.6%, rgb(230, 140, 90) 102.440002%) !important;
}

.kdv-footer {
  text-align: center;
  font-size: 10px;
  padding: 6px;
  color: #888;
  background: #fafafa;
  border-top: 1px solid #eee;
}

.kdv-feedback {
  display: none;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border-top: 1px solid #eee;
  background: #f6f7f8; 
  align-items: center; /* Center the thumbs */
}

.kdv-feedback.visible {
  display: flex;
  animation: slideUp 0.3s ease-out;
}

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

.kdv-feedback-title {
  font-weight: 600;
  color: #004066;
  text-align: center;
}

.kdv-feedback-options {
  display: flex;
  gap: 20px;
  justify-content: center;
  width: 100%;
}

.kdv-feedback-options button {
  flex: 0 1 80px;
  border-radius: 12px;
  border: 1px solid #ddd;
  background: white;
  padding: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kdv-feedback-options button .icon {
  font-size: 24px;
  line-height: 1;
}

.kdv-feedback-options button .label {
  display: none; /* Hide labels if they existed */
}

.kdv-feedback-options button.selected,
.kdv-feedback-options button:hover {
  background: #fff1f5;
  border-color: rgb(227, 0, 67);
  transform: scale(1.1);
}

.kdv-feedback-reasons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
}

.kdv-feedback-reasons button {
  background: white;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: left;
  font-size: 14px;
  color: #333;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  line-height: 1.4;
}

.kdv-feedback-reasons button:hover {
  background: #f9f9f9;
  border-color: #ddd;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Remove textarea and submit button styles */
.kdv-feedback textarea,
.kdv-feedback-actions .submit {
  display: none;
}

.kdv-feedback-actions {
  display: flex;
  justify-content: center;
  width: 100%;
}

.kdv-feedback-actions .skip {
  background: transparent;
  border: none;
  color: #888;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px;
}

.kdv-feedback-error {
  font-size: 12px;
  color: #b00020;
  min-height: 16px;
}
