/* styles.css */

/* Global Styles */
.kmchat-wrapper {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background-color: #ffffff;
    font-family: 'Open Sans', sans-serif;
    margin: 0;
    padding: 0;
    color: #525c69;
    overflow: hidden;
    transition: min-height 0.3s ease;
}

.kmchat-wrapper p {
    margin: 0 !important;
    padding: 0 !important;
}

/* Container */
.kmchat-container {
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
    margin-right: auto;
    margin-left: auto;
}

@media (min-width: 576px) {
    .kmchat-container {
        max-width: 540px;
    }
}

@media (min-width: 768px) {
    .kmchat-container {
        max-width: 720px;
    }
}

@media (min-width: 992px) {
    .kmchat-container {
        max-width: 960px;
    }
}

@media (min-width: 1200px) {
    .kmchat-container {
        max-width: 1140px;
    }
}

/* Row */
.kmchat-row {
    display: flex;
    flex-wrap: wrap;
    margin-right: -15px;
    margin-left: -15px;
}

/* Columns */
.kmchat-col-md-8 {
    position: relative;
    width: 100%;
    padding-right: 15px;
    padding-left: 15px;
}

@media (min-width: 768px) {
    .kmchat-col-md-8 {
        flex: 0 0 66.666667%;
        max-width: 66.666667%;
    }
}

.kmchat-offset-md-2 {
    margin-left: 16.666667%;
}

@media (max-width: 767px) {
    .kmchat-offset-md-2 {
        margin-left: 0;
    }
}

/* Form Group */
.kmchat-form-group {
    margin-bottom: 1rem;
}

/* Input Group */
.kmchat-input-group {
    display: flex;
    width: 100%;
}

/* Input Group Append */
.kmchat-input-group-append {
    display: flex;
}

/* Form Control */
.kmchat-form-control {
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    display: block;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box !important;
    border: 1px solid #ced4da !important;
    border-top-left-radius: 25px !important;
    border-bottom-left-radius: 25px !important;
    border-top-right-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    height: 50px !important;
    box-sizing: border-box !important;
}

.kmchat-form-control:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Search Button */
.kmchat-search-button {
    background-color: #13293d;
    border: none;
    border-top-right-radius: 25px !important;
    border-bottom-right-radius: 25px !important;
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    color: #fff;
    cursor: pointer;
    height: 50px !important;
    width: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    box-sizing: border-box; /* Included padding and border in height */
}

.kmchat-search-button:hover {
    background-color: #0f1d2a;
}

/* Headings */
.kmchat-title {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: #343a40;
}

.kmchat-heading {
    color: #13293d; /* Updated to match dark blue */
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
}

/* Response and Search Results */
.kmchat-response {
    background-color: transparent;
    border: none;
    min-height: 0;
    padding: 0;
    color: #525c69;
}

/* Alerts */
.kmchat-alert {
    padding: 0.75rem 1.25rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: 0.25rem;
}

.kmchat-alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

/* Search Results */
.kmchat_search-result {
    background-color: #f0f2f5cd;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    position: relative;
    margin-bottom: 15px; /* Space between search results */
    border-radius: 15px;
    transition: background-color 0.2s ease; /* Add transition to the div */
}

.kmchat_search-result:hover {
    background-color: #e9ecef; /* Apply hover background to the div */
    cursor: pointer; /* Apply cursor pointer to the div on hover */
}

.kmchat_search-result:last-child {
    border-bottom: none;
}

/* Search Result Number Styles */
.kmchat_search-result-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #13293d; /* Match search button color */
    color: #ffffff;
    border-radius: 50%;
    width: 24px; /* Slightly larger */
    height: 24px;
    font-size: 14px;
    margin-right: 8px;
    flex-shrink: 0;
}

/* Search Result Title */
.kmchat_search-result-title {
    color: #13293d; /* Updated to match dark blue */
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0;
}

/* Breadcrumbs and Text Alignment */
.kmchat_breadcrumb {
    color: #6c757d;
    font-size: 0.9rem;
    text-align: left;
    margin-top: 3px !important;
    margin-bottom: 12px !important;
    padding: 0 !important;
}

.kmchat_search-result-text {
    text-align: left;
    font-size: 1rem;
    color: #525c69;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding: 0 !important;
}

