<?php
/**
 * Solo vendor integration (WooCommerce-only, no Dokan)
 *
 * Provides WP admin menu pages for the booking wizard, bookings list,
 * calendar, analytics, and settings when Dokan is NOT active.
 * The site owner (administrator / shop_manager) acts as the sole vendor.
 *
 * @package WahraRentalsBookings
 */

defined('ABSPATH') || exit;

/**
 * Solo vendor integration class
 */
class WAHRB_Solo_Integration {

    /**
     * Constructor
     */
    public function __construct() {
        $this->init_hooks();
    }

    /**
     * Initialize hooks
     */
    private function init_hooks(): void {
        // Register admin menu pages
        add_action('admin_menu', [$this, 'register_admin_menus'], 20);

        // Enqueue admin assets on our pages
        add_action('admin_enqueue_scripts', [$this, 'enqueue_admin_assets']);

        // Add product edit fields (WooCommerce product data tabs)
        add_action('woocommerce_product_data_tabs', [$this, 'add_product_data_tab']);
        add_action('woocommerce_product_data_panels', [$this, 'render_product_data_panel']);
        add_action('woocommerce_process_product_meta', [$this, 'save_product_rental_fields']);

        // Add dashboard widget on WP dashboard
        add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']);
    }

    /**
     * Register admin menu pages — single merged menu for solo mode
     *
     * Combines admin pages (bookings overview, settings, analytics) with
     * vendor pages (wizard, calendar, fine-tune) into one top-level menu.
     */
    public function register_admin_menus(): void {
        // Top-level menu: Rentals
        add_menu_page(
            __('Rentals', 'wahra-rentals-bookings'),
            __('Rentals', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-dashboard',
            [$this, 'render_dashboard_page'],
            'dashicons-calendar-alt',
            56 // After WooCommerce
        );

        // Submenu: Dashboard (renames first item)
        add_submenu_page(
            'wahrb-dashboard',
            __('Dashboard', 'wahra-rentals-bookings'),
            __('Dashboard', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-dashboard',
            [$this, 'render_dashboard_page']
        );

        // Submenu: Bookings (admin bookings — rich filters, status cards)
        add_submenu_page(
            'wahrb-dashboard',
            __('Bookings', 'wahra-rentals-bookings'),
            __('Bookings', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-bookings',
            [$this, 'render_bookings_page']
        );

        // Submenu: Rental Wizard
        add_submenu_page(
            'wahrb-dashboard',
            __('Rental Wizard', 'wahra-rentals-bookings'),
            __('Rental Wizard', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-wizard',
            [$this, 'render_wizard_page']
        );

        // Submenu: Calendar
        add_submenu_page(
            'wahrb-dashboard',
            __('Calendar', 'wahra-rentals-bookings'),
            __('Calendar', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-calendar',
            [$this, 'render_calendar_page']
        );

        // Submenu: Statistics (admin analytics — AJAX, period filters, richer)
        add_submenu_page(
            'wahrb-dashboard',
            __('Statistics', 'wahra-rentals-bookings'),
            __('Statistics', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-analytics',
            [$this, 'render_analytics_page']
        );

        // Submenu: Settings (admin settings — full platform config)
        add_submenu_page(
            'wahrb-dashboard',
            __('Settings', 'wahra-rentals-bookings'),
            __('Settings', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-settings',
            [$this, 'render_admin_settings_page']
        );

        // Submenu: Form Builder
        add_submenu_page(
            'wahrb-dashboard',
            __('Form Builder', 'wahra-rentals-bookings'),
            __('Form Builder', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-form-builder',
            [$this, 'render_form_builder_page']
        );

        // Submenu: Visual (vendor visual customization)
        add_submenu_page(
            'wahrb-dashboard',
            __('Visual', 'wahra-rentals-bookings'),
            __('Visual', 'wahra-rentals-bookings'),
            'manage_woocommerce',
            'wahrb-vendor-settings',
            [$this, 'render_settings_page']
        );

        // Hidden submenu: Booking Detail (not shown in menu, accessed via bookings list)
        add_submenu_page(
            null, // No parent — hidden page
            __('Booking Detail', 'wahra-rentals-bookings'),
            '',
            'manage_woocommerce',
            'wahrb-booking-detail',
            [$this, 'render_booking_detail_page']
        );
    }

    /**
     * Enqueue admin assets on our custom pages
     *
     * @param string $hook_suffix Current admin page hook suffix
     */
    public function enqueue_admin_assets(string $hook_suffix): void {
        // All our pages contain 'wahrb-' in their hook suffix
        if (strpos($hook_suffix, 'wahrb-') === false) {
            return;
        }

        // Dashboard page needs only minimal styles (inline styles are sufficient)
        if (strpos($hook_suffix, 'wahrb-dashboard') !== false) {
            return;
        }

        // Bookings page now uses the vendor bookings-list template — needs vendor assets
        // (falls through to vendor-facing enqueue below)

        // Admin analytics page — CSS + Chart.js enqueued in render method
        if (strpos($hook_suffix, 'wahrb-analytics') !== false) {
            return;
        }

        // Admin settings page — wahrb-admin.css loaded by main plugin enqueue
        if (strpos($hook_suffix, 'wahrb-settings') !== false
            && strpos($hook_suffix, 'wahrb-vendor-settings') === false) {
            return;
        }

        // Vendor-facing pages (wizard, calendar, fine-tune) need vendor styles
        wp_enqueue_style(
            'wahrb-vendor-styles',
            WAHRB_PLUGIN_URL . 'assets/css/wahrb-vendor.css',
            [],
            WAHRB_VERSION
        );

        // FontAwesome
        wp_enqueue_style(
            'fontawesome',
            WAHRB_PLUGIN_URL . 'assets/vendor/fontawesome/css/all.min.css',
            [],
            '6.7.2'
        );

        // Vendor script
        wp_enqueue_script(
            'wahrb-vendor-script',
            WAHRB_PLUGIN_URL . 'assets/js/wahrb-vendor.js',
            ['jquery'],
            WAHRB_VERSION,
            true
        );

        wp_localize_script('wahrb-vendor-script', 'wahrbVendorConfig', [
            'apiUrl' => rest_url('wahrb/v1'),
            'nonce' => wp_create_nonce('wp_rest'),
            'vendorId' => get_current_user_id(),
            'currency' => get_woocommerce_currency(),
            'currencySymbol' => html_entity_decode(get_woocommerce_currency_symbol(), ENT_QUOTES, 'UTF-8'),
            'i18n' => [
                'confirmBooking'  => __('Confirm this booking?', 'wahra-rentals-bookings'),
                'cancelReason'    => __('Cancellation reason (optional):', 'wahra-rentals-bookings'),
                'checkinNotes'    => __('Check-in notes (optional):', 'wahra-rentals-bookings'),
                'checkoutNotes'   => __('Check-out notes (product condition, damages...):', 'wahra-rentals-bookings'),
                'error'           => __('Error', 'wahra-rentals-bookings'),
                'unknownError'    => __('An error occurred', 'wahra-rentals-bookings'),
                'loading'         => __('Loading...', 'wahra-rentals-bookings'),
                'loadError'       => __('Loading error', 'wahra-rentals-bookings'),
                'noData'          => __('No data', 'wahra-rentals-bookings'),
                'noBookings'      => __('No bookings', 'wahra-rentals-bookings'),
                'bookings'        => __('Bookings', 'wahra-rentals-bookings'),
                'revenue'         => __('Revenue', 'wahra-rentals-bookings'),
                'view'            => __('View', 'wahra-rentals-bookings'),
            ],
        ]);

        // Solo-mode specific wrapper styles
        wp_add_inline_style('wahrb-vendor-styles', $this->get_admin_wrapper_css());

        // Page-specific assets
        if (strpos($hook_suffix, 'wahrb-wizard') !== false) {
            $this->enqueue_wizard_assets();
        } elseif (strpos($hook_suffix, 'wahrb-calendar') !== false) {
            $this->enqueue_calendar_assets();
        }
    }

    /**
     * Get CSS for WP admin wrapper to make Dokan templates look native
     *
     * @return string CSS
     */
    private function get_admin_wrapper_css(): string {
        return '
.wahrb-solo-wrap{max-width:1200px;margin:20px auto;padding:0 20px}
.wahrb-solo-wrap .dokan-dashboard-wrap{background:transparent;padding:0}
.wahrb-solo-wrap .dokan-dashboard-content{margin:0;padding:0;float:none;width:100%}
.wahrb-solo-wrap .dokan-panel{background:#fff;border:1px solid #c3c4c7;box-shadow:0 1px 1px rgba(0,0,0,.04)}
.wahrb-solo-wrap .dokan-panel-heading{background:#f0f0f1;border-bottom:1px solid #c3c4c7;padding:12px 15px}
.wahrb-solo-wrap .dokan-panel-body{padding:15px}
.wahrb-solo-wrap .dokan-btn{display:inline-block;padding:6px 12px;font-size:13px;border-radius:3px;cursor:pointer;text-decoration:none;border:1px solid transparent}
.wahrb-solo-wrap .dokan-btn-theme{background:#2271b1;color:#fff;border-color:#2271b1}
.wahrb-solo-wrap .dokan-btn-theme:hover{background:#135e96;color:#fff}
.wahrb-solo-wrap .dokan-btn-default{background:#f0f0f1;color:#2c3338;border-color:#c3c4c7}
.wahrb-solo-wrap .dokan-btn-default:hover{background:#dcdcde;color:#2c3338}
.wahrb-solo-wrap .dokan-form-control{width:100%;max-width:400px;padding:6px 8px;border:1px solid #8c8f94;border-radius:3px;font-size:13px}
.wahrb-solo-wrap .dokan-form-group{margin-bottom:15px}
.wahrb-solo-wrap .dokan-w6{display:inline-block;width:48%;vertical-align:top;margin-right:2%}
.wahrb-solo-wrap table.dokan-table{border-collapse:collapse;width:100%}
.wahrb-solo-wrap table.dokan-table th,.wahrb-solo-wrap table.dokan-table td{padding:8px 10px;border:1px solid #c3c4c7;text-align:left}
.wahrb-solo-wrap table.dokan-table th{background:#f0f0f1}
';
    }

    /**
     * Render dashboard page — combined landing page with quick stats + navigation
     */
    public function render_dashboard_page(): void {
        $stats = $this->get_vendor_stats(get_current_user_id());
        $currency_symbol = html_entity_decode(get_woocommerce_currency_symbol(), ENT_QUOTES, 'UTF-8');
        ?>
        <div class="wrap wahrb-solo-wrap">
            <h1><?php esc_html_e('Rentals Dashboard', 'wahra-rentals-bookings'); ?></h1>

            <div class="wahrb-dashboard-grid" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:16px;margin:24px 0;">
                <div class="wahrb-dash-card" style="background:#fff;border:1px solid #c3c4c7;border-left:4px solid #f0c33c;padding:16px;border-radius:4px;">
                    <div style="font-size:28px;font-weight:700;color:#1d2327;"><?php echo esc_html($stats['pending']); ?></div>
                    <div style="color:#50575e;margin-top:4px;"><?php esc_html_e('Pending Bookings', 'wahra-rentals-bookings'); ?></div>
                </div>
                <div class="wahrb-dash-card" style="background:#fff;border:1px solid #c3c4c7;border-left:4px solid #00a32a;padding:16px;border-radius:4px;">
                    <div style="font-size:28px;font-weight:700;color:#1d2327;"><?php echo esc_html($stats['confirmed']); ?></div>
                    <div style="color:#50575e;margin-top:4px;"><?php esc_html_e('Confirmed Bookings', 'wahra-rentals-bookings'); ?></div>
                </div>
                <div class="wahrb-dash-card" style="background:#fff;border:1px solid #c3c4c7;border-left:4px solid #2271b1;padding:16px;border-radius:4px;">
                    <div style="font-size:28px;font-weight:700;color:#1d2327;"><?php echo esc_html($stats['active']); ?></div>
                    <div style="color:#50575e;margin-top:4px;"><?php esc_html_e('Active Rentals', 'wahra-rentals-bookings'); ?></div>
                </div>
                <div class="wahrb-dash-card" style="background:#fff;border:1px solid #c3c4c7;border-left:4px solid #8c6dbf;padding:16px;border-radius:4px;">
                    <div style="font-size:28px;font-weight:700;color:#1d2327;"><?php echo esc_html($currency_symbol . ' ' . number_format((float) $stats['revenue_month'], 2)); ?></div>
                    <div style="color:#50575e;margin-top:4px;"><?php esc_html_e('Revenue (This Month)', 'wahra-rentals-bookings'); ?></div>
                </div>
            </div>

            <div class="wahrb-dashboard-nav" style="display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;margin:24px 0;">
                <a href="<?php echo esc_url(admin_url('admin.php?page=wahrb-bookings')); ?>" class="wahrb-nav-card" style="display:flex;align-items:center;gap:12px;padding:16px 20px;background:#fff;border:1px solid #c3c4c7;border-radius:4px;text-decoration:none;color:#1d2327;transition:border-color .2s;">
                    <span class="dashicons dashicons-list-view" style="font-size:24px;color:#2271b1;"></span>
                    <span style="font-weight:600;"><?php esc_html_e('Bookings', 'wahra-rentals-bookings'); ?></span>
                </a>
                <a href="<?php echo esc_url(admin_url('admin.php?page=wahrb-wizard')); ?>" class="wahrb-nav-card" style="display:flex;align-items:center;gap:12px;padding:16px 20px;background:#fff;border:1px solid #c3c4c7;border-radius:4px;text-decoration:none;color:#1d2327;transition:border-color .2s;">
                    <span class="dashicons dashicons-plus-alt" style="font-size:24px;color:#00a32a;"></span>
                    <span style="font-weight:600;"><?php esc_html_e('Rental Wizard', 'wahra-rentals-bookings'); ?></span>
                </a>
                <a href="<?php echo esc_url(admin_url('admin.php?page=wahrb-calendar')); ?>" class="wahrb-nav-card" style="display:flex;align-items:center;gap:12px;padding:16px 20px;background:#fff;border:1px solid #c3c4c7;border-radius:4px;text-decoration:none;color:#1d2327;transition:border-color .2s;">
                    <span class="dashicons dashicons-calendar-alt" style="font-size:24px;color:#d63638;"></span>
                    <span style="font-weight:600;"><?php esc_html_e('Calendar', 'wahra-rentals-bookings'); ?></span>
                </a>
                <a href="<?php echo esc_url(admin_url('admin.php?page=wahrb-analytics')); ?>" class="wahrb-nav-card" style="display:flex;align-items:center;gap:12px;padding:16px 20px;background:#fff;border:1px solid #c3c4c7;border-radius:4px;text-decoration:none;color:#1d2327;transition:border-color .2s;">
                    <span class="dashicons dashicons-chart-area" style="font-size:24px;color:#8c6dbf;"></span>
                    <span style="font-weight:600;"><?php esc_html_e('Statistics', 'wahra-rentals-bookings'); ?></span>
                </a>
                <a href="<?php echo esc_url(admin_url('admin.php?page=wahrb-settings')); ?>" class="wahrb-nav-card" style="display:flex;align-items:center;gap:12px;padding:16px 20px;background:#fff;border:1px solid #c3c4c7;border-radius:4px;text-decoration:none;color:#1d2327;transition:border-color .2s;">
                    <span class="dashicons dashicons-admin-generic" style="font-size:24px;color:#50575e;"></span>
                    <span style="font-weight:600;"><?php esc_html_e('Settings', 'wahra-rentals-bookings'); ?></span>
                </a>
                <a href="<?php echo esc_url(admin_url('admin.php?page=wahrb-vendor-settings')); ?>" class="wahrb-nav-card" style="display:flex;align-items:center;gap:12px;padding:16px 20px;background:#fff;border:1px solid #c3c4c7;border-radius:4px;text-decoration:none;color:#1d2327;transition:border-color .2s;">
                    <span class="dashicons dashicons-art" style="font-size:24px;color:#e65100;"></span>
                    <span style="font-weight:600;"><?php esc_html_e('Visual', 'wahra-rentals-bookings'); ?></span>
                </a>
            </div>
        </div>
        <?php
    }

    /**
     * Render bookings page — vendor bookings list with full lifecycle management
     */
    public function render_bookings_page(): void {
        echo '<div class="wrap wahrb-solo-wrap">';
        echo '<h1>' . esc_html__('Bookings', 'wahra-rentals-bookings') . '</h1>';
        include WAHRB_PLUGIN_DIR . 'templates/dokan/bookings-list.php';
        echo '</div>';
    }

    /**
     * Render wizard page
     */
    public function render_wizard_page(): void {
        echo '<div class="wrap wahrb-solo-wrap">';
        echo '<h1>' . esc_html__('Rental Wizard', 'wahra-rentals-bookings') . '</h1>';
        include WAHRB_PLUGIN_DIR . 'templates/dokan/booking-wizard.php';
        echo '</div>';
    }

    /**
     * Render calendar page
     */
    public function render_calendar_page(): void {
        echo '<div class="wrap wahrb-solo-wrap">';
        echo '<h1>' . esc_html__('Calendar', 'wahra-rentals-bookings') . '</h1>';
        include WAHRB_PLUGIN_DIR . 'templates/dokan/calendar.php';
        echo '</div>';
    }

    /**
     * Render analytics page — admin analytics with AJAX, period filters, KPIs, Chart.js
     */
    public function render_analytics_page(): void {
        wp_enqueue_style(
            'wahrb-admin-analytics',
            WAHRB_PLUGIN_URL . 'assets/css/wahrb-admin-analytics.css',
            [],
            WAHRB_VERSION
        );
        wp_enqueue_script(
            'chartjs',
            WAHRB_PLUGIN_URL . 'assets/vendor/chartjs/chart.min.js',
            [],
            '4.5.1',
            true
        );
        include WAHRB_PLUGIN_DIR . 'templates/admin/analytics.php';
    }

    /**
     * Render vendor settings page (Visual — visual customization only)
     */
    public function render_settings_page(): void {
        echo '<div class="wrap wahrb-solo-wrap">';
        echo '<h1>' . esc_html__('Visual', 'wahra-rentals-bookings') . '</h1>';
        include WAHRB_PLUGIN_DIR . 'templates/dokan/visual-settings.php';
        echo '</div>';
    }

    /**
     * Render admin settings page (full platform configuration)
     */
    public function render_admin_settings_page(): void {
        include WAHRB_PLUGIN_DIR . 'templates/admin/settings.php';
    }

    /**
     * Render form builder page — dedicated submenu page for Solo mode
     *
     * Enqueues SortableJS + form builder assets, then includes the shared
     * form-builder-ui.php partial with role='admin'.
     */
    public function render_form_builder_page(): void {
        // Enqueue form builder assets (SortableJS + CSS/JS)
        wp_enqueue_script(
            'sortablejs',
            WAHRB_PLUGIN_URL . 'assets/vendor/sortablejs/Sortable.min.js',
            [],
            '1.15.6',
            true
        );

        wp_enqueue_style(
            'wahrb-form-builder-css',
            WAHRB_PLUGIN_URL . 'assets/css/wahrb-form-builder.css',
            [],
            WAHRB_VERSION
        );

        wp_enqueue_script(
            'wahrb-form-builder-js',
            WAHRB_PLUGIN_URL . 'assets/js/wahrb-form-builder.js',
            ['sortablejs'],
            WAHRB_VERSION,
            true
        );

        echo '<div class="wrap">';
        echo '<h1>' . esc_html__('Form Builder', 'wahra-rentals-bookings') . '</h1>';
        echo '<p class="description" style="margin-bottom: 20px;">';
        esc_html_e('Create and manage custom booking form templates for your products.', 'wahra-rentals-bookings');
        echo '</p>';

        $role = 'admin';
        include WAHRB_PLUGIN_DIR . 'templates/admin/partials/form-builder-ui.php';

        echo '</div>';
    }

    /**
     * Render booking detail page — Solo mode wraps vendor template in admin wrapper
     *
     * In Solo mode, the site owner is both admin and vendor.
     * This uses the vendor-facing booking-detail template (Dokan-style)
     * wrapped in the WP admin wrapper div, just like other Solo pages.
     */
    public function render_booking_detail_page(): void {
        echo '<div class="wrap wahrb-solo-wrap">';
        echo '<h1>' . esc_html__('Booking Detail', 'wahra-rentals-bookings') . '</h1>';
        include WAHRB_PLUGIN_DIR . 'templates/dokan/booking-detail.php';
        echo '</div>';
    }

    /**
     * Enqueue wizard assets
     */
    private function enqueue_wizard_assets(): void {
        $vendor_id = get_current_user_id();

        // Ensure WordPress Media is available
        if (!did_action('wp_enqueue_media')) {
            wp_enqueue_media();
        }

        // PHP multi-step wizard styles and scripts
        $php_js_path = WAHRB_PLUGIN_DIR . 'assets/js/wahrb-wizard-php.js';
        $steps_js_path = WAHRB_PLUGIN_DIR . 'assets/js/wahrb-wizard-steps.js';
        $php_js_ver = WAHRB_VERSION . '.' . (file_exists($php_js_path) ? filemtime($php_js_path) : '0');
        $steps_js_ver = WAHRB_VERSION . '.' . (file_exists($steps_js_path) ? filemtime($steps_js_path) : '0');

        wp_enqueue_style('wahrb-wizard-php', WAHRB_PLUGIN_URL . 'assets/css/wizard-php.css', [], WAHRB_VERSION);

        wp_enqueue_script(
            'wahrb-wizard-php-js',
            WAHRB_PLUGIN_URL . 'assets/js/wahrb-wizard-php.js',
            [],
            $php_js_ver,
            true
        );

        wp_enqueue_script(
            'wahrb-wizard-steps',
            WAHRB_PLUGIN_URL . 'assets/js/wahrb-wizard-steps.js',
            [],
            $steps_js_ver,
            true
        );

        // Check if Vite-built assets exist
        $wizard_js_path = WAHRB_PLUGIN_DIR . 'assets/js/wizard.js';

        if (file_exists($wizard_js_path)) {
            wp_enqueue_script(
                'wahrb-wizard-app',
                WAHRB_PLUGIN_URL . 'assets/js/wizard.js',
                [],
                WAHRB_VERSION,
                true
            );

            wp_enqueue_script(
                'wahrb-wizard-validation',
                WAHRB_PLUGIN_URL . 'assets/js/wizard-validation.js',
                ['jquery'],
                WAHRB_VERSION,
                true
            );

            // Add type="module" attribute for ES module support
            add_filter('script_loader_tag', function($tag, $handle, $src) {
                if ($handle === 'wahrb-wizard-app') {
                    $tag = str_replace('<script ', '<script type="module" ', $tag);
                }
                return $tag;
            }, 10, 3);

            // Localize script with config
            wp_localize_script('wahrb-wizard-app', 'wahrbWizardConfig', [
                'apiUrl' => untrailingslashit(rest_url('wahrb/v1')),
                'nonce' => wp_create_nonce('wp_rest'),
                'vendorId' => $vendor_id,
                'locale' => str_replace('_', '-', get_user_locale()),
                'currency' => get_woocommerce_currency(),
                'currencySymbol' => html_entity_decode(get_woocommerce_currency_symbol(), ENT_QUOTES, 'UTF-8'),
                'timeFormat' => get_option('time_format'),
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Navigational parameter
                'productId' => isset($_GET['product_id']) ? absint(wp_unslash($_GET['product_id'])) : null,
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Navigational parameter
                'draftId' => isset($_GET['draft_id']) ? absint(wp_unslash($_GET['draft_id'])) : null,
                'settings' => $this->get_vendor_settings($vendor_id),
                'strings' => WAHRB_Solo_Integration::get_wizard_strings(),
                'serviceTypes' => $this->get_service_types_config(),
                'categories' => $this->get_wizard_categories(),
                'platformCategories' => WAHRB_Platform_Categories::get_js_config(),
                'mode' => 'solo', // Let the wizard know we're in solo mode
            ]);
        }
    }

    /**
     * Enqueue calendar assets
     */
    private function enqueue_calendar_assets(): void {
        wp_enqueue_style(
            'fullcalendar',
            WAHRB_PLUGIN_URL . 'assets/vendor/fullcalendar/fullcalendar.min.css',
            [],
            '6.1.20'
        );

        wp_enqueue_script(
            'fullcalendar',
            WAHRB_PLUGIN_URL . 'assets/vendor/fullcalendar/fullcalendar.min.js',
            [],
            '6.1.20',
            true
        );

        wp_enqueue_script(
            'fullcalendar-locales',
            WAHRB_PLUGIN_URL . 'assets/vendor/fullcalendar/locales-all.min.js',
            ['fullcalendar'],
            '6.1.20',
            true
        );

        wp_enqueue_style(
            'wahrb-calendar-styles',
            WAHRB_PLUGIN_URL . 'assets/css/wahrb-calendar.css',
            ['fullcalendar'],
            WAHRB_VERSION
        );

        wp_enqueue_script(
            'wahrb-calendar-script',
            WAHRB_PLUGIN_URL . 'assets/js/wahrb-calendar.js',
            ['fullcalendar', 'fullcalendar-locales'],
            WAHRB_VERSION,
            true
        );
    }

    /**
     * Add product data tab for rental configuration
     *
     * @param array $tabs Product data tabs
     * @return array Modified tabs
     */
    public function add_product_data_tab(array $tabs): array {
        $tabs['wahrb_rental'] = [
            'label' => __('Rental', 'wahra-rentals-bookings'),
            'target' => 'wahrb_rental_data',
            'class' => ['show_if_simple', 'show_if_variable'],
            'priority' => 75,
        ];
        return $tabs;
    }

    /**
     * Render product data panel for rental configuration
     */
    public function render_product_data_panel(): void {
        global $post;
        $post_id = $post->ID;

        $rental_enabled = get_post_meta($post_id, '_wahrb_rental_enabled', true);
        $booking_mode = get_post_meta($post_id, '_wahrb_booking_mode', true) ?: 'day';
        $base_price = get_post_meta($post_id, '_wahrb_base_price', true);
        $security_deposit = get_post_meta($post_id, '_wahrb_security_deposit', true);
        $total_units = get_post_meta($post_id, '_wahrb_total_units', true) ?: 1;
        $min_duration = get_post_meta($post_id, '_wahrb_min_duration', true) ?: 1;
        $max_duration = get_post_meta($post_id, '_wahrb_max_duration', true) ?: 365;
        ?>
        <div id="wahrb_rental_data" class="panel woocommerce_options_panel">
            <?php wp_nonce_field('wahrb_save_rental_fields', '_wahrb_rental_nonce'); ?>

            <?php
            woocommerce_wp_checkbox([
                'id' => '_wahrb_rental_enabled',
                'label' => __('Enable rental', 'wahra-rentals-bookings'),
                'description' => __('Enable rental booking for this product', 'wahra-rentals-bookings'),
                'value' => $rental_enabled,
            ]);
            ?>

            <p class="form-field">
                <a href="<?php echo esc_url(wahrb_get_admin_dashboard_url('wizard', ['product_id' => $post_id])); ?>" class="button button-secondary">
                    <span class="dashicons dashicons-admin-generic" style="vertical-align:middle;margin-right:4px"></span>
                    <?php esc_html_e('Configure with wizard', 'wahra-rentals-bookings'); ?>
                </a>
                <span class="description"><?php esc_html_e('Use the interactive wizard to configure rental settings.', 'wahra-rentals-bookings'); ?></span>
            </p>

            <?php
            woocommerce_wp_select([
                'id' => '_wahrb_booking_mode',
                'label' => __('Booking mode', 'wahra-rentals-bookings'),
                'options' => [
                    'day' => __('Daily rental', 'wahra-rentals-bookings'),
                    'slot' => __('Time slot rental (hourly)', 'wahra-rentals-bookings'),
                    'service' => __('Service (appointment)', 'wahra-rentals-bookings'),
                ],
                'value' => $booking_mode,
            ]);

            woocommerce_wp_text_input([
                'id' => '_wahrb_base_price',
                'label' => sprintf(
                    /* translators: %s: currency symbol */
                    __('Base price (%s)', 'wahra-rentals-bookings'),
                    get_woocommerce_currency_symbol()
                ),
                'type' => 'number',
                'custom_attributes' => ['step' => '0.01', 'min' => '0'],
                'value' => $base_price,
            ]);

            woocommerce_wp_text_input([
                'id' => '_wahrb_security_deposit',
                'label' => sprintf(
                    /* translators: %s: currency symbol */
                    __('Security deposit (%s)', 'wahra-rentals-bookings'),
                    get_woocommerce_currency_symbol()
                ),
                'type' => 'number',
                'custom_attributes' => ['step' => '0.01', 'min' => '0'],
                'value' => $security_deposit,
                'description' => __('Optional security deposit amount', 'wahra-rentals-bookings'),
            ]);

            woocommerce_wp_text_input([
                'id' => '_wahrb_total_units',
                'label' => __('Available units', 'wahra-rentals-bookings'),
                'type' => 'number',
                'custom_attributes' => ['step' => '1', 'min' => '1'],
                'value' => $total_units,
            ]);

            woocommerce_wp_text_input([
                'id' => '_wahrb_min_duration',
                'label' => __('Minimum duration (days)', 'wahra-rentals-bookings'),
                'type' => 'number',
                'custom_attributes' => ['step' => '1', 'min' => '1'],
                'value' => $min_duration,
            ]);

            woocommerce_wp_text_input([
                'id' => '_wahrb_max_duration',
                'label' => __('Maximum duration (days)', 'wahra-rentals-bookings'),
                'type' => 'number',
                'custom_attributes' => ['step' => '1', 'min' => '1'],
                'value' => $max_duration,
            ]);

            // ── Form Template selector ──
            $form_builder_settings = get_option('wahrb_settings_form_builder', ['enabled' => false]);
            if (!empty($form_builder_settings['enabled'])) {
                $form_builder = WAHRB_Form_Builder::instance();
                $all_templates = $form_builder->get_templates(['is_active' => true]);
                $current_template_id = (int) get_post_meta($post_id, '_wahrb_form_template_id', true);

                $template_options = [
                    '0'  => __('Auto (cascade resolution)', 'wahra-rentals-bookings'),
                    '-1' => __('None (no customer form)', 'wahra-rentals-bookings'),
                ];
                foreach ($all_templates as $tpl) {
                    $scope_label = ucfirst($tpl['scope'] ?? 'global');
                    $template_options[(string) $tpl['id']] = sprintf('%s [%s]', $tpl['name'], $scope_label);
                }

                woocommerce_wp_select([
                    'id' => '_wahrb_form_template_id',
                    'label' => __('Customer form', 'wahra-rentals-bookings'),
                    'description' => __('Select which form template customers must fill when booking this product. "Auto" uses the cascade resolution (product → vendor → category → global).', 'wahra-rentals-bookings'),
                    'desc_tip' => true,
                    'options' => $template_options,
                    'value' => (string) $current_template_id,
                ]);
            }
            ?>
        </div>
        <?php
    }

    /**
     * Save product rental fields from WooCommerce product edit
     *
     * @param int $post_id Product ID
     */
    public function save_product_rental_fields(int $post_id): void {
        // Verify nonce
        if (!isset($_POST['_wahrb_rental_nonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wahrb_rental_nonce'])), 'wahrb_save_rental_fields')) {
            return;
        }

        $fields = [
            '_wahrb_rental_enabled' => isset($_POST['_wahrb_rental_enabled']) ? 'yes' : 'no',
            '_wahrb_booking_mode' => isset($_POST['_wahrb_booking_mode']) ? sanitize_text_field(wp_unslash($_POST['_wahrb_booking_mode'])) : 'day',
            '_wahrb_base_price' => isset($_POST['_wahrb_base_price']) ? wc_format_decimal(sanitize_text_field(wp_unslash($_POST['_wahrb_base_price']))) : '',
            '_wahrb_security_deposit' => isset($_POST['_wahrb_security_deposit']) ? wc_format_decimal(sanitize_text_field(wp_unslash($_POST['_wahrb_security_deposit']))) : '',
            '_wahrb_total_units' => isset($_POST['_wahrb_total_units']) ? absint(wp_unslash($_POST['_wahrb_total_units'])) : 1,
            '_wahrb_min_duration' => isset($_POST['_wahrb_min_duration']) ? absint(wp_unslash($_POST['_wahrb_min_duration'])) : 1,
            '_wahrb_max_duration' => isset($_POST['_wahrb_max_duration']) ? absint(wp_unslash($_POST['_wahrb_max_duration'])) : 365,
            '_wahrb_form_template_id' => isset($_POST['_wahrb_form_template_id']) ? intval(wp_unslash($_POST['_wahrb_form_template_id'])) : 0,
        ];

        foreach ($fields as $key => $value) {
            update_post_meta($post_id, $key, $value);
        }
    }

    /**
     * Add WP Dashboard widget for booking stats
     */
    public function add_dashboard_widget(): void {
        if (!current_user_can('manage_woocommerce')) {
            return;
        }

        wp_add_dashboard_widget(
            'wahrb_bookings_widget',
            __('Rentals & Bookings', 'wahra-rentals-bookings'),
            [$this, 'render_dashboard_widget']
        );
    }

    /**
     * Render WP Dashboard widget
     */
    public function render_dashboard_widget(): void {
        $vendor_id = get_current_user_id();
        $stats = $this->get_vendor_stats($vendor_id);
        ?>
        <div class="wahrb-wp-widget">
            <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:10px;margin-bottom:15px">
                <div style="text-align:center;padding:10px;background:#fff8e1;border-radius:6px">
                    <div style="font-size:22px;font-weight:700;color:#d97706"><?php echo esc_html($stats['pending']); ?></div>
                    <div style="font-size:11px;color:#92400e"><?php esc_html_e('Pending', 'wahra-rentals-bookings'); ?></div>
                </div>
                <div style="text-align:center;padding:10px;background:#ecfdf5;border-radius:6px">
                    <div style="font-size:22px;font-weight:700;color:#059669"><?php echo esc_html($stats['confirmed']); ?></div>
                    <div style="font-size:11px;color:#065f46"><?php esc_html_e('Confirmed', 'wahra-rentals-bookings'); ?></div>
                </div>
                <div style="text-align:center;padding:10px;background:#eff6ff;border-radius:6px">
                    <div style="font-size:22px;font-weight:700;color:#0284c7"><?php echo esc_html($stats['active']); ?></div>
                    <div style="font-size:11px;color:#1e40af"><?php esc_html_e('In progress', 'wahra-rentals-bookings'); ?></div>
                </div>
            </div>
            <div style="text-align:center;padding:10px;background:linear-gradient(135deg,#fff7ed,#fef3c7);border-radius:6px;margin-bottom:15px">
                <div style="font-size:16px;font-weight:700;color:#f05025"><?php echo wp_kses_post(wc_price($stats['revenue_month'])); ?></div>
                <div style="font-size:11px;color:#92400e"><?php esc_html_e('Revenue this month', 'wahra-rentals-bookings'); ?></div>
            </div>
            <div style="display:flex;gap:8px">
                <a href="<?php echo esc_url(wahrb_get_admin_dashboard_url('bookings')); ?>" class="button button-primary" style="flex:1;text-align:center">
                    <?php esc_html_e('View bookings', 'wahra-rentals-bookings'); ?>
                </a>
                <a href="<?php echo esc_url(wahrb_get_admin_dashboard_url('wizard')); ?>" class="button" style="flex:1;text-align:center">
                    <?php esc_html_e('New listing', 'wahra-rentals-bookings'); ?>
                </a>
            </div>
        </div>
        <?php
    }

    /**
     * Get vendor settings (same logic as Dokan integration)
     *
     * @param int $vendor_id Vendor ID
     * @return array Settings
     */
    private function get_vendor_settings(int $vendor_id): array {
        $general_settings = get_option('wahrb_settings_general', []);
        $booking_settings = get_option('wahrb_settings_booking', []);
        $payment_settings = get_option('wahrb_settings_payment', []);
        $notification_settings = get_option('wahrb_settings_notifications', []);

        $pricing_rules = [];
        $enabled = WAHRB_Platform_Categories::get_enabled();
        foreach ($enabled as $slug => $cat) {
            $pricing_rules[$slug] = WAHRB_Platform_Categories::get_category_pricing($slug);
        }

        $vendor_overrides = get_user_meta($vendor_id, '_wahrb_vendor_settings', true) ?: [];
        $payment_by_category = WAHRB_Platform_Categories::get_all_payment_settings();

        $permissions_by_category = [];
        foreach ($enabled as $slug => $cat) {
            $permissions_by_category[$slug] = WAHRB_Platform_Categories::get_vendor_permissions($slug);
        }

        $vendor_permissions = get_option('wahrb_settings_vendor_permissions', []);
        $require_approval = !empty($vendor_permissions['require_approval']);

        $settings = [
            'timezone' => $general_settings['timezone'] ?? wp_timezone_string(),
            'wizard_welcome_text' => $general_settings['wizard_welcome_text'] ?? '',
            'date_format' => $general_settings['date_format'] ?? 'Y-m-d',
            'time_format' => $general_settings['time_format'] ?? '24h',
            'terms_url' => $general_settings['terms_url'] ?? '',
            'vendor_consent_text' => $general_settings['vendor_consent_text'] ?? __('I accept the terms and conditions', 'wahra-rentals-bookings'),
            'terms_required' => $general_settings['terms_required'] ?? true,
            'payment_by_category' => $payment_by_category,
            'min_booking_window_hours' => $booking_settings['min_booking_window_hours'] ?? 24,
            'max_booking_window_days' => $booking_settings['max_booking_window_days'] ?? 365,
            'buffer_before_hours' => $booking_settings['buffer_before_hours'] ?? 0,
            'buffer_after_hours' => $booking_settings['buffer_after_hours'] ?? 0,
            'default_min_stay_days' => $booking_settings['default_min_stay_days'] ?? 1,
            'default_max_stay_days' => $booking_settings['default_max_stay_days'] ?? 30,
            'hold_duration_minutes' => $booking_settings['hold_duration_minutes'] ?? 30,
            'balance_reminder_days' => $notification_settings['balance_reminder_days'] ?? 3,
            'pricing_rules' => $pricing_rules,
            'permissions_by_category' => $permissions_by_category,
            'require_approval' => $require_approval,
            'currency_symbol' => !empty($general_settings['currency_symbol']) ? $general_settings['currency_symbol'] : html_entity_decode(get_woocommerce_currency_symbol(), ENT_QUOTES, 'UTF-8'),
            'currency_position' => $general_settings['currency_position'] ?? 'before',
        ];

        // Allow vendor overrides
        if (!empty($vendor_overrides)) {
            foreach ($payment_by_category as $cat_slug => $cat_pay) {
                $cat_perms = $permissions_by_category[$cat_slug] ?? [];
                if (!empty($cat_perms['can_set_deposit_amount']) && isset($vendor_overrides["deposit_value_{$cat_slug}"])) {
                    $settings['payment_by_category'][$cat_slug]['deposit_value'] = $vendor_overrides["deposit_value_{$cat_slug}"];
                }
            }
        }

        return $settings;
    }

    /**
     * Get service types configuration
     *
     * @return array
     */
    private function get_service_types_config(): array {
        $enabled = WAHRB_Platform_Categories::get_enabled();
        $modes = [];
        foreach ($enabled as $slug => $cat) {
            foreach ($cat['booking_modes'] as $mode) {
                if (!isset($modes[$mode])) {
                    $modes[$mode] = ['title' => '', 'description' => ''];
                }
            }
        }
        $mode_defaults = [
            'day' => [
                'title' => __('Daily rental', 'wahra-rentals-bookings'),
                'description' => __('Reservation by full day', 'wahra-rentals-bookings'),
            ],
            'slot' => [
                'title' => __('Time slot booking', 'wahra-rentals-bookings'),
                'description' => __('Reservation on specific time slots', 'wahra-rentals-bookings'),
            ],
            'service' => [
                'title' => __('One-time service', 'wahra-rentals-bookings'),
                'description' => __('Single service on a specific date', 'wahra-rentals-bookings'),
            ],
            'product' => [
                'title' => __('Physical Product', 'wahra-rentals-bookings'),
                'description' => __('Product sale without reservation', 'wahra-rentals-bookings'),
            ],
        ];
        foreach ($modes as $mode => &$data) {
            if (isset($mode_defaults[$mode])) {
                $data = $mode_defaults[$mode];
            }
        }
        unset($data);

        $legacy = get_option('wahrb_settings_service_types', []);
        foreach ($legacy as $key => $config) {
            if (!empty($config['enabled']) && isset($modes[$key])) {
                if (!empty($config['title'])) {
                    $modes[$key]['title'] = $config['title'];
                }
                if (!empty($config['description'])) {
                    $modes[$key]['description'] = $config['description'];
                }
            }
        }

        return $modes;
    }

    /**
     * Get enabled categories for wizard
     *
     * @return array
     */
    private function get_wizard_categories(): array {
        $enabled = WAHRB_Platform_Categories::get_enabled();
        $settings = WAHRB_Platform_Categories::get_settings();
        $result = [];

        foreach ($enabled as $slug => $cat) {
            $cat_settings = $settings[$slug] ?? [];
            foreach ($cat['subcategories'] as $sub_slug => $sub_label) {
                if (!empty($cat_settings['subcategories'][$sub_slug])) {
                    $result[] = [
                        'id' => $sub_slug,
                        'label' => $sub_label,
                        'group' => $cat['label'],
                        'category' => $slug,
                    ];
                }
            }
        }

        return $result;
    }

    /**
     * Get vendor booking stats
     *
     * @param int $vendor_id Vendor ID (in solo mode, this is the site admin)
     * @return array Stats
     */
    private function get_vendor_stats(int $vendor_id): array {
        global $wpdb;
        $table = $wpdb->prefix . 'wahrb_bookings';

        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter
        if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) !== $table) {
            return ['pending' => 0, 'confirmed' => 0, 'active' => 0, 'revenue_month' => 0];
        }

        // In solo mode, get ALL bookings (not filtered by vendor_id)
        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
        $pending = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$table} WHERE status = 'pending' AND deleted_at IS NULL");

        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
        $confirmed = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$table} WHERE status = 'confirmed' AND deleted_at IS NULL");

        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
        $active = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$table} WHERE status IN ('checked_in') AND deleted_at IS NULL");

        // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, PluginCheck.Security.DirectDB.UnescapedDBParameter, WordPress.DB.PreparedSQL.InterpolatedNotPrepared
        $revenue_month = (float) $wpdb->get_var("SELECT COALESCE(SUM(JSON_EXTRACT(pricing_snapshot, '$.total')), 0) FROM {$table} WHERE status IN ('confirmed', 'checked_in', 'checked_out', 'completed') AND MONTH(created_at) = MONTH(CURRENT_DATE()) AND YEAR(created_at) = YEAR(CURRENT_DATE()) AND deleted_at IS NULL");

        return [
            'pending' => $pending,
            'confirmed' => $confirmed,
            'active' => $active,
            'revenue_month' => $revenue_month,
        ];
    }

    /**
     * Get wizard strings for i18n (static so it can be shared)
     *
     * @return array Translated strings
     */
    public static function get_wizard_strings(): array {
        return [
            'next' => __('Next', 'wahra-rentals-bookings'),
            'previous' => __('Previous', 'wahra-rentals-bookings'),
            'save' => __('Save', 'wahra-rentals-bookings'),
            'publish' => __('Publish', 'wahra-rentals-bookings'),
            'saveDraft' => __('Save Draft', 'wahra-rentals-bookings'),
            'cancel' => __('Cancel', 'wahra-rentals-bookings'),
            'loading' => __('Loading...', 'wahra-rentals-bookings'),
            'error' => __('Error', 'wahra-rentals-bookings'),
            'success' => __('Success', 'wahra-rentals-bookings'),
            'step0Title' => __('Rental Wizard', 'wahra-rentals-bookings'),
            'step0Subtitle' => __('Follow the steps to publish your rental listing', 'wahra-rentals-bookings'),
            'createNew' => __('New item to rent', 'wahra-rentals-bookings'),
            'editExisting' => __('Edit existing product', 'wahra-rentals-bookings'),
            'continueDraft' => __('Resume a draft', 'wahra-rentals-bookings'),
            'step1Title' => __('Offer type', 'wahra-rentals-bookings'),
            'dayRental' => __('Rental (Day)', 'wahra-rentals-bookings'),
            'dayRentalDesc' => __('Rent by day (bike, tools...)', 'wahra-rentals-bookings'),
            'slotRental' => __('Rental (Slots)', 'wahra-rentals-bookings'),
            'slotRentalDesc' => __('Rent by time slot (classes, rooms...)', 'wahra-rentals-bookings'),
            'service' => __('Service', 'wahra-rentals-bookings'),
            'serviceDesc' => __('One-time or appointment-based services', 'wahra-rentals-bookings'),
            'step2Title' => __('Inventory & Product', 'wahra-rentals-bookings'),
            'productName' => __('Product name', 'wahra-rentals-bookings'),
            'productDescription' => __('Description', 'wahra-rentals-bookings'),
            'isVariable' => __('Variable product (multiple sizes/colors)', 'wahra-rentals-bookings'),
            'variations' => __('Variations', 'wahra-rentals-bookings'),
            'availableUnits' => __('Available units', 'wahra-rentals-bookings'),
            'enableForRental' => __('Enable for rental', 'wahra-rentals-bookings'),
            'step3Title' => __('Availability', 'wahra-rentals-bookings'),
            'recurrence' => __('Available days', 'wahra-rentals-bookings'),
            'allDays' => __('Every day', 'wahra-rentals-bookings'),
            'weekdays' => __('Monday to Friday', 'wahra-rentals-bookings'),
            'weekends' => __('Saturday and Sunday', 'wahra-rentals-bookings'),
            'custom' => __('Custom', 'wahra-rentals-bookings'),
            'monday' => __('Mon', 'wahra-rentals-bookings'),
            'tuesday' => __('Tue', 'wahra-rentals-bookings'),
            'wednesday' => __('Wed', 'wahra-rentals-bookings'),
            'thursday' => __('Thu', 'wahra-rentals-bookings'),
            'friday' => __('Fri', 'wahra-rentals-bookings'),
            'saturday' => __('Sat', 'wahra-rentals-bookings'),
            'sunday' => __('Sun', 'wahra-rentals-bookings'),
            'blackoutDates' => __('Unavailable dates', 'wahra-rentals-bookings'),
            'addBlackout' => __('Add period', 'wahra-rentals-bookings'),
            'constraints' => __('Booking constraints', 'wahra-rentals-bookings'),
            'minBookingWindow' => __('Minimum booking window (days)', 'wahra-rentals-bookings'),
            'maxBookingWindow' => __('Maximum booking window (days)', 'wahra-rentals-bookings'),
            'minStay' => __('Minimum duration (days)', 'wahra-rentals-bookings'),
            'maxStay' => __('Maximum duration (days)', 'wahra-rentals-bookings'),
            'bufferBefore' => __('Preparation time (hours)', 'wahra-rentals-bookings'),
            'bufferAfter' => __('Cleaning time (hours)', 'wahra-rentals-bookings'),
            'step4Title' => __('Pricing', 'wahra-rentals-bookings'),
            'basePrice' => __('Base price', 'wahra-rentals-bookings'),
            'perDay' => __('per day', 'wahra-rentals-bookings'),
            'perHour' => __('per hour', 'wahra-rentals-bookings'),
            'pricingRules' => __('Pricing rules', 'wahra-rentals-bookings'),
            'addRule' => __('Add rule', 'wahra-rentals-bookings'),
            'ruleName' => __('Rule name', 'wahra-rentals-bookings'),
            'ruleType' => __('Type', 'wahra-rentals-bookings'),
            'dateRange' => __('Date range', 'wahra-rentals-bookings'),
            'weekday' => __('Weekday', 'wahra-rentals-bookings'),
            'duration' => __('Duration', 'wahra-rentals-bookings'),
            'modifier' => __('Modifier', 'wahra-rentals-bookings'),
            'fixed' => __('Fixed', 'wahra-rentals-bookings'),
            'percent' => __('Percentage', 'wahra-rentals-bookings'),
            'priority' => __('Priority', 'wahra-rentals-bookings'),
            'pricePreview' => __('Price preview', 'wahra-rentals-bookings'),
            'step5Title' => __('Payments', 'wahra-rentals-bookings'),
            'deposit' => __('Deposit', 'wahra-rentals-bookings'),
            'depositEnabled' => __('Request deposit at booking', 'wahra-rentals-bookings'),
            'depositAmount' => __('Deposit amount', 'wahra-rentals-bookings'),
            'depositRefundable' => __('Refundable on cancellation', 'wahra-rentals-bookings'),
            'securityDeposit' => __('Security deposit', 'wahra-rentals-bookings'),
            'securityEnabled' => __('Request security deposit', 'wahra-rentals-bookings'),
            'securityAmount' => __('Security deposit amount', 'wahra-rentals-bookings'),
            'captureMode' => __('Charge immediately', 'wahra-rentals-bookings'),
            'authMode' => __('Stripe authorization (hold without charge)', 'wahra-rentals-bookings'),
            'balance' => __('Balance', 'wahra-rentals-bookings'),
            'balanceEnabled' => __('Balance due before pickup', 'wahra-rentals-bookings'),
            'balanceDueDays' => __('Days before pickup', 'wahra-rentals-bookings'),
            'allowCod' => __('Allow payment on pickup', 'wahra-rentals-bookings'),
            'paymentSummary' => __('Payment summary', 'wahra-rentals-bookings'),
            'step6Title' => __('Photos', 'wahra-rentals-bookings'),
            'uploadImages' => __('Add photos', 'wahra-rentals-bookings'),
            'takePhoto' => __('Take photo', 'wahra-rentals-bookings'),
            'chooseFromGallery' => __('Choose from gallery', 'wahra-rentals-bookings'),
            'dragAndDrop' => __('Drag and drop images here', 'wahra-rentals-bookings'),
            'maxImages' => __('Maximum 10 images', 'wahra-rentals-bookings'),
            'imageCompressing' => __('Compressing...', 'wahra-rentals-bookings'),
            'step7Title' => __('Publication', 'wahra-rentals-bookings'),
            'cancellationPolicy' => __('Cancellation policy', 'wahra-rentals-bookings'),
            'flexible' => __('Flexible', 'wahra-rentals-bookings'),
            'flexibleDesc' => __('Free cancellation up to 24h before', 'wahra-rentals-bookings'),
            'moderate' => __('Moderate', 'wahra-rentals-bookings'),
            'moderateDesc' => __('50% refund up to 72h before', 'wahra-rentals-bookings'),
            'strict' => __('Strict', 'wahra-rentals-bookings'),
            'strictDesc' => __('Non-refundable after confirmation', 'wahra-rentals-bookings'),
            'acceptTerms' => __('I accept the terms and conditions', 'wahra-rentals-bookings'),
            'offerSummary' => __('Offer summary', 'wahra-rentals-bookings'),
            'publishSuccess' => __('Your product has been published successfully!', 'wahra-rentals-bookings'),
        ];
    }
}
