<?php
/**
 * White Label Page Template
 *
 * @package    TTSWP
 * @subpackage Mementor_TTS/admin/partials/pages
 * @author     Mementor AS
 */

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

// White Label editing requires Agency plan
$can_edit = get_option( 'tts_site_plan_slug', '' ) === 'agency';

// Handle form submission
if ($can_edit && isset($_POST['mementor_tts_white_label_nonce']) && wp_verify_nonce(sanitize_key(wp_unslash($_POST['mementor_tts_white_label_nonce'])), 'mementor_tts_white_label_save')) {
    if (isset($_POST['white_label_name'])) {
        update_option('mementor_tts_white_label_name', sanitize_text_field(wp_unslash($_POST['white_label_name'])));
    }
    if (isset($_POST['white_label_plugin_list_name'])) {
        update_option('mementor_tts_white_label_plugin_list_name', sanitize_text_field(wp_unslash($_POST['white_label_plugin_list_name'])));
    }
    if (isset($_POST['white_label_plugin_list_name_pro'])) {
        update_option('mementor_tts_white_label_plugin_list_name_pro', sanitize_text_field(wp_unslash($_POST['white_label_plugin_list_name_pro'])));
    }
    if (isset($_POST['white_label_author'])) {
        update_option('mementor_tts_white_label_author', sanitize_text_field(wp_unslash($_POST['white_label_author'])));
    }
    if (isset($_POST['white_label_author_uri'])) {
        update_option('mementor_tts_white_label_author_uri', esc_url_raw(wp_unslash($_POST['white_label_author_uri'])));
    }
    if (isset($_POST['white_label_plugin_uri'])) {
        update_option('mementor_tts_white_label_plugin_uri', esc_url_raw(wp_unslash($_POST['white_label_plugin_uri'])));
    }
    if (isset($_POST['white_label_visibility'])) {
        update_option('mementor_tts_white_label_visibility', sanitize_text_field(wp_unslash($_POST['white_label_visibility'])));
    }
    if (isset($_POST['white_label_allowed_users'])) {
        update_option('mementor_tts_white_label_allowed_users', sanitize_textarea_field(wp_unslash($_POST['white_label_allowed_users'])));
    }
    update_option('mementor_tts_white_label_hide_affiliate', isset($_POST['white_label_hide_affiliate']) ? '1' : '0');
    update_option('mementor_tts_white_label_hide_license', isset($_POST['white_label_hide_license']) ? '1' : '0');
    update_option('mementor_tts_white_label_hide_documentation', isset($_POST['white_label_hide_documentation']) ? '1' : '0');
    update_option('mementor_tts_white_label_hide_add_credits', isset($_POST['white_label_hide_add_credits']) ? '1' : '0');
    update_option('mementor_tts_white_label_hide_pro_help', isset($_POST['white_label_hide_pro_help']) ? '1' : '0');

    // Handle logo upload
    if (!empty($_FILES['white_label_logo']['name'])) {
        require_once(ABSPATH . 'wp-admin/includes/file.php');

        // Temporarily allow SVG uploads
        $allow_svg = function($mimes) {
            $mimes['svg'] = 'image/svg+xml';
            return $mimes;
        };
        add_filter('upload_mimes', $allow_svg);

        // Also fix WP's filetype check for SVG
        $fix_svg_filetype = function($data, $file, $filename, $mimes) {
            $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
            if ($ext === 'svg') {
                $data['ext'] = 'svg';
                $data['type'] = 'image/svg+xml';
            }
            return $data;
        };
        add_filter('wp_check_filetype_and_ext', $fix_svg_filetype, 10, 4);

        $uploaded = wp_handle_upload($_FILES['white_label_logo'], array(
            'test_form' => false,
        ));

        remove_filter('upload_mimes', $allow_svg);
        remove_filter('wp_check_filetype_and_ext', $fix_svg_filetype, 10);

        if (!isset($uploaded['error']) && isset($uploaded['url'])) {
            update_option('mementor_tts_white_label_logo', $uploaded['url']);
        } elseif (isset($uploaded['error'])) {
            $error = $uploaded['error'];
        }
    }

    // Handle logo removal
    if (isset($_POST['remove_logo']) && sanitize_text_field(wp_unslash($_POST['remove_logo'])) === '1') {
        delete_option('mementor_tts_white_label_logo');
    }

    $wl_toast_message = !isset($error)
        ? __('White label settings saved successfully!', 'text-to-speech-tts')
        : $error;
    $wl_toast_type = !isset($error) ? 'success' : 'error';
}