/* Citation Number Styles */
.citation-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #13293d; /* Updated to match search button */
    color: #ffffff; /* White text */
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    text-decoration: none;
    margin: 0 2px;
    transition: background-color 0.3s ease;
}

.citation-number:hover {
    background-color: #0f1d2a; /* Darker blue on hover */
}

/* Highlight for search results */
.highlight {
    background-color: #d0e7ff !important; /* Light blue highlight */
    transition: background-color 0.5s ease;
}

/* Utility Classes for Margin */
.my-5 {
    margin-top: 3rem !important;
    margin-bottom: 3rem !important;
}

.mb-3 {
    margin-bottom: 1rem !important;
}

/* Responsive Adjustments */
@media (max-width: 767px) {
    .kmchat-container {
        margin-top: 30px;
    }

    .kmchat_breadcrumb,
    .kmchat_search-result-text {
        margin-left: 0; /* Remove left margin on small screens for better alignment */
    }
}

/* Additional Enhancements */

/* Make the entire search result clickable if desired */
.kmchat_search-result a {
    color: #13293d; /* Consistent dark blue */
    text-decoration: none;
}

.kmchat_search-result a:hover {
    text-decoration: underline;
}

/* Ensure the citation numbers are visually distinct */
.citation-number {
    background-color: #13293d;
    color: #ffffff;
    border: none;
}

.citation-number:hover {
    background-color: #0f1d2a;
}

/* === Markdown Rendering Styles === */

/* Style for rendered Markdown in search results */
.kmchat_search-result-text ul {
    list-style-type: disc;
    padding-left: 20px;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.kmchat_search-result-text ol {
    list-style-type: decimal;
    padding-left: 20px;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.kmchat_search-result-text strong {
    font-weight: bold;
}

.kmchat_search-result-text em {
    font-style: italic;
}

.kmchat_search-result-text blockquote {
    border-left: 4px solid #dee2e6;
    padding-left: 16px;
    color: #6c757d;
    margin: 1em 0;
}

.kmchat_search-result-text code {
    background-color: #f8f9fa;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: monospace;
}

.kmchat_search-result-text pre {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
}

.kmchat_search-result-text a {
    color: #0d6efd;
    text-decoration: none;
}

.kmchat_search-result-text a:hover {
    text-decoration: underline;
}

/* General Link Styles within Search Results */
.kmchat_search-result .kmchat_breadcrumb {
    margin-bottom: 12px !important;
}

.kmchat_search-result .kmchat_search-result-text {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* General Link Styles within Search Results */
.kmchat_search-result .kmchat_search-result-text a {
    color: #007bff; /* Standard link color */
    text-decoration: underline;
}

.kmchat_search-result .kmchat_search-result-text a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Style for the full card link (should fill the div but be visually transparent) */
.search-result-card-link,
.search-result-card-link:visited {
    text-decoration: none !important; /* No underline */
    color: inherit;       /* Inherit text color */
    display: block;       /* Make the link fill the container */
    /* No background or transition needed here */
}

/* Remove specific hover style from the link itself */
/* .search-result-card-link:hover { ... } */

/* Ensure nested elements within the card link retain their specific colors WHEN DIV IS HOVERED */
.kmchat_search-result:hover .kmchat_search-result-title {
    color: #13293d !important; /* Keep title color */
}

.kmchat_search-result:hover .kmchat_breadcrumb {
    color: #6c757d !important; /* Keep breadcrumb color */
}

/* Make snippet text slightly darker when DIV is hovered */
.kmchat_search-result:hover .kmchat_search-result-text {
    color: #404852 !important; /* Slightly darker than #525c69 */
}

/* Keep citation number colors consistent when DIV is hovered */
.kmchat_search-result:hover .kmchat_search-result-number {
    background-color: #13293d !important; /* Match search button color */
    color: #ffffff !important;
}

/* Highlight effect for citation link scroll target */
.kmchat_search-result.highlight {
  background-color: #fdfd96; /* Light yellow */
  transition: background-color 0.5s ease-out;
  /* Add a slight border or outline for better visibility if needed */
  /* outline: 2px solid #fada5e; */
}

/* CSS Loading Spinner */
#kmchat_loading-spinner .spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-left-color: #333; /* Spinner color */
  border-radius: 50%;
  width: 30px;
  height: 30px;
  animation: spin 1s linear infinite;
  margin: 0 auto; /* Center the spinner */
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
