/**
 * All of the CSS for your public-facing functionality should be
 * included in this file.
 */

.chat-search__button-activate {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  position: fixed;
  bottom: 20px;
  right: 20px;
  background-color: rgba(var(--cs-primary-color), 0.3);
  color: rgb(var(--cs-primary-color));
  border: none;
  padding: 10px 30px;
  border-radius: 25px;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  z-index: 999999999;
  transition: all 300ms;
}

.chat-search__button-activate:hover {
  background-color: rgb(var(--cs-primary-color));
  color: #fff;
}

.chat-search__button-activate-text {
  display: inline-block;
  vertical-align: middle;
  line-height: 1;
}

.chat-search__button-activate-icon {
  display: inline-block;
  width: 25px;
  height: 25px;
}

body.chat-search-body--active {
  overflow: hidden;
  position: fixed;
}

.chat-search {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  padding: 0;
  background-color: #dce6f3;
  z-index: 99999999;
  box-sizing: border-box;
  font-family: inherit;
}

.chat-search--active {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.chat-search__loader {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  /* background-color: rgba(var(--cs-primary-color), 0.5); */
  z-index: 999999999;
}

.chat-search__loader-svg {
  circle {
    fill: rgba(var(--cs-primary-color), 1);
  }
}

.chat-search__content {
  display: block;
  width: 100%;
  margin: 0 auto;
  height: 100%;
}

.chat-search__form,
.chat-search__form-shortcode {
  bottom: -15px;
  left: 50%;
  width: calc(100% - 60px);
  max-width: 1020px;
  display: flex;
  flex-direction: row;
  align-items: center;
  transform: translateX(-50%);
  box-sizing: border-box;
  position: relative;
  border: 2px solid rgb(var(--cs-secondary-color));
  border-radius: 30px;
  background-color: #fff;
  box-shadow: 0 5px 0 0 rgb(var(--cs-secondary-color));
  z-index: 1;
  overflow: hidden;
}

.chat-search__form-shortcode {
  bottom: 0;
  margin: 25px 0;
}

.chat-search__icon {
  position: absolute;
  display: block;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
}

.chat-search__icon-svg {
  fill: rgb(var(--cs-primary-color));
}

input[type="text"].chat-search__input {
  flex: 1;
  border-radius: 5px;
  margin-right: 10px;
  padding: 15px 20px 15px 60px;
  border: none;
  background-color: transparent;
  font-weight: bold;
  line-height: 1;
  outline: none;
}

.chat-search__submit {
  padding: 10px 20px;
  background-color: rgba(var(--cs-primary-color), 0.3);
  color: rgb(var(--cs-primary-color));
  border: none;
  border-radius: 5px;
  cursor: pointer;
  margin: 0 10px 0 0;
  padding: 15px 30px;
  border-radius: 30px;
  text-transform: uppercase;
  line-height: 1;
  font-size: 12px;
  transition: all 300ms;
}

.chat-search__submit:hover {
  background-color: rgb(var(--cs-primary-color));
  color: #fff;
}

/* Comment Input Submit Button */
.chat-search-comment__submit-button {
  display: inline-block;
  padding: 15px 30px;
  background-color: rgba(var(--cs-primary-color), 0.3);
  color: rgb(var(--cs-primary-color));
  border: none;
  border-radius: 30px;
  cursor: pointer;
  text-transform: uppercase;
  line-height: 1;
  font-size: 12px;
  font-weight: bold;
  transition: all 300ms ease-in-out;
  margin-top: 10px; /* Space above the button */
  text-align: center;
}

.chat-search-comment__submit-button:hover:not(:disabled) {
  background-color: rgb(var(--cs-primary-color));
  color: #fff;
}

.chat-search-comment__submit-button:disabled {
  background-color: #e0e0e0;
  color: #a0a0a0;
  cursor: not-allowed;
  box-shadow: none;
}

.chat-search__messages-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0 auto;
  height: calc(100% - 100px);
  padding: 50px 0;
  overflow-y: auto;
  overflow-x: visible;
  box-sizing: border-box;
}

.chat-search__message {
  width: 100%;
  max-width: 960px;
  margin: 0 auto 20px;
  padding: 0 30px;
}

