/* Common button styling for back to top and AI buttons */
#backToTopBtn, #askAIBtn {
    position: fixed;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    background: linear-gradient(to right, #28a745, #20c997);
    color: white;
    font-size: 20px;
}

#backToTopBtn {
    bottom: 80px; /* Increased to avoid covering footer */
    right: 20px;
    display: none; /* Hidden by default */
}

#askAIBtn {
    bottom: 80px; /* Increased to avoid covering footer */
    left: 20px;
}

#backToTopBtn:hover, #askAIBtn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(to right, #218838, #1a9c77);
}

/* AI Chat Container Styling */
#addEntityChatAI {
    position: fixed;
    bottom: 80px;
    width: 350px !important;
    max-width: 90vw;
    background-color: #f8f9fa !important;
    border-radius: 15px !important;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2) !important;
    border-left: 5px solid #28a745 !important;
    display: none;
    padding: 0 !important;
    transition: all 0.3s ease;
    z-index: 1010;
}

#addEntityChatAI .chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    background: linear-gradient(to right, rgba(40, 167, 69, 0.1), transparent);
    border-radius: 15px 15px 0 0;
}

#addEntityChatAI .chat-header h4 {
    margin: 0;
    color: #28a745;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
}

#addEntityChatAI .chat-header h4 i {
    margin-right: 10px;
}

.close-btn {
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 22px !important;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #dc3545;
}

/* Comment List Styling */
#commentChatAIList {
    max-height: 300px;
    overflow-y: auto;
    padding: 15px;
    background-color: white;
    border-radius: 0 0 15px 15px;
    scrollbar-width: thin;
    scrollbar-color: #28a745 #f0f0f0;
}

#commentChatAIList::-webkit-scrollbar {
    width: 6px;
}

#commentChatAIList::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 10px;
}

#commentChatAIList::-webkit-scrollbar-thumb {
    background: #28a745;
    border-radius: 10px;
}

#commentChatAIList::-webkit-scrollbar-thumb:hover {
    background: #218838;
}

.comment-box {
    border-left: 4px solid #28a745 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
    border-radius: 0 10px 10px 0 !important;
    transition: all 0.2s ease;
    margin-bottom: 15px !important;
}

.comment-box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12) !important;
    transform: translateY(-2px);
}

/* User icon styling */
.comment-box .user-icon {
    width: 36px;
    height: 36px;
    background-color: #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    flex-shrink: 0;
}

/* Comment text styling */
.comment-box p {
    margin: 8px 0;
    line-height: 1.5;
    color: #495057;
}

.comment-box strong {
    color: #212529;
    font-weight: 600;
    font-size: 1rem;
}

/* Context section styling */
.context {
    font-size: 0.9rem;
    color: #6c757d;
    padding-top: 8px;
    font-style: italic;
    background-color: rgba(40, 167, 69, 0.05);
    padding: 10px;
    border-radius: 5px;
    margin-top: 10px !important;
}

/* Feedback buttons styling */
#feedback-div {
    margin-top: 10px;
    display: flex;
    gap: 10px;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border-radius: 0.25rem;
}

/* AI info text styling */
.ai-info-text {
    font-size: 0.7rem !important;
    color: #9ca3af !important;
    opacity: 0.7;
    line-height: 1.2;
    margin-bottom: 8px !important;
    font-style: italic;
}

/* Comment input area styling */
.chat-input-container {
    padding: 15px;
    background-color: #f8f9fa;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0 0 15px 10px;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
}

#commentTextChatAI {
    border: 1px solid #ced4da;
    border-radius: 20px;
    padding: 10px 15px;
    resize: none;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    font-size: 14px;
}

#commentTextChatAI:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
    outline: none;
}

.chat-btn {
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    transition: all 0.3s ease;
}

.chat-btn.send {
    background: linear-gradient(to right, #28a745, #20c997);
    border: none;
    color: white;
}

.chat-btn.send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.chat-btn.reset {
    border: 1px solid #28a745;
    color: #28a745;
    background-color: white;
}

.chat-btn.reset:hover {
    background-color: #f8f9fa;
}

.chat-btn i {
    font-size: 16px;
}

/* AI response styling */
.ai-response {
    background-color: #f0f7f2;
    border-left: 4px solid #28a745 !important;
}

.user-message {
    background-color: #f8f9fa;
    border-left: 4px solid #6c757d !important;
}

/* Empty chat message */
.empty-chat-message {
    text-align: center;
    padding: 30px 15px;
    color: #6c757d;
    font-style: italic;
}

/* Retry button styling */
#retryBtn {
    margin-left: auto;
    margin-right: auto;
    border-radius: 20px;
    padding: 8px 20px;
    transition: all 0.3s ease;
}

#retryBtn:hover {
    background-color: #28a745;
    color: white;
    transform: scale(1.05);
}

@media (max-width: 768px) {
    #backToTopBtn, #askAIBtn {
        width: 40px; /* Smaller buttons on mobile */
        height: 40px; /* Smaller buttons on mobile */
        font-size: 16px; /* Smaller icons */
    }
    
    #askAIBtn {
        left: 10px; /* Adjust position on mobile */
    }
    
    #backToTopBtn {
        right: 10px; /* Adjust position on mobile */
    }

    #addEntityChatAI {
        width: calc(100% - 20px) !important; /* Use almost full width */
        left: 10px; /* Ensure chat is not off-screen */
        right: 10px; /* Ensure balanced margins */
		top: auto; /* Reset top position */
        max-height: 80vh; /* Avoid taking too much vertical space */
        bottom: 120px; /* Position higher to avoid footer */
        transform: none; /* Remove any transforms that might affect positioning */
    }
    
    .chat-input-wrapper {
        flex-direction: row !important; /* Keep inputs and buttons in one row */
        flex-wrap: wrap; /* Allow wrapping if needed */
    }
    
    #commentTextChatAI {
        flex: 1 1 100%; /* Take full width for input */
        margin-bottom: 10px; /* Add space before buttons */
    }
    
    .chat-btn-group {
        justify-content: space-between;
        width: 100%;
    }
}