<?php

namespace MovieEngine\Admin\Player\Tabs;

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

class SecurityTab {

    public static function render($options) {
?>
        <input type="hidden" name="movie_engine_player_settings[active_sub_tab]" value="player_security">
        <div class="movie-engine-card">
            <div class="movie-engine-card-header">
                <h3><span class="fa-solid fa-shield-halved"></span> <?php esc_html_e('Security', '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[disable_right_click]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[disable_right_click]" value="1" <?php checked($options['movie_engine_disable_right_click'] ?? ($options['disable_right_click'] ?? 0), 1); ?>>
                        <span><?php esc_html_e('Disable Right Click', '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[disable_download_keys]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[disable_download_keys]" value="1" <?php checked($options['movie_engine_disable_download_keys'] ?? ($options['disable_download_keys'] ?? 0), 1); ?>>
                        <span><?php esc_html_e('Disable Download Shortcut Keys', '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[prevent_iframe]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[prevent_iframe]" value="1" <?php checked($options['movie_engine_prevent_iframe'] ?? ($options['prevent_iframe'] ?? 0), 1); ?>>
                        <span><?php esc_html_e('Prevent iFrame Embedding', '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[disable_pip_security]" value="0">
                        <input type="checkbox" name="movie_engine_player_settings[disable_pip_security]" value="1" <?php checked($options['movie_engine_disable_pip_security'] ?? ($options['disable_pip_security'] ?? 0), 1); ?>>
                        <span><?php esc_html_e('Disable Picture-in-Picture (Security)', 'cine-movie-engine'); ?></span>
                    </label>
                </div>

                <hr class="me-hr">
                <?php if (! has_action('movie_engine_render_pro_security_advanced')) : ?>
                    <div class="me-pro-notice-box">
                        <span class="dashicons dashicons-lock"></span>
                        <div class="me-pro-notice-message">
                            <strong><?php esc_html_e('Advanced Security', 'cine-movie-engine'); ?></strong>
                            <p><?php esc_html_e('Features like Secure Signed URLs, Anti-Screen Recording, and hiding video URLs are PRO features.', '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>
                <?php endif; ?>

                <?php
                if (has_action('movie_engine_render_pro_security_advanced')) {
                    do_action('movie_engine_render_pro_security_advanced', $options);
                } else {
                ?>
                    <div class="me-locked-feature">
                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled>
                                <span><?php esc_html_e('Secure Signed URLs (Time-Limited & IP-Bound)', 'cine-movie-engine'); ?></span>
                            </label>
                            <p class="movie-engine-field-description">
                                <?php esc_html_e('Generate signed URLs with 1-hour expiration and IP binding. Prevents URL sharing and unauthorized access while maintaining performance.', 'cine-movie-engine'); ?>
                            </p>
                        </div>
                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled>
                                <span><?php esc_html_e('Watermark for Anti-Screen Recording', 'cine-movie-engine'); ?></span>
                            </label>
                        </div>
                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled>
                                <span><?php esc_html_e('Hide Video URL in Source Code', 'cine-movie-engine'); ?></span>
                            </label>
                            <p class="movie-engine-field-description">
                                <?php esc_html_e('Load videos through secure proxy with signed tokens. Hides direct URLs in HTML source and adds time-limited, IP-bound protection. Recommended for maximum security.', 'cine-movie-engine'); ?>
                            </p>
                        </div>
                    </div>
                <?php
                }
                ?>
            </div>
        </div>
<?php
    }
}