.chat-search__message--bot {
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(var(--cs-secondary-color), 0.5);
}

.chat-search__message--user {
  margin-top: 20px;
  font-size: 24px;
  color: #000;
}

.chat-search__message-content {
  margin: 30px 0 0;
}

.chat-search__message-container {
  position: relative;
  margin: 0 0 75px;
  color: rgb(var(--cs-secondary-color));
}

.chat-search__message-container--user {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  border: 2px solid rgba(var(--cs-secondary-color), 0.9);
  border-radius: 30px;
  background-color: transparent;
  box-shadow: 0 5px 0 0 rgba(var(--cs-secondary-color), 0.9);
  z-index: 1;
  overflow: hidden;
}

.chat-search__message-container--user .chat-search__icon {
  position: relative;
  transform: none;
}

.chat-search__message-container--user
  .chat-search__icon
  .chat-search__icon-svg {
  fill: rgba(var(--cs-secondary-color), 0.9);
}

.chat-search__message-content--user {
  padding: 15px;
  margin: 0;
  border: none;
  background-color: transparent;
  font-weight: bold;
  line-height: 1;
  outline: none;
  color: rgb(var(--cs-secondary-color));
  filter: brightness(0.5);
}

.chat-search__citations {
  margin: 20px 0;
  padding: 20px 0 0;
  border-top: 1px solid rgba(var(--cs-secondary-color), 0.5);
}

.chat-search__citations-title {
  text-transform: uppercase;
  font-size: 16px;
}

/* SOURCES POST TEMPLATE */

.chat-search__citations-list {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: space-between;
  gap: 30px;
  padding: 0;
  margin: 0 0 50px;
  font-size: 14px;
}

.chat-search__citations-item {
  display: block;
  width: calc((100% / 3) - 30px);
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  background-color: rgba(255, 255, 255, 0.5);
  box-sizing: border-box;
  transition: all 300ms;
}

.chat-search__citations-item:hover {
  background-color: rgba(255, 255, 255, 0.8);
  box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

.chat-search-source {
  display: block;
  box-sizing: border-box;
}

.chat-search-source__link {
  display: block;
}

.chat-search-source__title {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: bold;
  color: #000;
}

.chat-search-source__figure {
  position: relative;
  display: block;
  width: 100%;
  height: 0;
  padding-bottom: 56.25%; /* 16:9 Aspect Ratio */
  margin: 0 0 15px;
}

.chat-search-source__image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  position: absolute;
  top: 0;
  left: 0;
}

.chat-search-source__date {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: bold;
  color: #000000;
}

.chat-search-source__content {
  font-size: 14px;
  color: rgb(var(--cs-secondary-color));
}

/* SEARCH RESULTS *****/

.chat-search-results__grid {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 30px;
  width: 100%;
  min-height: 200px;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-size: 16px;

  @media all and (min-width: 767px) {
    flex-direction: row;
    flex-wrap: nowrap;
  }
}

.chat-search-results__content {
  flex: 0 1 66%;
}

.chat-search-source__title {
  font-size: 1.2rem;
  color: initial !important;
}

.chat-search-source__content {
  flex: 0 1 66%;
  box-sizing: border-box;
  color: initial !important;
  font-size: 0.8rem;
}

/* Override link color inheritance for search results source elements */
.chat-search-source__link {
  text-decoration: none;
}

.citation-card__link:hover .citation-card__title {
  color: var(--cs-primary-color);
}

.citation-card__link:hover .citation-card__excerpt {
  color: var(--cs-primary-color);
}

.chat-search-results__citations {
  flex: 0 1 34%;
  padding: 2vw;
  box-sizing: border-box;
  background-color: #fff;
  border-radius: 8px;
}

.chat-search-results__citations-list {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: stretch;
  gap: 30px;
}

