#chatMessages {
    flex: 1 1 auto;  /* grow, shrink, and auto basis */
    display: flex;
    flex-direction: column;
    height: auto;  /* let it grow naturally */
    overflow-y: auto;
    margin-bottom: 1rem;
    padding-right: 1rem;
    padding-bottom: 1rem; /* Add padding to ensure last message is visible */
    word-wrap: break-word;
    scroll-behavior: smooth; /* Add smooth scrolling */
    position: relative; /* For absolute positioning of image preview row */
}

#chatMessages::-webkit-scrollbar {
    width: 8px;
}

#chatMessages::-webkit-scrollbar-track {
    background: var(--bs-dark);
}

#chatMessages::-webkit-scrollbar-thumb {
    background-color: var(--bs-primary);
    border-radius: 4px;
}

.chat-message {
    margin-bottom: 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    position: relative; /* Add position relative for copy button positioning */
}

.chat-message-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
    margin-bottom: 1rem;
}

.user-message {
    background-color: var(--bs-primary);
    margin-right: 1rem;
}

.assistant-message {
    background-color: var(--bs-dark-text-emphasis);
    margin-left: 1rem;
    position: relative; /* Add position relative for absolute positioning of gradient line */
    padding-top: 1rem; /* Add padding to make room for the gradient line */
}

/* Add gradient line to all assistant messages */
.assistant-message::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--bs-primary), transparent);
    border-radius: 0;
}

/* Progress bar for initial loading and responses */
.progress-gradient-line {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    border-radius: 0;
}

.progress-gradient-line .progress-bar {
    width: 100%;
    background: linear-gradient(90deg, transparent, var(--bs-primary), transparent);
    animation: moveGradient 2s linear infinite;
}

@keyframes moveGradient {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.system-message {
    background-color: rgba(255, 255, 255, 0.1);
    font-style: italic;
    font-size: 0.9rem;
}

#chatSpinner {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    background: var(--bs-dark);
}

.chat-message p {
    margin-bottom: 0.5rem;
}

.chat-message ul, .chat-message ol {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
}

.chat-message code {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

.chat-message pre {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin-bottom: 0.5rem;
}

.chat-message pre code {
    background-color: transparent;
    padding: 0;
}

.chat-message a {
    color: var(--bs-info);
    text-decoration: underline;
}

.chat-message blockquote {
    border-left: 3px solid var(--bs-info);
    margin-left: 0;
    padding-left: 1rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Table styles in chat messages */
.chat-message table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    overflow-x: auto;
    display: block; /* Make tables scrollable horizontally */
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 6px;
}

.chat-message table th,
.chat-message table td {
    padding: 8px 12px;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-message table th {
    background-color: rgba(var(--bs-primary-rgb), 0.15);
    color: #fff;
    font-weight: 600;
    text-align: center;
}

.chat-message table tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.05);
}

.chat-message table tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.1);
}

/* Chat input container and send button styles */
.chat-input-container {
    position: sticky;
    bottom: 0;
    padding: 1rem;
    margin: 0 -1rem -1rem -1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background-color: var(--bs-dark);
    width: auto;
    z-index: 1050;
/*    position: relative;
    padding: 1rem;
    margin: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;  */
}

/* Add styles for when image preview row is active */
.chat-input-container.with-image-preview {
    padding-bottom: 120px; /* Add padding for the image preview row */
    margin-top: 0; /* Reset margin */
}

.chat-input {
    width: 100%;
    resize: none;
    border-radius: 0.5rem !important;
    min-height: 85px !important;
    max-height: 85px !important;
    padding-right: 140px !important; /* Adjusted to make room for image button */
    margin: 0;
}

