<?php
namespace admin\Blocks\Render;

use WP_Query;

class Forum_Tab {
	/**
	 * Render the Forum Tab block.
	 *
	 * Displays forums and topics in tabbed layout with full
	 * customization for layout, visibility, colors, typography,
	 * spacing, and responsive behavior.
	 *
	 * @param array  $attributes Block attributes.
	 * @param string $content    Block content.
	 *
	 * @return string Rendered block HTML.
	 */
	public function render_forum_tab( $attributes, $content ) {
			
		$settings          = $attributes;
		$forum_tab_title   = ! empty( $attributes['forum_tab_title'] ) ? $attributes['forum_tab_title'] : __( 'Show Forums', 'bbp-core' );
		$topics_tab_title  = ! empty( $attributes['topics_tab_title'] ) ? $attributes['topics_tab_title'] : __( 'Show Topics', 'bbp-core' );
		$ppp               = ! empty( $attributes['ppp'] ) ? absint( $attributes['ppp'] ) : 9;
		$ppp2              = ! empty( $attributes['ppp2'] ) ? absint( $attributes['ppp2'] ) : 6;
		$order             = ! empty( $attributes['order'] ) ? $attributes['order'] : 'ASC';
		$order2            = ! empty( $attributes['order2'] ) ? $attributes['order2'] : 'ASC';
		$orderby           = ! empty( $attributes['orderby'] ) ? $attributes['orderby'] : 'date';
		$orderby2          = ! empty( $attributes['orderby2'] ) ? $attributes['orderby2'] : 'date';
		$default_tab       = ! empty( $attributes['default_active_tab'] ) ? $attributes['default_active_tab'] : 'forum';
		$columns           = ! empty( $attributes['columns'] ) ? absint( $attributes['columns'] ) : 3;
		$forum_image_size  = ! empty( $attributes['forum_image_size'] ) ? $attributes['forum_image_size'] : 'thumbnail';
		$no_posts_message  = ! empty( $attributes['no_posts_message'] ) ? $attributes['no_posts_message'] : __( 'No posts found.', 'bbp-core' );
		$forum_filter_ids  = ! empty( $attributes['forum_filter_ids'] ) ? $attributes['forum_filter_ids'] : '';

		// Visibility toggles.
		$show_forum_image       = isset( $attributes['show_forum_image'] ) ? $attributes['show_forum_image'] : true;
		$show_forum_post_count  = isset( $attributes['show_forum_post_count'] ) ? $attributes['show_forum_post_count'] : true;
		$show_forum_reply_count = isset( $attributes['show_forum_reply_count'] ) ? $attributes['show_forum_reply_count'] : true;
		$show_forum_excerpt     = isset( $attributes['show_forum_excerpt'] ) ? $attributes['show_forum_excerpt'] : false;
		$show_topic_avatar      = isset( $attributes['show_topic_avatar'] ) ? $attributes['show_topic_avatar'] : true;
		$show_topic_post_info   = isset( $attributes['show_topic_post_info'] ) ? $attributes['show_topic_post_info'] : true;
		$show_topic_tags        = isset( $attributes['show_topic_tags'] ) ? $attributes['show_topic_tags'] : true;
		$show_topic_post_reach  = isset( $attributes['show_topic_post_reach'] ) ? $attributes['show_topic_post_reach'] : true;
		$enable_card_hover      = isset( $attributes['enable_card_hover'] ) ? $attributes['enable_card_hover'] : true;

		// Enforce free defaults when Pro is not active.
		$is_pro_active = function_exists( 'forumax_is_premium' ) && forumax_is_premium();
		if ( ! $is_pro_active ) {
			$default_tab            = 'forum';
			$columns                = 3;
			$show_forum_image       = true;
			$show_forum_post_count  = true;
			$show_forum_reply_count = true;
			$show_forum_excerpt     = false;
			$show_topic_avatar      = true;
			$show_topic_post_info   = true;
			$show_topic_tags        = true;
			$show_topic_post_reach  = true;
			$enable_card_hover      = true;
			$mobile_columns         = 1;
			$hide_forum_image_mobile = false;
			$hide_topic_reach_mobile = true;
		}

		
		$this_get_id = 'bbpcft-' . uniqid();

		
		$forum_args = array(
			'post_type'      => 'forum',
			'posts_per_page' => $ppp,
			'order'          => $order,
			'orderby'        => $orderby,
		);

		// Filter by specific forum IDs.
		if ( ! empty( $forum_filter_ids ) ) {
			$ids = array_map( 'absint', array_filter( explode( ',', $forum_filter_ids ) ) );
			if ( ! empty( $ids ) ) {
				$forum_args['post__in'] = $ids;
			}
		}

		$forums = new \WP_Query( $forum_args );

			
		$topic_args = array(
			'post_type'      => 'topic',
			'posts_per_page' => $ppp2,
			'order'          => $order2,
			'orderby'        => $orderby2,
		);

		// If filtering by forum IDs, only show topics from those forums.
		if ( ! empty( $forum_filter_ids ) ) {
			$ids = array_map( 'absint', array_filter( explode( ',', $forum_filter_ids ) ) );
			if ( ! empty( $ids ) ) {
				$topic_args['post_parent__in'] = $ids;
			}
		}

		$topics = new \WP_Query( $topic_args );

			
		if ( ! wp_style_is( 'bbpc-el-widgets', 'registered' ) ) {
			wp_register_style( 'bbpc-el-widgets', FORUMAX_STYLES . 'frontend/el-widgets.css' );
		}
		if ( ! wp_style_is( 'elegant-icon', 'registered' ) ) {
			wp_register_style( 'elegant-icon', FORUMAX_VEND . 'elegant-icon/style.css' );
		}
		if ( ! wp_script_is( 'bbpc_js', 'registered' ) ) {
			wp_register_script( 'bbpc_js', FORUMAX_FRONT_ASS . 'js/forumTab.js', array( 'jquery' ), FORUMAX_VERSION, true );
		}

		wp_enqueue_style( 'bbpc-el-widgets' );
		wp_enqueue_style( 'elegant-icon' );
		wp_enqueue_script( 'bbpc_js' );

			
		$forum_active = ( 'forum' === $default_tab ) ? ' active' : '';
		$topic_active = ( 'topic' === $default_tab ) ? ' active' : '';
		$forum_show   = ( 'forum' === $default_tab ) ? ' show active' : '';
		$topic_show   = ( 'topic' === $default_tab ) ? ' show active' : '';

		
		$hover_class = $enable_card_hover ? '' : ' bbpc-ft-no-hover';

		
		$arrow_svg = '<div class="arrow-cont">
			<svg width="13px" height="13px" class="first" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
				<path d="M0 0h48v48H0z" fill="none"></path>
				<polygon points="24,29.171 9.414,14.585 6.586,17.413 24,34.827 41.414,17.413 38.586,14.585"></polygon>
			</svg>
			<svg width="13px" height="13px" class="second" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
				<path d="M0 0h48v48H0z" fill="none"></path>
				<polygon points="24,29.171 9.414,14.585 6.586,17.413 24,34.827 41.414,17.413 38.586,14.585"></polygon>
			</svg>
		</div>';

		ob_start();
		?>
		<section class="community-area<?php echo esc_attr( $hover_class ); ?>" id="forumTab-<?php echo esc_attr( $this_get_id ); ?>">
			<ul class="nav nav-tabs tab-buttons" role="tablist">
				<li class="nav-item" role="presentation">
					<button class="nav-links<?php echo esc_attr( $forum_active ); ?> tab-button tab"
						onclick="forumTab(event, 'forumTab-<?php echo esc_attr( $this_get_id ); ?>', 'forum-<?php echo esc_attr( $this_get_id ); ?>')">
						<?php echo esc_html( $forum_tab_title ); ?>
					</button>
				</li>
				<li class="nav-item" role="presentation">
					<button class="nav-links<?php echo esc_attr( $topic_active ); ?> tab-button tab"
						onclick="forumTab(event, 'forumTab-<?php echo esc_attr( $this_get_id ); ?>', 'topics-<?php echo esc_attr( $this_get_id ); ?>')">
						<?php echo esc_html( $topics_tab_title ); ?>
					</button>
				</li>
			</ul>

			<?php // Forum Tab Content ?>
			<div id="forum-<?php echo esc_attr( $this_get_id ); ?>" class="tab-content<?php echo esc_attr( $forum_show ); ?>">
				<?php if ( $forums->have_posts() ) : ?>
					<div class="gy-4 bbpc-community-topic-widget-main-wrapper">
						<?php
						while ( $forums->have_posts() ) :
							$forums->the_post();
							$item_id = get_the_ID();
							?>
							<div class="bbpc-community-topic-widget-wrapper">
								<div class="community-topic-widget-box">
									<?php if ( $show_forum_image ) : ?>
										<?php the_post_thumbnail( $forum_image_size ); ?>
									<?php endif; ?>
									<div class="box-content">
										<h5>
											<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a>
										</h5>
										<?php if ( $show_forum_excerpt ) : ?>
											<p class="bbpc-ft-excerpt"><?php echo esc_html( wp_trim_words( get_the_excerpt(), 15, '...' ) ); ?></p>
										<?php endif; ?>
										<?php if ( $show_forum_post_count || $show_forum_reply_count ) : ?>
											<div class="bbpc-ft-meta">
												<?php if ( $show_forum_post_count ) : ?>
													<span><?php bbp_forum_topic_count( $item_id ); ?> <?php esc_html_e( 'Posts', 'bbp-core' ); ?></span>
												<?php endif; ?>
												<?php if ( $show_forum_post_count && $show_forum_reply_count ) : ?>
													<span class="vr-line">|</span>
												<?php endif; ?>
												<?php if ( $show_forum_reply_count ) : ?>
													<span><?php bbp_forum_reply_count( $item_id ); ?> <?php esc_html_e( 'Replies', 'bbp-core' ); ?></span>
												<?php endif; ?>
											</div>
										<?php endif; ?>
									</div>
								</div>
							</div>
						<?php endwhile; ?>
					</div>
				<?php else : ?>
					<div class="alert alert-warning"><?php echo esc_html( $no_posts_message ); ?></div>
				<?php endif; ?>
				<?php wp_reset_postdata(); ?>

				<?php if ( isset( $settings['is_forum_tab_btn'] ) && $settings['is_forum_tab_btn'] ) : ?>
					<?php $forum_btn_url = ! empty( $settings['more_url'] ) ? $settings['more_url'] : get_post_type_archive_link( 'forum' ); ?>
					<div class="frmx-text-center bbpc-show-more-btn-wrapper">
						<a href="<?php echo esc_url( $forum_btn_url ); ?>"
							class="dbl-arrow-upper show-more-btn show-more-round frmx-mt-70">
							<?php echo wp_kses_post( $arrow_svg ); ?>
							<?php echo esc_html( $settings['more_txt'] ?? '' ); ?>
						</a>
					</div>
				<?php endif; ?>
			</div>

			<?php // Topics Tab Content ?>
			<div id="topics-<?php echo esc_attr( $this_get_id ); ?>" class="tab-content<?php echo esc_attr( $topic_show ); ?>">
				<?php if ( $topics->have_posts() ) : ?>
					<?php
					$i = 0;
					while ( $topics->have_posts() ) :
						$topics->the_post();
						$topic_id   = $topics->posts[ $i ]->ID;
						$vote_count = get_post_meta( $topic_id, 'bbpv-votes', true );
						$forum_id   = bbp_get_topic_forum_id();
						?>
						<div class="single-forum-post-widget">
							<div class="post-content">
								<div class="post-title">
									<h6>
										<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo esc_html( get_the_title() ); ?></a>
									</h6>
								</div>
								<?php if ( $show_topic_post_info ) : ?>
									<div class="post-info">
										<?php if ( $show_topic_avatar ) : ?>
											<div class="author">
												<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/user-circle-alt.svg' ); ?>" alt="<?php esc_attr_e( 'User', 'bbp-core' ); ?>">
												<?php
												echo wp_kses_post( bbp_get_topic_author_link(
													array(
														'post_id' => $topic_id,
														'type'    => 'name',
													)
												) );
												?>
											</div>
										<?php endif; ?>
										<div class="post-time">
											<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/time-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Time', 'bbp-core' ); ?>">
											<?php bbp_forum_last_active_time( get_the_ID() ); ?>
										</div>
										<div class="post-category">
											<a href="<?php echo esc_url( get_the_permalink( $forum_id ) ); ?>">
												<?php echo get_the_post_thumbnail( $forum_id ); ?>
												<?php echo esc_html( get_the_title( $forum_id ) ); ?>
											</a>
										</div>
									</div>
								<?php endif; ?>
								<?php if ( $show_topic_tags ) : ?>
									<?php
									bbp_topic_tag_list(
										'',
										array(
											'before' => '<div class="post-tags">',
											'after'  => '</div>',
											'sep'    => '',
										)
									);
									?>
								<?php endif; ?>
							</div>
							<?php if ( $show_topic_post_reach ) : ?>
								<div class="post-reach">
									<div class="post-view">
										<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/eye-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Views', 'bbp-core' ); ?>">
										<?php
										if ( function_exists( 'forumax_topic_view_count' ) ) {
											forumax_topic_view_count( $topic_id );
										}
										esc_html_e( ' Views', 'bbp-core' );
										?>
									</div>
									<div class="post-like">
										<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/thumbs-up-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Likes', 'bbp-core' ); ?>">
										<?php echo esc_html( $vote_count ? $vote_count : '0' ); ?>
										<?php esc_html_e( ' Likes', 'bbp-core' ); ?>
									</div>
									<div class="post-comment">
										<img src="<?php echo esc_url( FORUMAX_IMG . 'forum_tab/chatbubbles-outline.svg' ); ?>" alt="<?php esc_attr_e( 'Replies', 'bbp-core' ); ?>">
										<?php bbp_topic_reply_count( $topic_id ); ?>
										<?php esc_html_e( ' Replies', 'bbp-core' ); ?>
									</div>
								</div>
							<?php endif; ?>
						</div>
						<?php
						$i++;
					endwhile;
					unset( $i );
				else :
					?>
					<div class="alert alert-warning"><?php echo esc_html( $no_posts_message ); ?></div>
				<?php endif; ?>
				<?php wp_reset_postdata(); ?>

				<?php if ( isset( $settings['is_topic_tab_btn'] ) && $settings['is_topic_tab_btn'] ) : ?>
					<?php $topic_btn_url = ! empty( $settings['more_url2'] ) ? $settings['more_url2'] : get_post_type_archive_link( 'topic' ); ?>
					<div class="frmx-text-center bbpc-show-more-btn-wrapper">
						<a href="<?php echo esc_url( $topic_btn_url ); ?>"
							class="dbl-arrow-upper show-more-btn show-more-round frmx-mt-70">
							<?php echo wp_kses_post( $arrow_svg ); ?>
							<?php echo esc_html( $settings['more_txt2'] ?? '' ); ?>
						</a>
					</div>
				<?php endif; ?>
			</div>
		</section>

		<?php
		// Dynamic inline styles
		$sanitize_css_color = function ( $color ) {
			$color = trim( (string) $color );
			if ( empty( $color ) ) {
				return '';
			}
			if ( preg_match( '/^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{6})$/', $color ) ) {
				return $color;
			}
			if ( preg_match( '/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*(0|1|0?\.\d+))?\s*\)$/', $color ) ) {
				return $color;
			}
			return '';
		};

		$uid = esc_attr( $this_get_id );

		// Color attributes.
		$forum_tab_title_color  = isset( $attributes['forum_tab_title_color'] ) ? $sanitize_css_color( $attributes['forum_tab_title_color'] ) : '';
		$topics_tab_title_color = isset( $attributes['topics_tab_title_color'] ) ? $sanitize_css_color( $attributes['topics_tab_title_color'] ) : '';
		$tab_active_color       = isset( $attributes['tab_active_color'] ) ? $sanitize_css_color( $attributes['tab_active_color'] ) : '';
		$forum_content_color    = isset( $attributes['forum_tab_content_color'] ) ? $sanitize_css_color( $attributes['forum_tab_content_color'] ) : '';
		$topics_content_color   = isset( $attributes['topics_tab_content_color'] ) ? $sanitize_css_color( $attributes['topics_tab_content_color'] ) : '';
		$title_hover_color      = isset( $attributes['title_hover_color'] ) ? $sanitize_css_color( $attributes['title_hover_color'] ) : '';
		$card_bg_color          = isset( $attributes['card_bg_color'] ) ? $sanitize_css_color( $attributes['card_bg_color'] ) : '';
		$btn_color              = isset( $attributes['btn_color'] ) ? $sanitize_css_color( $attributes['btn_color'] ) : '';
		$btn_bg_color           = isset( $attributes['btn_bg_color'] ) ? $sanitize_css_color( $attributes['btn_bg_color'] ) : '';

		// Numeric attributes.
		$tab_font_size       = ! empty( $attributes['tab_font_size'] ) ? absint( $attributes['tab_font_size'] ) : 0;
		$card_title_font_size = ! empty( $attributes['card_title_font_size'] ) ? absint( $attributes['card_title_font_size'] ) : 0;
		$meta_font_size      = ! empty( $attributes['meta_font_size'] ) ? absint( $attributes['meta_font_size'] ) : 0;
		$tab_padding         = ! empty( $attributes['tab_padding'] ) ? absint( $attributes['tab_padding'] ) : 0;
		$card_gap            = ! empty( $attributes['card_gap'] ) ? absint( $attributes['card_gap'] ) : 0;
		$section_padding     = ! empty( $attributes['section_padding'] ) ? absint( $attributes['section_padding'] ) : 0;
		$card_border_radius  = ! empty( $attributes['card_border_radius'] ) ? absint( $attributes['card_border_radius'] ) : 0;
		$btn_border_radius   = ! empty( $attributes['btn_border_radius'] ) ? absint( $attributes['btn_border_radius'] ) : 0;
		$mobile_columns      = ! empty( $attributes['mobile_columns'] ) ? absint( $attributes['mobile_columns'] ) : 1;

		// Responsive.
		$hide_forum_image_mobile = isset( $attributes['hide_forum_image_mobile'] ) ? $attributes['hide_forum_image_mobile'] : false;
		$hide_topic_reach_mobile = isset( $attributes['hide_topic_reach_mobile'] ) ? $attributes['hide_topic_reach_mobile'] : true;

		// Re-enforce responsive defaults for free users (these variables are re-assigned above from attributes).
		if ( ! $is_pro_active ) {
			$mobile_columns          = 1;
			$hide_forum_image_mobile = false;
			$hide_topic_reach_mobile = true;
		}
		?>
		<style>
			/* Layout: columns */
			#forumTab-<?php echo $uid; ?> .bbpc-community-topic-widget-main-wrapper {
				grid-template-columns: repeat(<?php echo esc_attr( $columns ); ?>, 1fr) !important;
			}

