<?php

namespace MovieEngine\Admin\Player\Tabs;

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

class SeriesTab {

    public static function render($options) {
        if (has_action('movie_engine_render_pro_series')) {
            do_action('movie_engine_render_pro_series', $options);
            return;
        }
?>
        <input type="hidden" name="movie_engine_player_settings[active_sub_tab]" value="player_series">
        <div class="movie-engine-card">
            <div class="movie-engine-card-header">
                <h3><span class="fa-solid fa-list"></span> <?php esc_html_e('Episode Navigation', 'cine-movie-engine'); ?></h3>
            </div>
            <div class="movie-engine-card-body">
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[autoplay_next]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[autoplay_next]" value="1" <?php checked($options['movie_engine_autoplay_next'] ?? ($options['autoplay_next'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Enable Autoplay Next Episode', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label for="next_ep_countdown"><?php esc_html_e('Countdown Time for Next Episode (seconds)', 'cine-movie-engine'); ?></label>
                    <input type="number" id="next_ep_countdown" name="movie_engine_player_settings[next_ep_countdown]" value="<?php echo esc_attr($options['movie_engine_next_ep_countdown'] ?? ($options['next_ep_countdown'] ?? 10)); ?>" class="movie-engine-input" min="0">
                    <small class="movie-engine-help-text"><?php esc_html_e('Time to wait before auto-redirecting to next episode', 'cine-movie-engine'); ?></small>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[show_next_ep_card]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[show_next_ep_card]" value="1" <?php checked($options['movie_engine_show_next_ep_card'] ?? ($options['show_next_ep_card'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Show Next Episode Card', 'cine-movie-engine'); ?></span>
                    </label>
                    <small class="movie-engine-help-text"><?php esc_html_e('Display next episode card overlay on player', 'cine-movie-engine'); ?></small>
                </div>
                <div class="movie-engine-form-group">
                    <label for="next_ep_card_time"><?php esc_html_e('Show Next Episode Card (seconds before end)', 'cine-movie-engine'); ?></label>
                    <input type="number" id="next_ep_card_time" name="movie_engine_player_settings[next_ep_card_time]" value="<?php echo esc_attr($options['movie_engine_next_ep_card_time'] ?? ($options['next_ep_card_time'] ?? 10)); ?>" class="movie-engine-input" min="0">
                    <small class="movie-engine-help-text"><?php esc_html_e('When to show the next episode card before video ends', 'cine-movie-engine'); ?></small>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[show_nav_below_player]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[show_nav_below_player]" value="1" <?php checked($options['movie_engine_show_nav_below_player'] ?? ($options['show_nav_below_player'] ?? 0), 1); ?>>
                        <span><?php esc_html_e('Show Episode Navigation Below Player', 'cine-movie-engine'); ?></span>
                    </label>
                    <small class="movie-engine-help-text"><?php esc_html_e('Display Previous/Next buttons below the video player', 'cine-movie-engine'); ?></small>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[ep_title_overlay]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[ep_title_overlay]" value="1" <?php checked($options['movie_engine_ep_title_overlay'] ?? ($options['ep_title_overlay'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Show Episode Title Overlay', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[auto_mark_watched]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[auto_mark_watched]" value="1" <?php checked($options['movie_engine_auto_mark_watched'] ?? ($options['auto_mark_watched'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Auto Mark Episode as Watched', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[prev_ep_btn]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[prev_ep_btn]" value="1" <?php checked($options['movie_engine_prev_ep_btn'] ?? ($options['prev_ep_btn'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Enable Previous Episode Button', 'cine-movie-engine'); ?></span>
                    </label>
                </div>
                <div class="movie-engine-form-group">
                    <label class="movie-engine-checkbox-label">
                        <input type="hidden" name="movie_engine_player_settings[show_playlist_btn]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[show_playlist_btn]" value="1" <?php checked($options['movie_engine_show_playlist_btn'] ?? ($options['show_playlist_btn'] ?? 1), 1); ?>>
                        <span><?php esc_html_e('Show Playlist Button (Episodes List)', 'cine-movie-engine'); ?></span>
                    </label>
                    <p class="movie-engine-field-description">
                        <?php esc_html_e('Display a playlist button in player controls that shows all seasons and episodes in an overlay.', 'cine-movie-engine'); ?>
                    </p>
                </div>

                <hr class="me-hr">
                <div class="me-pro-notice-box">
                    <span class="dashicons dashicons-lock"></span>
                    <div class="me-pro-notice-message">
                        <strong><?php esc_html_e('Skip Intro & Recap', 'cine-movie-engine'); ?></strong>
                        <p><?php esc_html_e('This is a PRO feature. Upgrade to enable automatic intro/recap skipping.', 'cine-movie-engine'); ?></p>
                    </div>
                    <a href="<?php echo esc_url(\MovieEngine\Admin\Upgrade::get_pro_url('pricing')); ?>" target="_blank" class="button button-primary me-pro-notice-btn">
                        <?php esc_html_e('Upgrade to Pro', 'cine-movie-engine'); ?>
                    </a>
                </div>

                <div class="me-locked-feature">
                    <div class="movie-engine-form-group">
                        <label class="movie-engine-checkbox-label">
                            <input type="checkbox" disabled checked>
                            <span><?php esc_html_e('Enable "Skip Intro" Button', 'cine-movie-engine'); ?></span>
                        </label>
                    </div>
                    <div class="movie-engine-form-row me-form-group">
                        <div class="movie-engine-col skip-intro-label">
                            <label><?php esc_html_e('Intro Start Time (sec)', 'cine-movie-engine'); ?></label>
                            <input type="number" class="movie-engine-input" disabled value="0">
                        </div>
                        <div class="movie-engine-col skip-intro-label">
                            <label><?php esc_html_e('Intro End Time (sec)', 'cine-movie-engine'); ?></label>
                            <input type="number" class="movie-engine-input" disabled value="90">
                        </div>
                    </div>

                    <div class="movie-engine-form-group">
                        <label class="movie-engine-checkbox-label">
                            <input type="checkbox" disabled checked>
                            <span><?php esc_html_e('Enable "Skip Recap" Button', 'cine-movie-engine'); ?></span>
                        </label>
                    </div>
                    <div class="movie-engine-form-row">
                        <div class="movie-engine-col skip-intro-label">
                            <label><?php esc_html_e('Recap Start Time (sec)', 'cine-movie-engine'); ?></label>
                            <input type="number" class="movie-engine-input" disabled value="0">
                        </div>
                        <div class="movie-engine-col skip-intro-label">
                            <label><?php esc_html_e('Recap End Time (sec)', 'cine-movie-engine'); ?></label>
                            <input type="number" class="movie-engine-input" disabled value="30">
                        </div>
                    </div>
                </div>
            </div>
        </div>
<?php
    }
}