.chat-send-button {
    position: absolute;
    right: 24px;
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0.25rem;
    padding: 6px;
    margin-top: -10px;
    width: 65px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-send-button:hover {
    transform: translateY(-50%) scale(1.02);
    box-shadow: 0 0 8px rgba(94, 114, 228, 0.5);
}

.chat-send-button:active {
    transform: translateY(-50%) scale(0.97);
}

/* Hide the send icon by default (only show on mobile) */
.send-icon {
    display: none;
    transition: transform 0.2s ease;
}

.send-text {
    transition: transform 0.2s ease;
}

.chat-send-button:hover .send-text,
.chat-send-button:hover .send-icon {
    transform: scale(1.05);
}

.chat-send-button:active .send-text,
.chat-send-button:active .send-icon {
    transform: scale(0.95);
}

/* Image upload button styles */
.chat-image-button {
    position: absolute;
    right: 95px; /* Position it to the left of the send button */
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0.25rem;
    padding: 6px;
    margin-top: -10px;
    width: 40px;
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    display: none !important; /* Hide the image button by default */
}

.chat-image-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.chat-image-button:active {
    transform: translateY(-50%) scale(0.95);
    background-color: rgba(255, 255, 255, 0.15);
}

.chat-image-button i {
    transition: transform 0.2s ease;
}

.chat-image-button:hover i {
    transform: scale(1.15);
    color: rgba(255, 255, 255, 0.95);
}

.chat-image-button:active i {
    transform: scale(0.9);
}

/* Image preview container styles */
.image-preview-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
}

.image-preview {
    max-height: 200px;
    max-width: 100%;
    border-radius: 0.25rem;
}

.remove-image-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.remove-image-btn:hover {
    background-color: rgba(255, 0, 0, 0.7);
    cursor: pointer;
}

/* Chat message with image styles */
.chat-image-container {
    margin-top: 0.5rem;
    max-width: 100%;
    position: relative;
}

.chat-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 0.25rem;
}

/* New styles for the image preview in chat */
.image-preview-message {
    border: 2px solid #5e72e4 !important; /* Highlight the preview message */
    position: relative;
}

.image-preview-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    z-index: 1;
}

/* Image thumbnail styles */
.chat-image-thumbnail-container {
    position: relative;
    width: 120px;
    height: 120px;
    margin: 0;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    background-color: rgba(0, 0, 0, 0.2);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.chat-image-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-thumbnail-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s;
    z-index: 2;
}

.remove-thumbnail-btn:hover {
    background-color: rgba(220, 53, 69, 0.8);
}

/* Image modal styles */
.image-preview-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.image-preview-modal.show {
    opacity: 1;
    display: flex;
}

.image-preview-modal-content {
    max-width: 90%;
    max-height: 90%;
    position: relative;
}

.image-preview-modal-img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.image-preview-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Adjust heights for narrow screens to prevent overlap */
@media screen and (max-width: 576px) {
    .chat-input {
        /* min-height: 68px !important; */
        max-height: 68px !important;
        padding-right: 130px !important; /* Adjusted padding */
    }
    
    .chat-send-button {
        margin-top: -15px !important;  /* Force override for narrow screens only */
        width: 40px !important;  /* Make same width as other buttons */
        right: 20px !important;  /* Position adjusted further left */
    }
    
    /* Show icon and hide text in mobile view */
    .send-text {
        display: none;
    }
    
    .send-icon {
        display: block;
        font-size: 1.1rem;
    }
    
    .chat-image-button {
        margin-top: -16px !important;
        right: 64px !important; /* 3px spacing from send button (0px + 40px + 3px = 43px) */
    }
    
    .chat-document-button {
        margin-top: -16px !important;
        right: 68px !important; /* 3px spacing from image button (43px + 40px + 3px = 86px) */
    }
    
    .chat-image-button:hover,
    .chat-document-button:hover {
        transform: translateY(-50%) scale(1.05);  /* Maintain hover transform with margin adjustment */
    }
    
    .chat-image-button:active,
    .chat-document-button:active {
        transform: translateY(-50%) scale(0.95);  /* Maintain active transform with margin adjustment */
    }
    
    .chat-send-button:hover {
        transform: translateY(-50%) scale(1.05);  /* Apply hover effect to send button */
    }
    
    .chat-send-button:active {
        transform: translateY(-50%) scale(0.95);  /* Apply active effect to send button */
    }
}

/* LaTeX styles */
.katex {
    font-size: 1.1em;
    color: var(--bs-light);
}

.katex-display {
    margin: 1em 0;
    overflow-x: auto;
    overflow-y: hidden;
}

.katex-html {
    white-space: normal;
}

/* Context accordion styles */
.context-accordion {
    margin-top: 1rem;
}