			<?php if ( $forum_tab_title_color ) : ?>
				#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item:first-child button {
					color: <?php echo esc_attr( $forum_tab_title_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $topics_tab_title_color ) : ?>
				#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item:nth-child(2) button {
					color: <?php echo esc_attr( $topics_tab_title_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $tab_active_color ) : ?>
				#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item button.active {
					border-bottom-color: <?php echo esc_attr( $tab_active_color ); ?> !important;
					color: <?php echo esc_attr( $tab_active_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $forum_content_color ) : ?>
				#forum-<?php echo $uid; ?> .community-topic-widget-box .box-content,
				#forum-<?php echo $uid; ?> .community-topic-widget-box .box-content a,
				#forum-<?php echo $uid; ?> .community-topic-widget-box .box-content span {
					color: <?php echo esc_attr( $forum_content_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $topics_content_color ) : ?>
				#topics-<?php echo $uid; ?> .single-forum-post-widget .post-content,
				#topics-<?php echo $uid; ?> .single-forum-post-widget .post-content a {
					color: <?php echo esc_attr( $topics_content_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $title_hover_color ) : ?>
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box h5:hover a,
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box h5 a:hover,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6:hover a,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6 a:hover,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget:hover .post-title h6 a {
					color: <?php echo esc_attr( $title_hover_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $card_bg_color ) : ?>
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget {
					background-color: <?php echo esc_attr( $card_bg_color ); ?> !important;
				}
			<?php endif; ?>

			<?php if ( $btn_color || $btn_bg_color ) : ?>
				#forumTab-<?php echo $uid; ?> .show-more-btn {
					<?php if ( $btn_color ) : ?>
						color: <?php echo esc_attr( $btn_color ); ?> !important;
					<?php endif; ?>
					<?php if ( $btn_bg_color ) : ?>
						background-color: <?php echo esc_attr( $btn_bg_color ); ?> !important;
					<?php endif; ?>
				}
			<?php endif; ?>

