<?php
/**
 * Frontend widget template for Ask Any chat interface
 *
 * This template displays the chat widget interface with support for:
 * - Chat functionality
 * - Contact form integration
 * - Suggested prompts
 * - Emoji picker
 * - Responsive design
 *
 * @package Askany
 * @since 1.0.0
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

// Check pro status
$plugin = \Askany\Plugin::get_instance();
$is_pro = $plugin->is_pro_active();

$contact_form_enabled = isset($settings['contact_form_enabled']) ? $settings['contact_form_enabled'] : false;
$contact_form_shortcode = isset($settings['contact_form_shortcode']) ? $settings['contact_form_shortcode'] : 'light';
?>

<div class="askany-chat-widget <?php echo esc_attr( $atts['position'] ); ?> <?php echo esc_attr( 'theme-' . $theme ); ?>" data-position="<?php echo esc_attr( $atts['position'] ); ?>" data-api-provider="<?php echo esc_attr($settings['api_provider']); ?>" data-fallback-enabled="<?php echo esc_attr($settings['fallback_enabled'] ? 'true' : 'false'); ?>">
	<?php if ( 'inline' !== $atts['position'] ) : ?>
		<div class="askany-chat-toggle">
			<div class="toggle-icon-container">
				<span class="askany-chat-icon">
					
					<?php if ( ! empty($settings['assistant_avatar']) ) : ?>
						<img src="<?php echo esc_url($settings['assistant_avatar']); ?>" alt="<?php esc_attr_e('Assistant Avatar', 'askany'); ?>" />
					<?php else : ?>
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
							<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
						</svg>
					<?php endif; ?>

				</span>
				<span class="notification-badge"><?php esc_html_e( '1', 'askany' ); ?></span>
			</div>
		</div>
	<?php endif; ?>
	
	<div class="askany-chat-container" 
	<?php
	if ( 'inline' !== $atts['position'] ) {
		echo 'style="display: none;"'; }
	?>
	>
		<div class="askany-chat-header">
			<div class="header-left">
				<div class="assistant-avatar">

					<?php if ( ! empty($settings['home_logo']) ) : ?>
						<img src="<?php echo esc_url($settings['home_logo']); ?>" alt="<?php esc_attr_e('Assistant Avatar', 'askany'); ?>" />
					<?php else : ?>
						<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
							<circle cx="12" cy="12" r="10"></circle>
							<path d="M8 14s1.5 2 4 2 4-2 4-2"></path>
							<line x1="9" y1="9" x2="9.01" y2="9"></line>
							<line x1="15" y1="9" x2="15.01" y2="9"></line>
						</svg>
					<?php endif; ?>

				</div>
				<div class="header-info">
					<h3><?php echo esc_html( $header_text ); ?></h3>
					<span class="status-indicator"><?php esc_html_e( 'Online', 'askany' ); ?></span>
				</div>
			</div>
			<div class="header-actions">
				
				<?php if ( 'inline' !== $atts['position'] ) : ?>
					<button class="action-btn minimize-btn" title="<?php esc_attr_e('Minimize', 'askany'); ?>">
						<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
							<line x1="5" y1="12" x2="19" y2="12"></line>
						</svg>
					</button>
					<button class="action-btn expand-btn" title="<?php esc_attr_e('Expand', 'askany'); ?>">
						<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
							<path d="M15 3h6v6"></path>
							<path d="M9 21H3v-6"></path>
							<path d="M21 3l-7 7"></path>
							<path d="M3 21l7-7"></path>
						</svg>
					</button>
					<button class="action-btn askany-chat-close" title="<?php esc_attr_e('Close', 'askany'); ?>">
						<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
							<line x1="18" y1="6" x2="6" y2="18"></line>
							<line x1="6" y1="6" x2="18" y2="18"></line>
						</svg>
					</button>
				<?php endif; ?>
			</div>
		</div>

		<!-- Content Area Container -->
		<div class="askany-content-wrapper">

		<?php if ( ! empty($settings['get_started_enabled']) ) : ?>
		<!-- Get Started Page -->
		<div class="askany-get-started-page" style="display: block;">
			<div class="get-started-content">
				<div class="get-started-header">
					<?php if ( ! empty($settings['home_logo']) ) : ?>
						<img src="<?php echo esc_url($settings['home_logo']); ?>" alt="<?php esc_attr_e('Logo', 'askany'); ?>" class="get-started-logo" />
					<?php endif; ?>
					<h2><?php echo esc_html( $settings['get_started_title'] ?? __( 'Welcome! Let\'s Get Started', 'askany' ) ); ?></h2>
					<p><?php echo esc_html( $settings['get_started_description'] ?? __( 'Please provide your name and email to start chatting with us.', 'askany' ) ); ?></p>
				</div>
				
				<form id="askany-get-started-form" class="get-started-form">
					<div class="form-group">
						<label for="get-started-name">
							<?php echo esc_html( $settings['get_started_name_label'] ?? __( 'Your Name', 'askany' ) ); ?>
							<?php if ( ! empty($settings['get_started_name_required']) ) : ?>
								<span class="required">*</span>
							<?php endif; ?>
						</label>
						<input 
							type="text" 
							id="get-started-name" 
							name="name" 
							<?php echo ! empty($settings['get_started_name_required']) ? 'required' : ''; ?>
							placeholder="<?php echo esc_attr( $settings['get_started_name_label'] ?? __( 'Your Name', 'askany' ) ); ?>"
						/>
					</div>
					
					<div class="form-group">
						<label for="get-started-email">
							<?php echo esc_html( $settings['get_started_email_label'] ?? __( 'Your Email', 'askany' ) ); ?>
							<?php if ( ! empty($settings['get_started_email_required']) ) : ?>
								<span class="required">*</span>
							<?php endif; ?>
						</label>
						<input 
							type="email" 
							id="get-started-email" 
							name="email" 
							<?php echo ! empty($settings['get_started_email_required']) ? 'required' : ''; ?>
							placeholder="<?php echo esc_attr( $settings['get_started_email_label'] ?? __( 'Your Email', 'askany' ) ); ?>"
						/>
					</div>
					
					<button type="submit" class="get-started-submit-btn">
						<?php echo esc_html( $settings['get_started_button_text'] ?? __( 'Start Chat', 'askany' ) ); ?>
					</button>
				</form>
			</div>
		</div>
		<?php endif; ?>

		<?php if ( ! empty($settings['home_page_enabled']) ) : ?>
		<!-- Home Tab Content (only show if home page is enabled) -->
		<div class="askany-main-tab-content" id="home-tab" style="display: <?php echo ! empty($settings['get_started_enabled']) ? 'none' : 'block'; ?>;">
			<div class="askany-home-content">
				<!-- Logo Section -->
				<!-- <div class="home-logo-section">
					<?php if ( ! empty($settings['home_logo']) ) : ?>
						<img src="<?php echo esc_url($settings['home_logo']); ?>" alt="<?php esc_attr_e('Logo', 'askany'); ?>" class="home-logo" />
					<?php endif; ?>
				</div> -->

				<!-- Agents Section -->
				<?php if ( ! empty($settings['show_agents']) && ! empty($agents) ) : ?>
				<div class="home-agents-section">
					<div class="agents-avatars">
						<?php foreach ( $agents as $agent ) { ?>
							<div class="agent-avatar">
								<?php echo get_avatar( $agent->user_email, 40 ); ?>
							</div>
						<?php } ?>
					</div>
				</div>
				<?php endif; ?>

				<!-- Welcome Message -->
				<div class="home-welcome-section">
					<h2 class="welcome-title">
						<?php 
						if ( is_user_logged_in() ) {
							$current_user = wp_get_current_user();
							$display_name = $current_user->display_name ?: $current_user->user_login;
							printf( 
								/* translators: %s: User's display name */
								esc_html__( 'Hi %s', 'askany' ), 
								'<span class="user-name">' . esc_html( $display_name ) . '</span>'
							);
						} else {
							esc_html_e( 'Hi', 'askany' );
						}
						?> 
						<span class="wave-emoji">👋</span>
					</h2>
					<p class="welcome-subtitle">
						<?php echo esc_html( $settings['home_welcome_message'] ?? __( 'How may we help you today?', 'askany' ) ); ?>
					</p>
				</div>

				<!-- Quick Actions -->
				<div class="home-actions-section">
					<!-- Documentation Link -->
					<?php if ( ! empty($settings['show_documentation']) && ! empty($settings['documentation_url']) ) : ?>
					<div class="home-action-item">
						<a href="<?php echo esc_url($settings['documentation_url']); ?>" target="_blank" class="action-link">
							<div class="action-icon">
								<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
									<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
									<polyline points="14,2 14,8 20,8"></polyline>
									<line x1="16" y1="13" x2="8" y2="13"></line>
									<line x1="16" y1="17" x2="8" y2="17"></line>
									<polyline points="10,9 9,9 8,9"></polyline>
								</svg>
							</div>
							<div class="action-content">
								<div class="action-title"><?php esc_html_e( 'Visit our Documentation', 'askany' ); ?></div>
								<div class="action-subtitle"><?php echo esc_html( $settings['documentation_description'] ?? __( 'Find detailed guides and tutorials', 'askany' ) ); ?></div>
							</div>
						</a>
					</div>
					<?php endif; ?>

					<!-- Report Issue -->
					<?php if ( $is_pro && ! empty($settings['report_issue_enabled']) ) : ?>
					<div class="home-action-item">
						<button class="action-link report-issue-btn" data-action-type="report_issue">
							<div class="action-icon">
								<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
									<circle cx="12" cy="12" r="10"></circle>
									<line x1="12" y1="8" x2="12" y2="12"></line>
									<line x1="12" y1="16" x2="12.01" y2="16"></line>
								</svg>
							</div>
							<div class="action-content">
								<div class="action-title"><?php echo esc_html( $settings['report_issue_title'] ?? __( 'Report an issue?', 'askany' ) ); ?></div>
								<div class="action-subtitle"><?php echo esc_html( $settings['report_issue_description'] ?? __( 'Found a bug? Let us know.', 'askany' ) ); ?></div>
							</div>
						</button>
					</div>
					<?php endif; ?>

					<!-- Feature Request -->
					<?php if ( $is_pro && ! empty($settings['feature_request_enabled']) ) : ?>
					<div class="home-action-item">
						<button class="action-link feature-request-btn" data-action-type="feature_request">
							<div class="action-icon">
								<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
									<path d="M12 20h9"></path>
									<path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path>
								</svg>
							</div>
							<div class="action-content">
								<div class="action-title"><?php echo esc_html( $settings['feature_request_title'] ?? __( 'Request a feature', 'askany' ) ); ?></div>
								<div class="action-subtitle"><?php echo esc_html( $settings['feature_request_description'] ?? __( 'What would you like to see next?', 'askany' ) ); ?></div>
							</div>
						</button>
					</div>
					<?php endif; ?>

					<!-- FAQ Section -->
					<?php if ( ! empty($settings['show_faq']) && ! empty($faqs) ) : ?>
					<div class="home-faq-section">
						<h3 class="faq-title"><?php esc_html_e( 'Frequently Asked Questions', 'askany' ); ?></h3>
						<div class="faq-list">
							<?php foreach ( $faqs as $faq ) { ?>
							<div class="faq-item">
								<button class="faq-question" data-faq-id="<?php echo esc_attr($faq->id); ?>">
									<span><?php echo esc_html($faq->question); ?></span>
									<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
										<polyline points="6,9 12,15 18,9"></polyline>
									</svg>
								</button>
								<div class="faq-answer askany-faq-markdown" style="display: none;">
									<?php echo wp_kses_post($faq->answer); ?>
								</div>
							</div>
							<?php } ?>
						</div>
					</div>
					<?php endif; ?>

					<!-- Custom Links -->
					<?php if ( ! empty($settings['show_custom_links']) && ! empty($custom_links) ) : ?>
						<?php foreach ( $custom_links as $link ) { ?>
					<div class="home-action-item">
						<a href="<?php echo esc_url($link->url); ?>" target="_blank" class="action-link">
							<div class="action-icon">
								<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
									<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path>
									<path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path>
								</svg>
							</div>
							<div class="action-content">
								<div class="action-title"><?php echo esc_html($link->title); ?></div>
								<div class="action-subtitle"><?php echo esc_html($link->description); ?></div>
							</div>
						</a>
					</div>
					<?php } ?>
					<?php endif; ?>
				</div>
			</div>
		</div>
		<?php endif; ?>

		<!-- Messages Tab Content -->
		<?php 
		// Show Messages as a main tab if home page is enabled OR news is enabled
		$show_as_main_tab = ! empty($settings['home_page_enabled']) || ( $is_pro && ! empty($settings['news_enabled']) );
		if ( $show_as_main_tab ) : 
		?>
		<div class="askany-main-tab-content" id="messages-tab" style="display: <?php echo empty($settings['home_page_enabled']) ? 'flex' : 'none'; ?>; flex-direction: column;">
		<?php else : ?>
		<!-- Direct Chat Content (when home page and news are both disabled) -->
		<div class="askany-direct-chat-content" style="display: <?php echo ! empty($settings['get_started_enabled']) ? 'none' : 'flex'; ?>; flex-direction: column; flex: 1;">
		<?php endif; ?>

			<!-- Sub-tabs for Messages section (or direct chat tabs when home disabled) -->
			<?php if ( $contact_form_enabled ) : ?>
			<div class="askany-chat-tabs">
				<button class="tab-btn active" data-tab="chat">
					<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 5px; flex-shrink: 0;">
					<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
					<line x1="9" y1="10" x2="15" y2="10"></line>
					<line x1="9" y1="14" x2="15" y2="14"></line>
					</svg>
					<span style="display: inline-block; line-height: 1;"><?php esc_html_e('Chat', 'askany'); ?></span>
				</button>
				<button class="tab-btn" data-tab="contact">
					<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="margin-right: 5px; flex-shrink: 0;">
					<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"></path>
					<circle cx="12" cy="7" r="4"></circle>
					</svg>
					<span style="display: inline-block; line-height: 1;"><?php esc_html_e('Contact', 'askany'); ?></span>
				</button>
			</div>
			<?php endif; ?>

			<!-- Chat Tab Content -->
			<div class="askany-chat-tab-content" id="chat-tab" style="display: block;">
				<div class="askany-chat-messages"></div>
				
				<div class="suggested-prompts">
					<div class="prompt-header">
						<div class="prompt-label"><?php esc_html_e( 'Suggested Questions:', 'askany' ); ?></div>
						<button class="close-prompts-btn" title="<?php esc_attr_e('Close suggestions', 'askany'); ?>">
							<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
								<line x1="18" y1="6" x2="6" y2="18"></line>
								<line x1="6" y1="6" x2="18" y2="18"></line>
							</svg>
						</button>
					</div>
					<div class="prompt-items">
						<button class="prompt-item"><?php esc_html_e( 'Hello can you help me?', 'askany' ); ?></button>
						<button class="prompt-item"><?php esc_html_e( 'What\'s your return policy?', 'askany' ); ?></button>
						<button class="prompt-item"><?php esc_html_e( 'Do you have any discount codes?', 'askany' ); ?></button>
					</div>
				</div>
				
				<div class="askany-chat-products"></div>
				
				<div class="askany-chat-input">
					<form id="askany-chat-form">
						<div class="input-container">
							<button type="button" class="attachment-btn">
								<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
									<path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"></path>
								</svg>
							</button>
							<button type="button" class="emoji-btn">
								<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
									<circle cx="12" cy="12" r="10"></circle>
									<path d="M8 14s1.5 2 4 2 4-2 4-2"></path>
									<line x1="9" y1="9" x2="9.01" y2="9"></line>
									<line x1="15" y1="9" x2="15.01" y2="9"></line>
								</svg>
							</button>
							<input id='fe-submit' type="text" placeholder="<?php echo esc_attr( $atts['placeholder'] ); ?>" required />

							<button type="submit" class="send-btn submit-btn">
								 <svg width="20" height="20" viewBox="0 0 384 512" fill="none" xmlns="http://www.w3.org/2000/svg">
									<path d="M214.6 41.4c-12.5-12.5-32.8-12.5-45.3 0l-160 160c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L160 141.2 160 448c0 17.7 14.3 32 32 32s32-14.3 32-32l0-306.7L329.4 246.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3l-160-160z" fill="currentColor"/>
								</svg>
							</button>
							
						</div>
						
					</form>
				</div>
				
				<div class="emoji-picker">
					<div class="emoji-group">
						<span class="emoji" data-emoji="😊">😊</span>
						<span class="emoji" data-emoji="👍">👍</span>
						<span class="emoji" data-emoji="❤️">❤️</span>
						<span class="emoji" data-emoji="🙏">🙏</span>
						<span class="emoji" data-emoji="😂">😂</span>
						<span class="emoji" data-emoji="🔥">🔥</span>
						<span class="emoji" data-emoji="✨">✨</span>
						<span class="emoji" data-emoji="🎉">🎉</span>
					</div>
				</div>
			</div>

			<!-- Contact Tab Content -->
			<?php if ( $contact_form_enabled ) : ?>
			<div class="askany-chat-tab-content" id="contact-tab" style="display: none;">
				<div class="askany-contact-form">
					<?php echo do_shortcode($contact_form_shortcode); ?>
				</div>
			</div>
			<?php endif; ?>
		</div>
		
		<?php if ( $is_pro && ! empty($settings['news_enabled']) ) : ?>
		<!-- News Tab Content -->
		<div class="askany-main-tab-content" id="news-tab" style="display: none;">
			<div class="askany-news-container">
				<!-- News List View -->
				<div class="askany-news-list" id="askany-news-list">
					<?php
					$news_handler = \Askany\Plugin::get_instance()->get_news_handler();
					$news_posts = $news_handler->get_news_posts();
					
					if ( ! empty( $news_posts ) ) :
						foreach ( $news_posts as $post ) :
					?>
					<div class="news-card" data-post-id="<?php echo esc_attr( $post['id'] ); ?>">
						<?php if ( ! empty( $post['image'] ) ) : ?>
						<div class="news-card-image-wrapper">
							<img class="news-card-image" src="<?php echo esc_url( $post['image'] ); ?>" 
								 alt="<?php echo esc_attr( $post['title'] ); ?>" loading="lazy">
						</div>
						<?php endif; ?>
						<div class="news-card-body">
							<h3 class="news-card-title">
								<?php echo esc_html( $post['title'] ); ?>
							</h3>
							<p class="news-card-excerpt">
								<?php echo esc_html( $post['excerpt'] ); ?>
							</p>
							<div class="news-card-footer">
								<span class="news-card-date">
									<?php echo esc_html( $post['date'] ); ?>
								</span>
								<span class="news-card-arrow">
									<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 512">
										<path d="M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z" fill="currentColor"/>
									</svg>
								</span>
							</div>
						</div>
					</div>
					<?php 
						endforeach;
					else :
					?>
					<div class="news-empty-state">
						<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
							<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
							<polyline points="14 2 14 8 20 8"></polyline>
							<line x1="16" y1="13" x2="8" y2="13"></line>
							<line x1="16" y1="17" x2="8" y2="17"></line>
							<polyline points="10 9 9 9 8 9"></polyline>
						</svg>
						<p><?php esc_html_e( 'No news available at the moment.', 'askany' ); ?></p>
					</div>
					<?php endif; ?>
				</div>
				
				<!-- Full Post View (hidden by default) -->
				<div class="askany-news-full" id="askany-news-full" style="display: none;">
					<!-- Content loaded via AJAX -->
				</div>
			</div>
		</div>
		<?php endif; ?>
		
		</div>
		<?php 
		// Show main tabs if home page is enabled OR news is enabled
		$show_main_tabs = ! empty($settings['home_page_enabled']) || ( $is_pro && ! empty($settings['news_enabled']) );
		if ( $show_main_tabs ) : 
		?>
		<div class="askany-main-tabs" style="display: <?php echo ! empty($settings['get_started_enabled']) ? 'none' : 'flex'; ?>;">
			<?php if ( ! empty($settings['home_page_enabled']) ) : ?>
			<button class="main-tab-btn active" data-tab="home">
				<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
					<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"></path>
					<polyline points="9,22 9,12 15,12 15,22"></polyline>
				</svg>
				<span><?php esc_html_e('Home', 'askany'); ?></span>
			</button>
			<?php endif; ?>
			<button class="main-tab-btn <?php echo empty($settings['home_page_enabled']) ? 'active' : ''; ?>" data-tab="messages">
				<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
					<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
				</svg>
				<span><?php esc_html_e('Messages', 'askany'); ?></span>
			</button>
			<?php if ( $is_pro && ! empty($settings['news_enabled']) ) : ?>
			<button class="main-tab-btn" data-tab="news">
				<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
					<path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
					<polyline points="14 2 14 8 20 8"></polyline>
					<line x1="16" y1="13" x2="8" y2="13"></line>
					<line x1="16" y1="17" x2="8" y2="17"></line>
					<polyline points="10 9 9 9 8 9"></polyline>
				</svg>
				<span><?php echo esc_html( $settings['news_label'] ?? __('News', 'askany') ); ?></span>
			</button>
			<?php endif; ?>
		</div>
		<?php endif; ?>
		
		<div class="chat-footer">
			<span class="powered-by"><?php esc_html_e( 'Powered by Ask Any', 'askany' ); ?></span>
		</div>
	</div>
</div>