.context-accordion .accordion-item {
    background-color: var(--bs-dark);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.context-accordion .accordion-button {
    background-color: var(--bs-dark);
    color: rgba(255, 255, 255, 0.6);
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
}

.context-accordion .accordion-button:not(.collapsed) {
    background-color: var(--bs-primary);
    color: var(--bs-light);
}

.context-accordion .accordion-button::after {
    transform: scale(0.75);
    opacity: 0.6;
}

.context-accordion .accordion-button:not(.collapsed)::after {
    transform: scale(0.75) rotate(180deg);
    opacity: 0.6;
}

.context-accordion .accordion-body {
    padding: 1rem;
    background-color: var(--bs-dark);
    color: var(--bs-light);
}

.context-card {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
    background-color: var(--bs-dark-bg-subtle);
}

.context-card.current-card {
    background-color: var(--bs-primary);
    margin-bottom: 0.5rem;
}

.context-card:last-child {
    margin-bottom: 0;
}

.context-card-title {
    font-weight: 500;
    margin-bottom: 0.75rem;
    padding-top: 0.125rem;
}

.context-card-summary {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
}

/* Ensure proper spacing in modal body */
.modal-body {
    padding-bottom: 1rem;
}

/* Disclaimer text styling */
.disclaimer-text {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-top: 0.5rem;
    padding-left: 0.5rem;
    margin-bottom: 1rem;
}

/* Update modal sizing and scrolling */
.modal-dialog.modal-lg {
    height: 85vh;
    margin: 7.5vh auto;
    display: flex;
    max-width: 95%;
}

.modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow: hidden;  /* Hide scrollbar on modal body */
}

/* Keep input container and accordion at bottom */
.chat-input-container {
    flex-shrink: 0;
    margin-top: auto;
    position: relative;
    background: var(--bs-dark);  /* Match modal background */
    padding: 1rem;
    margin: 0 -1rem -1rem -1rem;  /* Negative margins to reach edges */
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

#activityContextAccordion {
    flex-shrink: 0;
    margin-top: 1rem;
}

/* Context accordion styles */
.context-accordion {
    margin-top: 1rem;
}

.context-accordion .accordion-body {
    padding: 1rem;
    background-color: var(--bs-dark);
    color: var(--bs-light);
    overflow: visible;  /* Allow content to expand */
}

/* Ensure modal backdrop covers full scrollable area */
.modal-backdrop {
    position: fixed;
    height: 100vh;
}

#extendedContextAccordion .accordion-button::after {
    transform: scale(0.75);
    opacity: 0.6;
    filter: invert(0.5) brightness(1.75);
}

#extendedContextAccordion .accordion-button:not(.collapsed) {
    background-color: var(--bs-primary);
    color: white;
}

#extendedContextAccordion .accordion-button:not(.collapsed)::after {
    transform: scale(0.75) rotate(180deg);
    opacity: 0.6;
    filter: invert(0.5) brightness(1.75);
}

#extendedContext .accordion-body {
    font-size: 0.8rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, 0.9);
}

#extendedContext .accordion-body strong,
#extendedContext .accordion-body b {
    color: rgba(255, 255, 255, 1);
    font-weight: 500;
}

#extendedContext .accordion-body p {
    margin-bottom: 0.5rem;
}

#extendedContext .accordion-body p:last-child {
    margin-bottom: 0;
    background-color: var(--bs-dark-text-emphasis);  /* Using Bootstrap's dark subtle background color */
    padding: 0.75rem;
    border-radius: 0.25rem;
}

/* Style for card titles in context */
#extendedContext .accordion-body p strong {
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    display: inline;
}

/* Add this to ensure the colon is included in the bold text
#extendedContext .accordion-body p strong::after {
    content: ":";
    font-weight: 600;
    color: white;
}
 */

.message-header {
    display: none;  /* Hide instead of removing */
    font-size: 0.8rem;
    margin-bottom: 0.25rem;
    opacity: 0.8;
}

.user-name {
    font-weight: 500;
}

.message-time {
    margin-left: 0.5rem;
    opacity: 0.7;
}

#userList .list-group-item {
    border-color: rgba(255, 255, 255, 0.1);
}

#userList .list-group-item:hover {
    background-color: var(--bs-primary) !important;
}

#userList .list-group-item.active {
    background-color: var(--bs-primary) !important;
    border-color: var(--bs-primary);
}

.chat-input-container .text-muted {
    margin: 0.5rem 0 0;
}