			<?php if ( $tab_font_size ) : ?>
				#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item button {
					font-size: <?php echo esc_attr( $tab_font_size ); ?>px !important;
				}
			<?php endif; ?>

			<?php if ( $card_title_font_size ) : ?>
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box h5,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-title h6 a {
					font-size: <?php echo esc_attr( $card_title_font_size ); ?>px !important;
				}
			<?php endif; ?>

			<?php if ( $meta_font_size ) : ?>
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box span,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-info > div {
					font-size: <?php echo esc_attr( $meta_font_size ); ?>px !important;
				}
			<?php endif; ?>

			<?php if ( $tab_padding ) : ?>
				#forumTab-<?php echo $uid; ?> .nav-tabs .nav-item button {
					padding: <?php echo esc_attr( $tab_padding ); ?>px 0 !important;
				}
			<?php endif; ?>

			<?php if ( $card_gap ) : ?>
				#forumTab-<?php echo $uid; ?> .bbpc-community-topic-widget-main-wrapper {
					grid-gap: <?php echo esc_attr( $card_gap ); ?>px !important;
				}
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget {
					margin-top: <?php echo esc_attr( $card_gap ); ?>px !important;
				}
			<?php endif; ?>

			<?php if ( $section_padding ) : ?>
				#forumTab-<?php echo $uid; ?> .tab-content {
					padding-top: <?php echo esc_attr( $section_padding ); ?>px !important;
				}
			<?php endif; ?>

			<?php if ( $card_border_radius ) : ?>
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget {
					border-radius: <?php echo esc_attr( $card_border_radius ); ?>px !important;
				}
			<?php endif; ?>

			<?php if ( $btn_border_radius ) : ?>
				#forumTab-<?php echo $uid; ?> .show-more-btn {
					border-radius: <?php echo esc_attr( $btn_border_radius ); ?>px !important;
				}
			<?php endif; ?>

			/* Disable hover animation */
			<?php if ( ! $enable_card_hover ) : ?>
				#forumTab-<?php echo $uid; ?> .community-topic-widget-box:hover,
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget:hover {
					transform: none !important;
					box-shadow: 0 1.6px 3.5px 0 rgba(51,77,114,.15), 0 0.5px 1px 0 rgba(51,77,114,.1) !important;
				}
				#forumTab-<?php echo $uid; ?> .single-forum-post-widget:hover .post-title h6 a {
					color: inherit !important;
				}
			<?php endif; ?>

			/* Responsive */
			@media (max-width: 768px) {
				#forumTab-<?php echo $uid; ?> .bbpc-community-topic-widget-main-wrapper {
					grid-template-columns: repeat(<?php echo esc_attr( $mobile_columns ); ?>, 1fr) !important;
				}
				<?php if ( $hide_forum_image_mobile ) : ?>
					#forumTab-<?php echo $uid; ?> .community-topic-widget-box img {
						display: none !important;
					}
				<?php endif; ?>
				<?php if ( $hide_topic_reach_mobile ) : ?>
					#forumTab-<?php echo $uid; ?> .single-forum-post-widget .post-reach {
						display: none !important;
					}
				<?php endif; ?>
			}
		</style>
		<?php
		return ob_get_clean();
	}
}