// Get settings after form processing
$white_label_logo = get_option('mementor_tts_white_label_logo', '');
$white_label_name = get_option('mementor_tts_white_label_name', '');
$white_label_plugin_list_name = get_option('mementor_tts_white_label_plugin_list_name', '');
$white_label_plugin_list_name_pro = get_option('mementor_tts_white_label_plugin_list_name_pro', '');
$white_label_author = get_option('mementor_tts_white_label_author', '');
$white_label_author_uri = get_option('mementor_tts_white_label_author_uri', '');
$white_label_plugin_uri = get_option('mementor_tts_white_label_plugin_uri', '');
$visibility = get_option('mementor_tts_white_label_visibility', 'all');

?>
<?php
$tts_page_title = __('White Label', 'text-to-speech-tts');
$tts_topbar_actions = $can_edit
    ? '<button type="submit" form="white-label-form" class="tts-btn tts-btn-primary">' . esc_html__('Save settings', 'text-to-speech-tts') . '</button>'
    : '';
include MEMENTOR_TTS_PLUGIN_DIR . 'admin/partials/layout-open.php';
?>
<?php include(MEMENTOR_TTS_PLUGIN_DIR . 'admin/partials/navigation.php'); ?>

            <?php if (!$can_edit): ?>

            <!-- PRO Upsell -->
            <div class="tts-card tts-wl-hero">
                <div class="tts-wl-hero-inner">
                    <h3><?php esc_html_e('Make It Yours with White Label', 'text-to-speech-tts'); ?></h3>
                    <p><?php esc_html_e('Customize the plugin to perfectly match your brand identity. A great solution for agencies, freelancers, or companies who want to resell and present it as their own.', 'text-to-speech-tts'); ?></p>
                </div>
            </div>

            <div class="tts-card">
                <div class="tts-card-header tts-card-header-inline">
                    <h3 class="tts-card-title"><?php esc_html_e('What You Get', 'text-to-speech-tts'); ?></h3>
                    <span class="tts-pill tts-pill-pro"><span class="dashicons dashicons-star-filled"></span> <?php esc_html_e('Agency Plan', 'text-to-speech-tts'); ?></span>
                </div>

                <div class="tts-grid-2 tts-wl-features">
                    <div class="tts-metric">
                        <div class="tts-metric-label"><?php esc_html_e('Requirements', 'text-to-speech-tts'); ?></div>
                        <ul class="tts-wl-list">
                            <li><?php esc_html_e('Agency plan subscription', 'text-to-speech-tts'); ?></li>
                        </ul>
                        <a href="<?php echo esc_url(admin_url('admin.php?page=text-to-speech-tts-account')); ?>" class="tts-btn tts-btn-primary" style="margin-top:12px;">
                            <?php esc_html_e('Upgrade to Agency', 'text-to-speech-tts'); ?> &rarr;
                        </a>
                    </div>
                    <div class="tts-metric">
                        <div class="tts-metric-label"><?php esc_html_e('Features', 'text-to-speech-tts'); ?></div>
                        <ul class="tts-wl-list">
                            <li><?php esc_html_e('Custom plugin name & logo', 'text-to-speech-tts'); ?></li>
                            <li><?php esc_html_e('Separate names for Free & PRO', 'text-to-speech-tts'); ?></li>
                            <li><?php esc_html_e('Custom author name & website', 'text-to-speech-tts'); ?></li>
                            <li><?php esc_html_e('Hide Affiliate & License menus', 'text-to-speech-tts'); ?></li>
                            <li><?php esc_html_e('Control page visibility per user', 'text-to-speech-tts'); ?></li>
                        </ul>
                    </div>
                </div>

            </div>

            <!-- Settings Preview (disabled teaser) -->
            <div class="tts-card tts-wl-teaser">
                <div class="tts-card-header tts-card-header-inline">
                    <h3 class="tts-card-title"><?php esc_html_e('Settings Preview', 'text-to-speech-tts'); ?></h3>
                    <span class="tts-pill tts-pill-neutral"><?php esc_html_e('Agency Plan Required', 'text-to-speech-tts'); ?></span>
                </div>

                <div class="tts-setting-row">
                    <div>
                        <div class="tts-setting-label"><?php esc_html_e('Plugin Name', 'text-to-speech-tts'); ?></div>
                        <div class="tts-setting-hint"><?php esc_html_e('Shown throughout the admin interface.', 'text-to-speech-tts'); ?></div>
                    </div>
                    <input type="text" disabled placeholder="<?php esc_attr_e('Your Brand Name', 'text-to-speech-tts'); ?>" class="tts-wl-input">
                </div>

                <div class="tts-setting-row">
                    <div>
                        <div class="tts-setting-label"><?php esc_html_e('Plugin Author', 'text-to-speech-tts'); ?></div>
                        <div class="tts-setting-hint"><?php esc_html_e('Shown as "By [Author]" in the plugins list.', 'text-to-speech-tts'); ?></div>
                    </div>
                    <input type="text" disabled placeholder="<?php esc_attr_e('Your Company', 'text-to-speech-tts'); ?>" class="tts-wl-input">
                </div>

                <div class="tts-setting-row">
                    <div>
                        <div class="tts-setting-label"><?php esc_html_e('Plugin Logo', 'text-to-speech-tts'); ?></div>
                        <div class="tts-setting-hint"><?php esc_html_e('Recommended: Square logo. Accepts JPG, PNG, GIF, SVG.', 'text-to-speech-tts'); ?></div>
                    </div>
                    <input type="file" disabled class="tts-wl-input">
                </div>

                <div class="tts-setting-row">
                    <div>
                        <div class="tts-setting-label"><?php esc_html_e('Hide Menu Items', 'text-to-speech-tts'); ?></div>
                        <div class="tts-setting-hint"><?php esc_html_e('Hide Affiliate & License pages from non-admin users.', 'text-to-speech-tts'); ?></div>
                    </div>
                    <label class="tts-toggle">
                        <input type="checkbox" disabled>
                        <span class="tts-toggle-slider"></span>
                    </label>
                </div>
            </div>

            <?php else: ?>

            <!-- PRO Edit View -->
            <form method="post" enctype="multipart/form-data" action="" id="white-label-form">
                <?php wp_nonce_field('mementor_tts_white_label_save', 'mementor_tts_white_label_nonce'); ?>

                <div class="tts-wl-layout">
                <div><!-- main column -->

                <!-- Branding -->
                <div class="tts-card">
                    <div class="tts-card-header tts-card-header-inline">
                        <h3 class="tts-card-title"><?php esc_html_e('Branding', 'text-to-speech-tts'); ?></h3>
                        <p class="tts-card-desc"><?php esc_html_e('Customize plugin name and logo', 'text-to-speech-tts'); ?></p>
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Plugin Name', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Shown throughout the admin interface. Leave empty for default.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <input type="text" name="white_label_name" value="<?php echo esc_attr($white_label_name); ?>" placeholder="<?php esc_attr_e('Text to Speech (TTS)', 'text-to-speech-tts'); ?>" class="tts-wl-input">
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Plugin List Name (Free)', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Shown for the free version in the WordPress plugins list.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <input type="text" name="white_label_plugin_list_name" value="<?php echo esc_attr($white_label_plugin_list_name); ?>" placeholder="<?php esc_attr_e('Mementor Text to Speech (TTS) Accessibility', 'text-to-speech-tts'); ?>" class="tts-wl-input">
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Plugin List Name (PRO)', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Shown for the PRO version in the WordPress plugins list.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <input type="text" name="white_label_plugin_list_name_pro" value="<?php echo esc_attr($white_label_plugin_list_name_pro); ?>" placeholder="<?php esc_attr_e('Mementor Text to Speech (TTS) PRO', 'text-to-speech-tts'); ?>" class="tts-wl-input">
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Plugin Author', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Shown as "By [Author]" in the plugins list.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <input type="text" name="white_label_author" value="<?php echo esc_attr($white_label_author); ?>" placeholder="<?php esc_attr_e('Mementor AS', 'text-to-speech-tts'); ?>" class="tts-wl-input">
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Author Website', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Link when users click the author name.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <input type="url" name="white_label_author_uri" value="<?php echo esc_attr($white_label_author_uri); ?>" placeholder="https://mementor.no" class="tts-wl-input">
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Plugin Website', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Link for "Visit plugin site" in the plugins list.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <input type="url" name="white_label_plugin_uri" value="<?php echo esc_attr($white_label_plugin_uri); ?>" placeholder="https://example.com" class="tts-wl-input">
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Plugin Logo', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Recommended: Square logo. Accepts JPG, PNG, GIF, SVG.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <div>
                            <?php if (!empty($white_label_logo)) : ?>
                            <div class="tts-wl-logo-current">
                                <img src="<?php echo esc_url($white_label_logo); ?>" alt="<?php esc_attr_e('Current Logo', 'text-to-speech-tts'); ?>">
                                <label class="tts-wl-remove-logo">
                                    <input type="checkbox" name="remove_logo" value="1">
                                    <?php esc_html_e('Remove', 'text-to-speech-tts'); ?>
                                </label>
                            </div>
                            <?php endif; ?>
                            <input type="file" name="white_label_logo" accept="image/*">
                        </div>
                    </div>
                </div>

                <!-- Visibility -->
                <div class="tts-card">
                    <div class="tts-card-header tts-card-header-inline">
                        <h3 class="tts-card-title"><?php esc_html_e('Visibility', 'text-to-speech-tts'); ?></h3>
                        <p class="tts-card-desc"><?php esc_html_e('Control access and menu items', 'text-to-speech-tts'); ?></p>
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('White Label Page Visibility', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Control who can see and access the White Label settings page.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <div class="tts-wl-radio-group">
                            <label><input type="radio" name="white_label_visibility" value="all" <?php checked($visibility, 'all'); ?>> <?php esc_html_e('All admins', 'text-to-speech-tts'); ?></label>
                            <label><input type="radio" name="white_label_visibility" value="admin_only" <?php checked($visibility, 'admin_only'); ?>> <?php esc_html_e('Administrators only', 'text-to-speech-tts'); ?></label>
                            <label><input type="radio" name="white_label_visibility" value="specific_users" <?php checked($visibility, 'specific_users'); ?>> <?php esc_html_e('Specific users', 'text-to-speech-tts'); ?></label>
                            <div id="allowed_users_container" class="tts-wl-users-field" <?php echo ($visibility !== 'specific_users') ? 'style="display:none;"' : ''; ?>>
                                <textarea name="white_label_allowed_users" rows="3" placeholder="user@example.com&#10;another@example.com"><?php echo esc_textarea(get_option('mementor_tts_white_label_allowed_users', '')); ?></textarea>
                                <div class="tts-setting-hint"><?php esc_html_e('Enter email addresses or usernames, one per line.', 'text-to-speech-tts'); ?></div>
                            </div>
                        </div>
                    </div>

                    <div class="tts-setting-row">
                        <div>
                            <div class="tts-setting-label"><?php esc_html_e('Hide Menu Items', 'text-to-speech-tts'); ?></div>
                            <div class="tts-setting-hint"><?php esc_html_e('Hide specific menu items from non-admin users.', 'text-to-speech-tts'); ?></div>
                        </div>
                        <div class="tts-wl-checkbox-group">
                            <label><input type="checkbox" name="white_label_hide_affiliate" value="1" <?php checked(get_option('mementor_tts_white_label_hide_affiliate', '0'), '1'); ?>> <?php esc_html_e('Hide "Affiliate Program"', 'text-to-speech-tts'); ?></label>
                            <label><input type="checkbox" name="white_label_hide_license" value="1" <?php checked(get_option('mementor_tts_white_label_hide_license', '0'), '1'); ?>> <?php esc_html_e('Hide "License PRO"', 'text-to-speech-tts'); ?></label>
                            <label><input type="checkbox" name="white_label_hide_documentation" value="1" <?php checked(get_option('mementor_tts_white_label_hide_documentation', '0'), '1'); ?>> <?php esc_html_e('Hide "Documentation"', 'text-to-speech-tts'); ?></label>
                            <label><input type="checkbox" name="white_label_hide_add_credits" value="1" <?php checked(get_option('mementor_tts_white_label_hide_add_credits', '0'), '1'); ?>> <?php esc_html_e('Hide "Add More Credits"', 'text-to-speech-tts'); ?></label>
                            <label><input type="checkbox" name="white_label_hide_pro_help" value="1" <?php checked(get_option('mementor_tts_white_label_hide_pro_help', '0'), '1'); ?>> <?php esc_html_e('Hide "PRO Support"', 'text-to-speech-tts'); ?></label>
                        </div>
                    </div>
                </div>

                </div><!-- end main column -->

                <!-- Sidebar column -->
                <div class="tts-wl-sidebar">
                <div class="tts-card">
                    <div class="tts-card-header">
                        <h3 class="tts-card-title"><?php esc_html_e('Tips', 'text-to-speech-tts'); ?></h3>
                    </div>
                    <ul class="tts-wl-tips">
                        <li><?php esc_html_e('Use a square logo with a transparent background.', 'text-to-speech-tts'); ?></li>
                        <li><?php esc_html_e('Choose a short, professional plugin name.', 'text-to-speech-tts'); ?></li>
                        <li><?php esc_html_e('Your branding shows on all plugin admin pages.', 'text-to-speech-tts'); ?></li>
                        <li><?php esc_html_e('Settings are saved per site.', 'text-to-speech-tts'); ?></li>
                        <li><?php esc_html_e('Hide pages for a fully white-labeled experience.', 'text-to-speech-tts'); ?></li>
                    </ul>
                </div>
                </div><!-- /.tts-wl-sidebar -->

                </div><!-- /.tts-wl-layout -->

                <!-- Preview -->
                <?php if ($white_label_name || $white_label_logo): ?>
                <div class="tts-card">
                    <div class="tts-card-header tts-card-header-inline">
                        <h3 class="tts-card-title"><?php esc_html_e('Preview', 'text-to-speech-tts'); ?></h3>
                        <p class="tts-card-desc"><?php esc_html_e('How your branding will appear', 'text-to-speech-tts'); ?></p>
                    </div>
                    <div class="tts-wl-preview">
                        <?php if ($white_label_logo): ?>
                        <img src="<?php echo esc_url($white_label_logo); ?>" alt="<?php echo esc_attr($white_label_name); ?>">
                        <?php endif; ?>
                        <?php if ($white_label_name): ?>
                        <span><?php echo esc_html($white_label_name); ?></span>
                        <?php endif; ?>
                    </div>
                </div>
                <?php endif; ?>
            </form>

            <?php endif; ?>

            <style>
            /* Hero */
            .tts-wl-hero {
                background: linear-gradient(135deg, var(--tts-purple, #7c3aed) 0%, #5b21b6 100%);
                border-color: transparent;
            }

            .tts-wl-hero-inner {
                text-align: center;
                padding: 32px 20px;
            }

            .tts-wl-hero-inner h3 {
                font-size: 24px;
                font-weight: 600;
                color: #fff;
                margin: 0 0 12px;
            }

            .tts-wl-hero-inner p {
                max-width: 600px;
                margin: 0 auto;
                font-size: 14px;
                line-height: 1.6;
                color: rgba(255, 255, 255, 0.9);
            }

            /* PRO pill */
            .tts-pill-pro {
                background: #fef3cd;
                color: #856404;
                font-size: 12px;
                padding: 4px 10px;
                border-radius: 10px;
                display: inline-flex;
                align-items: center;
                gap: 4px;
                white-space: nowrap;
            }

            .tts-pill-pro::before { display: none; }

            .tts-pill-pro .dashicons {
                font-size: 14px;
                width: 14px;
                height: 14px;
                color: #f0b849;
            }

            /* Feature list */
            .tts-wl-list {
                list-style: none;
                margin: 8px 0 0;
                padding: 0;
            }

            .tts-wl-list li {
                position: relative;
                padding-left: 18px;
                margin-bottom: 6px;
                font-size: 13px;
                color: var(--tts-text-primary);
                line-height: 1.5;
            }

            .tts-wl-list li::before {
                content: '\2713';
                position: absolute;
                left: 0;
                color: #0F6E56;
                font-weight: bold;
            }

            /* CTA */
            .tts-wl-cta {
                text-align: center;
                padding: 16px 20px 20px;
                border-top: var(--tts-border);
            }

            .tts-btn-lg {
                padding: 10px 28px;
                font-size: 14px;
            }

            /* 3/1 layout */
            .tts-wl-layout {
                display: grid;
                grid-template-columns: 3fr 1fr;
                gap: 16px;
                align-items: start;
            }

            .tts-wl-sidebar .tts-card {
                position: sticky;
                top: 48px;
            }

            @media screen and (max-width: 1200px) {
                .tts-wl-layout {
                    grid-template-columns: 1fr;
                }
            }

            /* Tips */
            .tts-wl-tips {
                list-style: none;
                margin: 0;
                padding: 0 16px 16px;
            }

            .tts-wl-tips li {
                position: relative;
                padding: 8px 0 8px 18px;
                border-bottom: 1px solid #f0f0f0;
                font-size: 12px;
                color: var(--tts-text-secondary, #646970);
                line-height: 1.5;
            }

            .tts-wl-tips li:last-child {
                border-bottom: none;
                padding-bottom: 0;
            }

            .tts-wl-tips li::before {
                content: '\2022';
                position: absolute;
                left: 0;
                color: var(--tts-purple, #7c3aed);
                font-size: 16px;
                line-height: 1;
                top: 8px;
            }

            /* Teaser (disabled preview) */
            .tts-wl-teaser .tts-setting-row {
                opacity: 0.55;
                pointer-events: none;
            }

            /* Inputs — width only; border/bg/focus from global rules */
            .tts-wl-input {
                width: 280px !important;
            }

            /* Logo */
            .tts-wl-logo-preview img,
            .tts-wl-logo-current img {
                max-height: 40px;
                display: block;
                background: var(--tts-bg-secondary);
                padding: 8px;
                border-radius: var(--tts-radius-sm);
            }

            .tts-wl-logo-current {
                display: flex;
                align-items: center;
                gap: 12px;
                margin-bottom: 8px;
            }

            .tts-wl-remove-logo {
                font-size: 12px;
                color: var(--tts-red, #dc2626);
                cursor: pointer;
            }

            /* Radio & checkbox groups */
            .tts-wl-radio-group,
            .tts-wl-checkbox-group {
                display: flex;
                flex-direction: column;
                gap: 6px;
                font-size: 13px;
            }

            .tts-wl-users-field {
                margin-top: 8px;
            }

            .tts-wl-users-field textarea {
                width: 280px !important;
                max-width: 280px;
            }

            /* Preview */
            .tts-wl-preview {
                display: flex;
                align-items: center;
                gap: 12px;
                padding: 20px;
                background: var(--tts-bg-secondary);
                border-radius: var(--tts-radius-md);
                margin: 0 16px 16px;
            }

            .tts-wl-preview img {
                max-height: 40px;
            }

            .tts-wl-preview span {
                font-size: 20px;
                font-weight: 400;
                color: var(--tts-text-primary);
            }
            </style>

<?php include MEMENTOR_TTS_PLUGIN_DIR . 'admin/partials/layout-close.php'; ?>

<script>
jQuery(document).ready(function($) {
    $('input[name="white_label_visibility"]').on('change', function() {
        if ($(this).val() === 'specific_users') {
            $('#allowed_users_container').slideDown();
        } else {
            $('#allowed_users_container').slideUp();
        }
    });
});
<?php if (!empty($wl_toast_message)) : ?>
if (typeof mementorTTSShowNotification === 'function') {
    mementorTTSShowNotification('<?php echo esc_js($wl_toast_message); ?>', '<?php echo esc_js($wl_toast_type); ?>');
}
<?php endif; ?>
</script>