/* Adjust spacing between chat input and Extended Context */
#extendedContextAccordion {
    flex-shrink: 0;
    margin-top: 1rem;
    overflow-y: auto;
}

/* Make chat messages container scrollable */
#dashboardChatMessages {
    flex: 1 1 auto;
    overflow-y: auto;  /* Enable vertical scrolling */
    padding-right: 1rem;
    margin-bottom: 1rem;
}

/* Activity context styles */
.board-activity {
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.engagement-badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.card-activity {
    padding: 0.5rem;
    border-left: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease;
}

.card-activity:hover {
    background: rgba(255, 255, 255, 0.02);
}

.card-activity.most-recent {
    border-left-color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), 0.05);
}

.chat-preview {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 0.25rem;
    padding: 0.5rem;
}

.chat-line {
    padding: 0.25rem 0;
    opacity: 0.8;
}

.chat-role {
    display: inline-block;
    width: 1.5rem;
    opacity: 0.7;
}

.project-name {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Activity context styles */
.accordion-body {
    max-height: 300px;  /* Set a max height */
    overflow-y: auto;   /* Enable vertical scrolling */
    padding: 1rem;
}

#activitySummary {
    padding-right: 0.5rem;  /* Add space for scrollbar */
}

/* Style the scrollbar */
.accordion-body::-webkit-scrollbar {
    width: 8px;
}

.accordion-body::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.accordion-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.accordion-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Loading indicator styles */
#dashboardLoadingIndicator {
    z-index: 9999;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#dashboardLoadingIndicator .spinner-border {
    width: 2rem;
    height: 2rem;
}

.streaming-indicator.active {
    display: flex;
    justify-content: center;
    padding: 10px;
}

.thinking-pill {
    display: flex;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 6px 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.thinking-text {
    font-size: 14px;
    font-weight: 500;
    font-style: italic;
    color: rgba(255, 255, 255, 0.9);
    margin-right: 8px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Context hierarchy styles */
.context-hierarchy {
    padding: 0.5rem;
    background-color: var(--bs-dark-border-subtle);
    border-radius: 0.25rem;
}

.context-hierarchy .text-muted {
    font-size: 0.8rem;
    line-height: 1.2;
}

/* Update existing context entry styles */
#extendedContext .context-entry {
    margin-bottom: 0.75rem;
    background-color: var(--bs-dark-border-subtle);
    padding: 0.75rem;
    border-radius: 0.25rem;
}

#extendedContext .context-entry.current-card {
    background-color: var(--bs-primary);
}

#extendedContext .context-entry:last-child {
    margin-bottom: 0;
}

#extendedContext .context-entry strong {
    display: block;
    font-weight: 600;
    color: white;
    margin-bottom: 0.5rem;
}

#extendedContext .context-entry-summary {
    /* Swapped colors: lighter text on a slightly darker background */
    background-color: #1e1e23; /* Darker grey for better contrast */
    color: rgba(255, 255, 255, 0.92); /* Nearly white text */
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Column Summary Modal Styles */
#summaryContent .context-entry {
    margin-bottom: 0.5rem;
    background-color: var(--bs-dark-border-subtle);
    padding: 0.75rem;
    border-radius: 0.25rem;
    display: block;
}

#summaryContent .context-entry:last-child {
    margin-bottom: 0;
}

#summaryContent .context-entry strong {
    display: block;
    font-weight: 600;
    color: white;
    margin-bottom: 0.5rem;
}

#summaryContent .context-entry-summary {
    color: rgba(255, 255, 255, 0.9);
}

#summaryContent .context-entry-summary .mb-2:last-child {
    margin-bottom: 0 !important;
}

#summaryContent .text-light-emphasis {
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Add styles for chat spacer */
.chat-spacer {
    height: 60vh; /* Increased from 40vh to 60vh to provide more space on larger screens */
    min-height: 300px; /* Increased minimum height for larger screens */
    flex-shrink: 0; /* Prevent the spacer from shrinking */
    margin-top: auto; /* Push the spacer to the bottom */
    transition: height 0.3s ease; /* Add smooth transition when height changes */
}

/* Responsive adjustments for chat spacer */
@media screen and (min-height: 900px) {
    .chat-spacer {
        height: 70vh; /* Even more space on very tall screens */
    }
}

