<?php
/**
 * Single Forum - Style 3: Compact List (No Thumbnail).
 *
 * Displays topics in a minimal list without cover image.
 * Uses $settings, $forum_id, $topics, $unique_id.
 *
 * @package bbp-core
 */
?>
<div class="bbpc-sf-list">
    <div class="bbpc-sf-list-header">
        <h4 class="bbpc-sf-list-forum-title">
            <a href="<?php the_permalink( $forum_id ); ?>">
                <?php echo esc_html( get_the_title( $forum_id ) ); ?>
            </a>
        </h4>
        <?php if ( ! empty( $settings['show_cover_badges'] ) ) : ?>
            <div class="bbpc-sf-list-counts">
                <span class="bbpc-sf-list-badge">
                    <?php echo esc_html( bbp_get_forum_topic_count( $forum_id ) ); ?>
                    <?php esc_html_e( 'Topics', 'forumax' ); ?>
                </span>
                <span class="bbpc-sf-list-badge">
                    <?php echo esc_html( bbp_get_forum_reply_count( $forum_id ) ); ?>
                    <?php esc_html_e( 'Replies', 'forumax' ); ?>
                </span>
            </div>
        <?php endif; ?>
    </div>

    <?php if ( ! empty( $settings['show_excerpt'] ) ) : ?>
        <p class="bbpc-sf-list-forum-desc">
            <?php echo wp_kses_post( wp_trim_words( get_the_content( null, false, $forum_id ), $settings['word_length'] ) ); ?>
        </p>
    <?php endif; ?>

    <?php
    if ( $topics->have_posts() ) :
        while ( $topics->have_posts() ) :
            $topics->the_post();
            $topic_id = get_the_ID();
            ?>
            <div class="bbpc-sf-list-item">
                <div class="bbpc-sf-list-title">
                    <a href="<?php the_permalink(); ?>">
                        <?php the_title(); ?>
                    </a>
                </div>
                <?php if ( ! empty( $settings['show_excerpt'] ) ) : ?>
                    <p class="bbpc-sf-list-excerpt">
                        <?php echo wp_kses_post( wp_trim_words( get_the_content(), 20 ) ); ?>
                    </p>
                <?php endif; ?>
                <div class="bbpc-sf-list-meta">
                    <?php if ( ! empty( $settings['show_voice'] ) ) : ?>
                        <span class="bbpc-sf-list-meta-voice">
                            <?php echo esc_html( bbp_get_topic_voice_count( $topic_id ) ); ?>
                            <?php esc_html_e( 'Voices', 'forumax' ); ?>
                        </span>
                    <?php endif; ?>
                    <?php if ( ! empty( $settings['show_replies'] ) ) : ?>
                        <span class="bbpc-sf-list-meta-replies">
                            <?php bbp_topic_reply_count( $topic_id ); ?>
                            <?php esc_html_e( 'Replies', 'forumax' ); ?>
                        </span>
                    <?php endif; ?>
                    <?php if ( ! empty( $settings['show_freshness'] ) ) : ?>
                        <span class="bbpc-sf-list-meta-time">
                            <?php bbp_topic_last_active_time( $topic_id ); ?>
                        </span>
                    <?php endif; ?>
                </div>
            </div>
            <?php
        endwhile;
        wp_reset_postdata();
    else :
        ?>
        <div class="bbpc-sf-list-item">
            <p class="mb-0"><?php esc_html_e( 'No topics found.', 'forumax' ); ?></p>
        </div>
    <?php endif; ?>

    <?php if ( ! empty( $settings['show_view_all'] ) ) : ?>
        <div class="bbpc-sf-list-footer">
            <a href="<?php the_permalink( $forum_id ); ?>" class="bbpc-sf-list-view-all">
                <?php echo esc_html( $settings['read_more'] ); ?> &rarr;
            </a>
        </div>
    <?php endif; ?>
</div>
