<?php

namespace MovieEngine\Admin\Monetization\Tabs;

if (! defined("ABSPATH")) {
    exit;
}

class VideoTab {

    public static function render($options = [], $standalone = true) {
        if (has_action('movie_engine_render_pro_video_ads')) {
            do_action('movie_engine_render_pro_video_ads', $options, $standalone);
            return;
        }
?>
        <?php if ($standalone) : ?>
            <div class="movie-engine-settings-section">
                <div class="movie-engine-section-header">
                    <h2><?php esc_html_e('Video Player Ads', 'cine-movie-engine'); ?></h2>
                    <p class="description"><?php esc_html_e('Configure VAST/VPAID video advertisements', 'cine-movie-engine'); ?></p>
                </div>
            <?php endif; ?>
            <div class="movie-engine-card">
                <div class="movie-engine-card-header">
                    <h3><span class="fa-solid fa-film"></span> <?php esc_html_e('Video Ad Settings', 'cine-movie-engine'); ?></h3>
                </div>
                <div class="movie-engine-card-body">
                    <div class="me-pro-notice-box">
                        <span class="dashicons dashicons-lock"></span>
                        <div class="me-pro-notice-message">
                            <strong><?php esc_html_e('Video Ads', 'cine-movie-engine'); ?></strong>
                            <p><?php esc_html_e('VAST/VPAID video advertising support is a PRO feature. Upgrade to unlock.', '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 class="movie-engine-checkbox-text"><?php esc_html_e('Enable Video Ads', 'cine-movie-engine'); ?></span>
                            </label>
                            <p class="movie-engine-help-text"><?php esc_html_e('Show video advertisements in the player', 'cine-movie-engine'); ?></p>
                        </div>

                        <div class="movie-engine-form-group">
                            <label><?php esc_html_e('VAST Tag URL', 'cine-movie-engine'); ?></label>
                            <input type="url"
                                class="movie-engine-input"
                                disabled
                                value="https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator="
                                placeholder="https://pubads.g.doubleclick.net/...">
                            <p class="movie-engine-help-text">
                                <?php esc_html_e('Enter your VAST/VPAID ad tag URL. For testing, use this Google Linear Ad Tag:', 'cine-movie-engine'); ?><br>
                                <code>https://pubads.g.doubleclick.net/gampad/ads?iu=/21775744923/external/single_ad_samples&sz=640x480&cust_params=sample_ct%3Dlinear&ciu_szs=300x250&gdfp_req=1&output=vast&unviewed_position_start=1&env=vp&impl=s&correlator=</code>
                            </p>
                        </div>
                    </div>
                </div>
            </div>
            <div class="movie-engine-card">
                <div class="movie-engine-card-header">
                    <h3><span class="fa-solid fa-clock"></span> <?php esc_html_e('Ad Timing', 'cine-movie-engine'); ?></h3>
                </div>
                <div class="movie-engine-card-body">
                    <div class="me-locked-feature">
                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled checked>
                                <span class="movie-engine-checkbox-text"><?php esc_html_e('Pre-roll Ads (Before Video)', 'cine-movie-engine'); ?></span>
                            </label>
                        </div>

                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled checked>
                                <span class="movie-engine-checkbox-text"><?php esc_html_e('Mid-roll Ads (During Video)', 'cine-movie-engine'); ?></span>
                            </label>
                            <div class="movie-engine-sub-options" style="margin-left: 20px; margin-top: 10px; padding-left: 10px; border-left: 1px solid var(--movie-engine-admin-border-color);">
                                <div class="movie-engine-form-group">
                                    <label><?php esc_html_e('Mid-roll Offset (seconds)', 'cine-movie-engine'); ?></label>
                                    <input type="number" class="movie-engine-input" disabled value="300">
                                    <p class="movie-engine-help-text"><?php esc_html_e('Show mid-roll ad after this many seconds (e.g., 300 = 5 minutes)', 'cine-movie-engine'); ?></p>
                                </div>

                                <div class="movie-engine-form-group">
                                    <label><?php esc_html_e('Mid-roll Repeat Count', 'cine-movie-engine'); ?></label>
                                    <input type="number" class="movie-engine-input" disabled value="1">
                                    <p class="movie-engine-help-text"><?php esc_html_e('How many times to repeat the mid-roll ad (e.g., 1 = once, 3 = three times at intervals)', 'cine-movie-engine'); ?></p>
                                </div>
                            </div>
                        </div>

                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled checked>
                                <span class="movie-engine-checkbox-text"><?php esc_html_e('Post-roll Ads (After Video)', 'cine-movie-engine'); ?></span>
                            </label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="movie-engine-card">
                <div class="movie-engine-card-header">
                    <h3><span class="fa-solid fa-wrench"></span> <?php esc_html_e('Advanced Options', 'cine-movie-engine'); ?></h3>
                </div>
                <div class="movie-engine-card-body">
                    <div class="me-locked-feature">
                        <div class="movie-engine-form-group">
                            <label><?php esc_html_e('Skip Button Delay (seconds)', 'cine-movie-engine'); ?></label>
                            <input type="number" class="movie-engine-input" disabled value="5">
                            <p class="movie-engine-help-text"><?php esc_html_e('Show "Skip Ad" button after this many seconds (0 = non-skippable)', 'cine-movie-engine'); ?></p>
                        </div>

                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled>
                                <span class="movie-engine-checkbox-text"><?php esc_html_e('Mute Ads by Default', 'cine-movie-engine'); ?></span>
                            </label>
                        </div>

                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled checked>
                                <span class="movie-engine-checkbox-text"><?php esc_html_e('Force Multiple Ads (Test Mode)', 'cine-movie-engine'); ?></span>
                                <p class="movie-engine-help-text"><?php esc_html_e('Try to play multiple ads if VAST tag returns a pod', 'cine-movie-engine'); ?></p>
                            </label>
                        </div>

                        <div class="movie-engine-form-group">
                            <label class="movie-engine-checkbox-label">
                                <input type="checkbox" disabled>
                                <span class="movie-engine-checkbox-text"><?php esc_html_e('Show Ads for Admin (Test Mode)', 'cine-movie-engine'); ?></span>
                                <p class="movie-engine-help-text"><?php esc_html_e('Enable testing ads while logged in as administrator', 'cine-movie-engine'); ?></p>
                            </label>
                        </div>
                    </div>
                </div>
            </div>

            <?php if ($standalone) : ?>
            </div>
        <?php endif; ?>
<?php
    }
}