.chat-search-results__citations-item {
  display: block;
  width: 100%;
  padding: 0 0 20px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.chat-search-results__citations-item:last-child {
  padding: 0;
  border-bottom: none;
}

.citation-card__title {
  margin: 0 0 5px;
  color: #000;
  font-size: 16px;
  font-weight: bold;
  transition: all 300ms;
}

.citation-card__excerpt {
  margin: 0;
  font-size: 16px;
  color: #000;
  transition: all 300ms;
}

/* Skeleton Loaders */
@keyframes skeletonPulse {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

.skeleton-line {
  height: 16px;
  margin-bottom: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

.skeleton-line--100 {
  width: 100%;
}

.skeleton-line--95 {
  width: 95%;
}

.skeleton-line--90 {
  width: 90%;
}

.skeleton-line--80 {
  width: 80%;
}

.skeleton-line--70 {
  width: 70%;
}

.skeleton-line--60 {
  width: 60%;
}

.skeleton-title {
  height: 20px;
  margin-bottom: 15px;
}

.ai-overview__skeleton {
  padding: 15px 0;
}

.citation-skeleton {
  padding: 0 0 15px 0;
  margin: 0 0 15px 0;
  border-bottom: 1px solid #f0f0f0;
}

.citation-skeleton:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.chat-search-results {
  /* max-height: 300px; Example */
  /* overflow-y: auto; */
  white-space: pre-wrap; /* Ensure whitespace and newlines are preserved */
  word-wrap: break-word; /* Added fallback */
  overflow-wrap: break-word; /* Ensure wrapping */
}

.ai-overview__svg {
  path {
    fill: rgb(var(--cs-primary-color)) !important;
  }
}

.ai-overview__content {
  display: block;
  line-height: 1.7;
  white-space: normal; /* Normal whitespace handling */
  word-wrap: break-word; /* Added fallback */
  overflow-wrap: break-word; /* Ensure wrapping */
}

.ai-overview__content h1,
.ai-overview__content h2,
.ai-overview__content h3,
.ai-overview__content h4,
.ai-overview__content h5,
.ai-overview__content h6 {
  line-height: 1.4;
}

.ai-overview__content ul,
.ai-overview__content ol {
  list-style-type: disc;
  margin: 0;
  margin-block-start: 0;
  margin-block-end: 0;
  padding: 0 0 20px 20px;
  padding-inline-start: 20px;
}

.ai-overview__content ol {
  list-style-type: decimal;
}

.ai-overview__content ul li,
.ai-overview__content ol li {
  margin: 0 0 10px;
  padding: 0;
  line-height: 1.2;
}

.ai-overview__score {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 1rem;
  position: relative;
  min-height: 60px;
}

.chat-search__message-score {
  margin: 25px 0 0;
  padding: 25px 0 0;
  border-top: 1px solid #ccc;
}

.ai-overview__disclaimer {
  font-size: 0.8rem;
}

.v-enter-active,
.v-leave-active {
  transition: opacity 0.5s ease;
}

.v-enter-from,
.v-leave-to {
  opacity: 0;
}

@keyframes fadeInOut {
  0% {
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.ai-overview__score {
  display: block;
  margin-top: 1rem;
  padding-top: 1.5rem;
  position: relative;
  width: 100%;
  min-height: 60px;
  border-top: 2px solid rgba(0, 0, 0, 0.3);
}

.ai-overview__score-container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.ai-overview__disclaimer {
  width: 100%;
  max-width: 400px;
  text-align: left;
}

.chat-search-score {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.chat-search-score__good,
.chat-search-score__bad {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  padding: 15px;
  border: 2px solid rgba(0, 0, 0, 0.2);
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 300ms;
}

.chat-search-score__good svg,
.chat-search-score__bad svg {
  width: 18px;
  height: 18px;
}

.chat-search-score__good:hover,
.chat-search-score__bad:hover {
  border-color: rgba(0, 0, 0, 0.5);
}

.chat-search-score__good:hover .chat-search-score__icon-outline {
  cursor: pointer;
  animation: wiggle 1s;
  transform-origin: center;
}

.chat-search-score__good--active,
.chat-search-score__bad--active {
  border-color: rgba(0, 0, 0, 0.5);
  background-color: rgba(0, 0, 0, 0.2);
}

.chat-search-score__bad:hover .chat-search-score__icon-outline {
  cursor: pointer;
  animation: wiggle 1s;
  transform-origin: center;
}

@keyframes wiggle {
  0% {
    transform: rotate(0deg);
  }
  7% {
    transform: rotate(5deg);
  }
  14% {
    transform: rotate(-5deg);
  }
  21% {
    transform: rotate(4deg);
  }
  28% {
    transform: rotate(-4deg);
  }
  35% {
    transform: rotate(3deg);
  }
  42% {
    transform: rotate(-3deg);
  }
  49% {
    transform: rotate(2deg);
  }
  56% {
    transform: rotate(-2deg);
  }
  63% {
    transform: rotate(1deg);
  }
  70% {
    transform: rotate(-1deg);
  }
  77% {
    transform: rotate(0.5deg);
  }
  84% {
    transform: rotate(-0.5deg);
  }
  90% {
    transform: rotate(0.25deg);
  }
  95% {
    transform: rotate(-0.25deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.ai-overview__content {
  /* Add specific styles for the content area if needed */
  /* Example: Add padding or margin */
  padding: 5px;
  overflow-wrap: break-word; /* Ensure long words/strings break and wrap */
  word-wrap: break-word; /* Older browsers */
  word-break: break-word; /* Consider this too, might be more aggressive */
}

/* WORDPRESS SEARCH FORM ==============*/
.search-form {
  input[type="search"] {
    /* Hide the clear button (x) in search inputs */

    /* For Webkit browsers (Chrome, Safari, new Edge) */
    -webkit-appearance: none; /* General reset for webkit search inputs */

    /* For Firefox - it doesn't typically show a clear button by default on type="search" */
    /* but ensuring appearance is none can sometimes help reset browser styles. */
    -moz-appearance: textfield; /* Reset Firefox appearance for search to behave like text */
    appearance: none; /* Standard property, also helps */
  }

  input[type="search"]::-webkit-search-decoration,
  input[type="search"]::-webkit-search-cancel-button,
  input[type="search"]::-webkit-search-results-button,
  input[type="search"]::-webkit-search-results-decoration {
    -webkit-appearance: none;
    display: none;
  }
}

/* Custom Clear Button for WordPress Search Form (added by Search.vue) */
.search-form .chat-search__clear-button {
  display: none;
  cursor: pointer;
  position: absolute;
  right: 48px;
  top: 50%;
  margin: 1px 0 0;
  transform: translateY(-50%);
  z-index: 2;
  color: black;
  line-height: 1;
  font-size: 31px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Default color, can be overridden by .cs-primary-color */
  color: rgb(var(--cs-primary-color));
}

.search-form .chat-search__clear-button:hover,
.search-form .chat-search__clear-button:focus {
  opacity: 0.7;
}

/* Adjust WordPress search input padding when our clear button is potentially visible */
.search-form input[type="search"] {
  /* Add some padding to the right so text doesn't go under the clear button */
  /* This value should be enough to accommodate the button + some spacing */
  /* Ensure this doesn't conflict with other specific search input styles from the theme */
  padding-right: 75px; /* Adjust as needed based on button size and position */
  box-sizing: border-box; /* Ensure padding is included correctly */
}

/* For IE/Edge (older versions) */
input[type="search"]::-ms-clear {
  display: none;
  width: 0;
  height: 0;
}

.chat-search-comment {
  display: block;
  padding: 30px 0;
  box-sizing: border-box;
}

.chat-search-comment__textarea {
  width: 100%;
  padding: 15px;
  font-size: 1em;
  border-radius: 5px;
  border-color: #ccc;
  box-sizing: border-box;
}

.chat-search-comment__textarea:focus {
  outline: none;
}

.chat-search-comment__char-count {
  display: block;
  margin: 5px 0 0;
  text-align: right;
  font-size: 0.8rem;
  font-style: italic;
}

/* Comment box fade-slide transition */
.comment-fade-slide-enter-active,
.comment-fade-slide-leave-active {
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.comment-fade-slide-enter-from,
.comment-fade-slide-leave-to {
  opacity: 0;
  transform: translateY(10px);
}

.comment-fade-slide-enter-to,
.comment-fade-slide-leave-from {
  opacity: 1;
  transform: translateY(0);
}