@media screen and (max-height: 600px) {
    .chat-spacer {
        height: 40vh; /* Less space on smaller screens */
        min-height: 200px;
    }
}

/* Add styles for new message container */
.new-message-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Add styles for chat history container */
.chat-history-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

/* Image preview row at the bottom of chat modal */
.chat-image-preview-row {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 15px;
    padding: 15px;
    background-color: rgba(38, 42, 46, 0.75);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    min-height: 150px;
    height: auto;
    white-space: nowrap;
    margin: 12px 0;
    align-items: center; /* Center items vertically */
    justify-content: flex-start; /* Align items to the start */
}

.chat-image-preview-row .chat-image-thumbnail-container {
    display: inline-block;
    margin: 0;
    position: relative;
    vertical-align: middle;
}

/* Style for the remove button inside preview row */
.chat-image-preview-row .remove-thumbnail-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    left: auto;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s;
    z-index: 2;
}

.chat-image-preview-row .remove-thumbnail-btn:hover {
    background-color: rgba(220, 53, 69, 0.8);
}

@media (max-height: 700px) {
    .chat-image-preview-row {
        bottom: 130px; /* Adjust for smaller screens */
    }
}

/* Chat input container shouldn't need adjustment - the row floats above it */
.chat-input-container.with-image-preview {
    /* No additional styling needed as the preview row floats above */
}

/* New styles for multiple images container */
.chat-images-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.chat-images-container .chat-image-thumbnail-container {
    margin: 0;
    flex: 0 0 auto;
}

/* Document preview container styles */
.document-preview-container {
    position: relative;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.75rem 1rem;
}

.document-preview-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
}

.document-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background-color: rgba(73, 80, 87, 0.5);
    border-radius: 0.25rem;
    color: #e9ecef;
}

.document-icon i {
    font-size: 1.25rem;
}

.document-info {
    display: flex;
    flex-direction: column;
}

.document-name {
    font-weight: 500;
    word-break: break-word;
}

.document-size {
    font-size: 0.8rem;
    opacity: 0.7;
}

.remove-document-btn {
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 1rem;
}

.remove-document-btn:hover {
    background-color: rgba(255, 0, 0, 0.7);
}

/* Document preview in chat */
.chat-document-preview-row {
    display: flex;
    padding: 8px 0;
    gap: 8px;
    overflow-x: auto;
    margin-top: 15px;
    margin-bottom: 15px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 20px 10px 20px 0px;
    align-items: center; /* vertically center icon + text */
}

.chat-document-thumbnail-container {
    position: relative;
    min-width: 180px;
    height: 70px;
    display: flex;
    align-items: center;
    background-color: rgba(73, 80, 87, 0.5);
    border-radius: 6px;
    padding: 12px 30px 12px 20px; /* Increased left padding */
    gap: 12px;
}

.chat-document-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #e9ecef;
}

.chat-document-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    justify-content: center; /* keep filename + size centered vertically */
}

.chat-document-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.9rem;
}

.chat-document-type {
    font-size: 0.75rem;
    opacity: 0.7;
}

.chat-document-preview-row .remove-thumbnail-btn {
    position: absolute;
    top: 5px;  /* Adjusted down */
    left: 0px; /* Positioned within the new left padding */
    background-color: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 2;
}

.chat-document-preview-row .remove-thumbnail-btn:hover {
    background-color: rgba(255, 0, 0, 0.7);
    cursor: pointer;
}

/* Chat document button */
.chat-document-button {
    position: absolute;
    right: 96px; /* Position it to the left of the image button */
    top: 50%;
    transform: translateY(-50%);
    border-radius: 0.25rem;
    padding: 6px;
    margin-top: -14px;
    width: 40px;
    height: 68px
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chat-document-button:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-50%) scale(1.05);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
}

.chat-document-button:active {
    transform: translateY(-50%) scale(0.95);
    background-color: rgba(255, 255, 255, 0.15);
}

.chat-document-button i {
    transition: transform 0.2s ease;
}

.chat-document-button:hover i {
    transform: scale(1.15);
    color: rgba(255, 255, 255, 0.95);
}

.chat-document-button:active i {
    transform: scale(0.9);
}

.chat-document-container {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

/* Styles for AI Chat Summaries Modal */
#summaryContent .context-entry.summary-present-bg {
    background-color: var(--bs-primary); /* Bootstrap primary color for the outer box IF summary is present */
}

