/* Knowledge item text truncation and wrapping */
.knowledge-item {
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.knowledge-content {
    flex: 1;
    min-width: 0; /* Enable text truncation in flex container */
}

.knowledge-title {
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #2E7D32;
}

.knowledge-text {
    /* Limit to 3 lines of text */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
    max-height: 4.5em; /* 3 lines × 1.5 line-height */
    margin-bottom: 0.5rem;
    color: #333;
    
    /* Ensure proper word wrapping */
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Full text on hover (optional) */
.knowledge-item:hover .knowledge-text {
    -webkit-line-clamp: unset;
    max-height: none;
    transition: max-height 0.3s ease-out;
}

.knowledge-meta {
    font-size: 0.85rem;
    color: #666;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.knowledge-meta span {
    white-space: nowrap;
}

/* For documents section */
.documents-list .knowledge-text,
#documentsList .knowledge-text {
    /* Even shorter for document summaries */
    -webkit-line-clamp: 2;
    max-height: 3em; /* 2 lines × 1.5 line-height */
}

/* Also limit the documents list height */
.documents-list,
#documentsList {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Knowledge list container */
.knowledge-list {
    max-height: 600px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Scrollbar styling */
.knowledge-list::-webkit-scrollbar {
    width: 6px;
}

.knowledge-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.knowledge-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.knowledge-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Add click-to-expand functionality indicator */
.knowledge-item {
    cursor: pointer;
    position: relative;
}

.knowledge-item::after {
    content: "Click to expand";
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    font-size: 0.75rem;
    color: #999;
    opacity: 0;
    transition: opacity 0.2s;
}

.knowledge-item:hover::after {
    opacity: 1;
}

/* Expanded state */
.knowledge-item.expanded .knowledge-text {
    -webkit-line-clamp: unset;
    max-height: none;
}

.knowledge-item.expanded::after {
    content: "Click to collapse";
}