#summaryContent .context-entry.summary-empty-bg {
    background-color: #2b3035; /* Dark grey for the outer box IF summary is NOT present (this will also be bg for summary-container in this case) */
}

#summaryContent .summary-title-styled {
    font-size: 1.1rem;
    color: #ffffff; 
}

#summaryContent .summary-content-styled {
    font-size: 1rem;
    color: #e0e0e0; 
}

#summaryContent .summary-text-styled {
    font-size: 1.1rem;
    color: #ffffff; 
}

/* This is the key part for the inner summary text box */
#summaryContent .summary-container {
    background-color: #2b3035; /* Always dark grey for the summary text's direct container */
    border-radius: 6px;
    padding: 1rem;
    margin-top: 0.5rem; /* As per the backup's inline style */
}

/* General .context-entry styles */
#summaryContent .context-entry {
    margin-bottom: 1rem; 
    padding: 1rem; /* Padding for the outer box that contains title/desc AND summary-container */     
    border-radius: 6px; 
    display: block;
    color: #ffffff; 
}

#summaryContent .context-entry:last-child {
    margin-bottom: 0;
}

/* === Styles for Extended Context Accordion in Chat Modal (Refined) === */

/* Outer container for each summary item in Extended Context */
#extendedContextAccordion .context-card {
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    /* Default background, will be overridden by .current-card or :not(.current-card) */
}

/* Title within the Extended Context item */
#extendedContextAccordion .context-card-title {
    font-weight: 500;
    color: white;
    margin-bottom: 0.75rem;
    font-size: 1rem; /* Matching implied size from screenshot */
}

/* The actual summary text container within an Extended Context item */
#extendedContextAccordion .context-card-summary {
    background-color: var(--bs-dark-bg-subtle, #212529); /* Fallback to a Bootstrap dark color */
    color: var(--bs-light-text-emphasis, #f8f9fa); /* Fallback to a light color */
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.9rem; /* Matching general context summary font */
    line-height: 1.5;
}

/* Current card in Extended Context - outer box is purple */
#extendedContextAccordion .context-card.current-card {
    background-color: var(--bs-primary, #6f42c1); /* Purple background */
}

/* Other cards in Extended Context - outer box is medium grey */
#extendedContextAccordion .context-card:not(.current-card) {
    background-color: var(--bs-gray-700, #495057); /* Medium-dark grey, adjust as needed */
}

/* === Updated rules for Extended Context using .context-entry === */
#extendedContextAccordion .context-entry,
#directExtendedContextContent .context-entry,
#directChatSummaryContent .context-entry {
    border-radius: 8px;
    /* Reduce top padding for better vertical centering of the title */
    padding: 0.5rem 1rem 1rem; /* top | left/right | bottom */
    margin-bottom: 0.75rem;
    background-color: var(--bs-gray-700, #495057);
}

#extendedContextAccordion .context-entry.current-card,
#directExtendedContextContent .context-entry.current-card,
#directChatSummaryContent .context-entry.current-card {
    background-color: var(--bs-primary, #6f42c1);
}

#extendedContextAccordion .context-entry strong,
#directExtendedContextContent .context-entry strong,
#directChatSummaryContent .context-entry strong {
    font-weight: 600;
    color: white;
    display: block;
    /* Move the title upward for better vertical centering */
    margin: 0 0 0.5rem; /* top | horizontal | bottom */
}

#extendedContextAccordion .context-entry-summary,
#directExtendedContextContent .context-entry-summary,
#directChatSummaryContent .context-entry-summary {
    /* Swapped colors: lighter text on a slightly darker background */
    background-color: #1e1e23; /* Darker grey for better contrast */
    color: rgba(255, 255, 255, 0.92); /* Nearly white text */
    padding: 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.5;
}

#extendedContextAccordion .context-entry:last-child,
#directExtendedContextContent .context-entry:last-child,
#directChatSummaryContent .context-entry:last-child {
    margin-bottom: 0;
}

/* Chat Summary Styles */
.summary-present-bg {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    transition: background-color 0.2s ease;
}

.summary-present-bg:hover {
    background: rgba(255, 255, 255, 0.08);
}

.summary-empty-bg {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.summary-title-styled {
    color: var(--bs-light);
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.summary-content-styled {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    line-height: 1.4;
}

.summary-text-styled {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.95rem;
    line-height: 1.5;
}

.context-entry-summary {
    margin-top: 0.5rem;
}

.context-entry-summary p {
    margin-bottom: 0.75rem;
}

.context-entry-summary p:last-child {
    margin-bottom: 0;
}

/* Loading Animation */
.gradient-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(
        90deg, 
        transparent 0%, 
        var(--bs-primary) 50%, 
        transparent 100%
    );
    background-size: 200% 100%;
    opacity: 0.8;
    box-shadow: 0 0 8px rgba(var(--bs-primary-rgb), 0.3);
    z-index: 1000;
    animation: moveGradient 1.5s ease-in-out infinite alternate;
}

@keyframes moveGradient {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spin {
    display: inline-block;
    animation: spin 1s linear infinite;
}

/* Empty State Styling */
.summary-empty {
    border: 1px dashed rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
}

.summary-empty .fas {
    font-size: 2rem;
    opacity: 0.3;
}

.summary-empty p {
    margin-bottom: 0.5rem;
}

.summary-empty .fs-small {
    font-size: 0.875rem;
}

/* -- Chat Summary Tab Overrides -- */
#directChatSummaryContent .summary-present-bg {
    background-color: var(--bs-primary) !important;
}

#directChatSummaryContent .summary-present-bg:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.9) !important;
}

/* Ensure text remains readable */
#directChatSummaryContent .summary-present-bg .summary-container {
    background-color: rgba(0, 0, 0, 0.6);
}

/* Message action buttons container */
.chat-message-actions {
    position: absolute;
    bottom: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

/* Copy button styles for chat messages */
.chat-message-copy-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Print button styles for chat messages */
.chat-message-print-btn {
    background-color: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-message:hover .chat-message-actions {
    opacity: 1;
}

.chat-message-copy-btn:hover,
.chat-message-print-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.chat-message-copy-btn:active,
.chat-message-print-btn:active {
    transform: scale(0.95);
}

.chat-message-copy-btn.copied {
    background-color: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border-color: #28a745;
}

.chat-message-print-btn.printing {
    background-color: rgba(23, 162, 184, 0.2);
    color: #17a2b8;
    border-color: #17a2b8;
}

.chat-message-copy-btn i,
.chat-message-print-btn i {
    font-size: 0.875rem;
}

.chat-message-copy-btn .copy-text,
.chat-message-print-btn .print-text {
    font-size: 0.75rem;
    margin-left: 2px;
}

/* Hide print buttons on mobile phones */
@media screen and (max-width: 576px) {
    /* Hide message-level print buttons */
    .chat-message-print-btn {
        display: none !important;
    }
    
    /* Hide chat-level print button */
    #printChatBtn {
        display: none !important;
    }
    
    /* Adjust the actions container gap since only copy button will be visible */
    .chat-message-actions {
        gap: 0;
    }
}

/* Chat-level print button styling */
#printChatBtn {
    color: rgba(255, 255, 255, 0.7);
    border-color: rgba(255, 255, 255, 0.3);
}

#printChatBtn:hover {
    color: rgba(255, 255, 255, 0.9);
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.4);
}

#printChatBtn:active {
    color: rgba(255, 255, 255, 0.95);
    background-color: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

#printChatBtn:disabled {
    color: rgba(255, 255, 255, 0.5);
    border-color: rgba(255, 255, 255, 0.2);
    opacity: 0.6;
}

/* Load more button styles */
.load-more-btn {
    display: block;
    width: 100%;
    padding: 10px 20px;
    margin: 10px 0;
    background-color: rgba(248, 249, 250, 0.1);
    color: var(--bs-light);
    border: 1px solid rgba(248, 249, 250, 0.3);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.load-more-btn:hover {
    background-color: rgba(248, 249, 250, 0.2);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(248, 249, 250, 0.2);
    color: var(--bs-light);
}

.load-more-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.load-more-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: rgba(248, 249, 250, 0.05);
}

.load-more-btn .spinner-border {
    width: 1rem;
    height: 1rem;
    margin-right: 5px;
    vertical-align: middle;
}

/* Loading gradient animation for load more button */
@keyframes loadingGradient {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 100% 0;
    }
}

