<?php
/**
 * Schema Types Configuration
 *
 * Defines all available schema types, their properties, and field mappings
 *
 * @package TamRank
 * @subpackage Schema
 */

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

/**
 * Get all available schema types with their configurations
 *
 * @return array Schema types configuration
 */
function tamrank_get_schema_types() {
    return array(
        'Article' => array(
            'label' => __('Article', 'tam-rank'),
            'description' => __( 'A standard article', 'tam-rank' ),
            'properties' => array(
                'headline' => array(
                    'label' => __('Headline', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'custom_field', 'manual')
                ),
                'author' => array(
                    'label' => __('Author', 'tam-rank'),
                    'required' => true,
                    'type' => 'person',
                    'sources' => array('author_name', 'author_url', 'custom_field')
                ),
                'datePublished' => array(
                    'label' => __('Date Published', 'tam-rank'),
                    'required' => true,
                    'type' => 'date',
                    'sources' => array('post_date', 'custom_field')
                ),
                'dateModified' => array(
                    'label' => __('Date Modified', 'tam-rank'),
                    'required' => false,
                    'type' => 'date',
                    'sources' => array('post_modified', 'custom_field')
                ),
                'publisher' => array(
                    'label' => __('Publisher', 'tam-rank'),
                    'required' => true,
                    'type' => 'organization',
                    'sources' => array('global_organization')
                ),
                'articleSection' => array(
                    'label' => __('Article Section', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('category', 'custom_field', 'manual')
                ),
                'wordCount' => array(
                    'label' => __('Word Count', 'tam-rank'),
                    'required' => false,
                    'type' => 'number',
                    'sources' => array('auto_wordcount', 'manual')
                ),
                'keywords' => array(
                    'label' => __('Keywords', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('tags', 'custom_field', 'manual')
                ),
                'mainEntityOfPage' => array(
                    'label' => __('Main Entity Of Page', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('post_url', 'manual')
                )
            )
        ),
        'NewsArticle' => array(
            'label' => __('News Article', 'tam-rank'),
            'description' => __( 'A news article', 'tam-rank' ),
            'properties' => array(
                'headline' => array(
                    'label' => __('Headline', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'custom_field', 'manual')
                ),
                'author' => array(
                    'label' => __('Author', 'tam-rank'),
                    'required' => true,
                    'type' => 'person',
                    'sources' => array('author_name', 'author_url', 'custom_field')
                ),
                'datePublished' => array(
                    'label' => __('Date Published', 'tam-rank'),
                    'required' => true,
                    'type' => 'date',
                    'sources' => array('post_date', 'custom_field')
                ),
                'dateModified' => array(
                    'label' => __('Date Modified', 'tam-rank'),
                    'required' => false,
                    'type' => 'date',
                    'sources' => array('post_modified', 'custom_field')
                ),
                'publisher' => array(
                    'label' => __('Publisher', 'tam-rank'),
                    'required' => true,
                    'type' => 'organization',
                    'sources' => array('global_organization')
                ),
                'dateline' => array(
                    'label' => __('Dateline (Location)', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'Amsterdam, NL'
                )
            )
        ),
        'BlogPosting' => array(
            'label' => __('Blog Posting', 'tam-rank'),
            'description' => __( 'A blog post', 'tam-rank' ),
            'properties' => array(
                'headline' => array(
                    'label' => __('Headline', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'custom_field', 'manual')
                ),
                'author' => array(
                    'label' => __('Author', 'tam-rank'),
                    'required' => true,
                    'type' => 'person',
                    'sources' => array('author_name', 'author_url', 'custom_field')
                ),
                'datePublished' => array(
                    'label' => __('Date Published', 'tam-rank'),
                    'required' => true,
                    'type' => 'date',
                    'sources' => array('post_date', 'custom_field')
                ),
                'dateModified' => array(
                    'label' => __('Date Modified', 'tam-rank'),
                    'required' => false,
                    'type' => 'date',
                    'sources' => array('post_modified', 'custom_field')
                ),
                'publisher' => array(
                    'label' => __('Publisher', 'tam-rank'),
                    'required' => true,
                    'type' => 'organization',
                    'sources' => array('global_organization')
                )
            )
        ),
        'Product' => array(
            'label' => __('Product', 'tam-rank'),
            'description' => __( 'A product with price and availability', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'custom_field', 'manual')
                ),
                'price' => array(
                    'label' => __('Price', 'tam-rank'),
                    'required' => true,
                    'type' => 'number',
                    'sources' => array('woo_price', 'custom_field', 'manual')
                ),
                'priceCurrency' => array(
                    'label' => __('Price Currency', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('woo_currency', 'manual'),
                    'default' => 'EUR'
                ),
                'availability' => array(
                    'label' => __('Availability', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('woo_stock', 'manual'),
                    'options' => array(
                        'https://schema.org/InStock' => 'In Stock',
                        'https://schema.org/OutOfStock' => 'Out of Stock',
                        'https://schema.org/PreOrder' => 'Pre Order',
                        'https://schema.org/BackOrder' => 'Back Order',
                        'https://schema.org/LimitedAvailability' => 'Limited Availability'
                    )
                ),
                'brand' => array(
                    'label' => __('Brand', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_brand',
                    'sources' => array('custom_field', 'manual')
                ),
                'sku' => array(
                    'label' => __('SKU', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('woo_sku', 'custom_field', 'manual')
                ),
                'gtin' => array(
                    'label' => __('GTIN/EAN', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '1234567890123'
                ),
                'mpn' => array(
                    'label' => __('MPN (Manufacturer Part Number)', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                ),
                'aggregateRating' => array(
                    'label' => __('Rating', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_rating',
                    'sources' => array('woo_rating', 'custom_field', 'manual')
                ),
                'review' => array(
                    'label' => __('Reviews', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_reviews',
                    'sources' => array('woo_reviews', 'manual')
                ),
                'offers' => array(
                    'label' => __('Offer Details', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_offer',
                    'sources' => array('woo_offer', 'manual')
                ),
                'category' => array(
                    'label' => __('Product Category', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('woo_category', 'category', 'custom_field', 'manual')
                ),
                'material' => array(
                    'label' => __('Material', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                ),
                'color' => array(
                    'label' => __('Color', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                ),
                'weight' => array(
                    'label' => __('Weight', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('woo_weight', 'custom_field', 'manual'),
                    'placeholder' => '1.5 kg'
                )
            )
        ),
        'LocalBusiness' => array(
            'label' => __('Local Business', 'tam-rank'),
            'description' => __( 'A local business with address and opening hours', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Business Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('global_organization', 'post_title', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'global_logo', 'manual')
                ),
                'address' => array(
                    'label' => __('Address', 'tam-rank'),
                    'required' => true,
                    'type' => 'nested_address',
                    'sources' => array('global_organization', 'manual')
                ),
                'telephone' => array(
                    'label' => __('Telephone', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                ),
                'email' => array(
                    'label' => __('Email', 'tam-rank'),
                    'required' => false,
                    'type' => 'email',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                ),
                'url' => array(
                    'label' => __('Website URL', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('site_url', 'custom_field', 'manual')
                ),
                'priceRange' => array(
                    'label' => __('Price Range', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        '€' => '€ (Budget)',
                        '€€' => '€€ (Moderate)',
                        '€€€' => '€€€ (Expensive)',
                        '€€€€' => '€€€€ (Very Expensive)'
                    )
                ),
                'openingHoursSpecification' => array(
                    'label' => __('Opening Hours', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_hours',
                    'sources' => array('global_organization', 'manual')
                ),
                'geo' => array(
                    'label' => __('GPS Coordinates', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_geo',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '52.3676, 4.9041'
                ),
                'aggregateRating' => array(
                    'label' => __('Rating', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_rating',
                    'sources' => array('custom_field', 'manual')
                ),
                'sameAs' => array(
                    'label' => __('Social Media Links', 'tam-rank'),
                    'required' => false,
                    'type' => 'text_list',
                    'sources' => array('global_organization', 'manual'),
                    'placeholder' => 'https://facebook.com/..., https://instagram.com/...'
                ),
                'paymentAccepted' => array(
                    'label' => __('Payment Methods', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'Cash, Credit Card, iDEAL'
                ),
                'currenciesAccepted' => array(
                    'label' => __('Currencies Accepted', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('manual'),
                    'default' => 'EUR'
                ),
                'areaServed' => array(
                    'label' => __('Service Area', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'Amsterdam, North Holland', 'tam-rank' )
                )
            )
        ),
        'Event' => array(
            'label' => __('Event', 'tam-rank'),
            'description' => __( 'An event with date, location and tickets', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Event Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Event Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'manual')
                ),
                'startDate' => array(
                    'label' => __('Start Date & Time', 'tam-rank'),
                    'required' => true,
                    'type' => 'datetime',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '2025-06-15T19:00:00'
                ),
                'endDate' => array(
                    'label' => __('End Date & Time', 'tam-rank'),
                    'required' => false,
                    'type' => 'datetime',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '2025-06-15T23:00:00'
                ),
                'location' => array(
                    'label' => __('Location', 'tam-rank'),
                    'required' => true,
                    'type' => 'nested_place',
                    'sources' => array('custom_field', 'manual')
                ),
                'organizer' => array(
                    'label' => __('Organizer', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_organization',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                ),
                'performer' => array(
                    'label' => __('Performer(s)', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                ),
                'eventStatus' => array(
                    'label' => __('Event Status', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'https://schema.org/EventScheduled' => 'Scheduled',
                        'https://schema.org/EventPostponed' => 'Postponed',
                        'https://schema.org/EventCancelled' => 'Cancelled',
                        'https://schema.org/EventMovedOnline' => 'Moved Online',
                        'https://schema.org/EventRescheduled' => 'Rescheduled'
                    ),
                    'default' => 'https://schema.org/EventScheduled'
                ),
                'eventAttendanceMode' => array(
                    'label' => __('Attendance Mode', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'https://schema.org/OfflineEventAttendanceMode' => 'Offline (Physical)',
                        'https://schema.org/OnlineEventAttendanceMode' => 'Online (Virtual)',
                        'https://schema.org/MixedEventAttendanceMode' => 'Mixed (Hybrid)'
                    )
                ),
                'offers' => array(
                    'label' => __('Ticket Price', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_offer',
                    'sources' => array('custom_field', 'manual')
                ),
                'doorTime' => array(
                    'label' => __('Door Opening Time', 'tam-rank'),
                    'required' => false,
                    'type' => 'datetime',
                    'sources' => array('custom_field', 'manual')
                )
            )
        ),
        'Recipe' => array(
            'label' => __('Recipe', 'tam-rank'),
            'description' => __( 'A recipe with ingredients and preparation', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Recipe Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Recipe Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'manual')
                ),
                'author' => array(
                    'label' => __('Author', 'tam-rank'),
                    'required' => true,
                    'type' => 'person',
                    'sources' => array('author_name', 'custom_field', 'manual')
                ),
                'datePublished' => array(
                    'label' => __('Date Published', 'tam-rank'),
                    'required' => false,
                    'type' => 'date',
                    'sources' => array('post_date', 'custom_field')
                ),
                'prepTime' => array(
                    'label' => __('Preparation Time', 'tam-rank'),
                    'required' => false,
                    'type' => 'duration',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'PT15M (15 minutes)', 'tam-rank' )
                ),
                'cookTime' => array(
                    'label' => __('Cooking Time', 'tam-rank'),
                    'required' => false,
                    'type' => 'duration',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'PT30M (30 minutes)', 'tam-rank' )
                ),
                'totalTime' => array(
                    'label' => __('Total Time', 'tam-rank'),
                    'required' => false,
                    'type' => 'duration',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'PT45M (45 minutes)', 'tam-rank' )
                ),
                'recipeYield' => array(
                    'label' => __('Servings', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( '4 servings', 'tam-rank' )
                ),
                'recipeIngredient' => array(
                    'label' => __('Ingredients', 'tam-rank'),
                    'required' => true,
                    'type' => 'ingredient_list',
                    'sources' => array('custom_field', 'manual')
                ),
                'recipeInstructions' => array(
                    'label' => __('Instructions', 'tam-rank'),
                    'required' => true,
                    'type' => 'steps_list',
                    'sources' => array('custom_field', 'manual')
                ),
                'recipeCategory' => array(
                    'label' => __('Category', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('category', 'custom_field', 'manual'),
                    'placeholder' => __( 'Main course, Dessert, etc.', 'tam-rank' )
                ),
                'recipeCuisine' => array(
                    'label' => __('Cuisine', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'Italian, Dutch, etc.', 'tam-rank' )
                ),
                'keywords' => array(
                    'label' => __('Keywords', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('tags', 'custom_field', 'manual')
                ),
                'nutrition' => array(
                    'label' => __('Nutritional Information', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_nutrition',
                    'sources' => array('custom_field', 'manual')
                ),
                'aggregateRating' => array(
                    'label' => __('Rating', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_rating',
                    'sources' => array('custom_field', 'manual')
                ),
                'video' => array(
                    'label' => __('Recipe Video', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_video',
                    'sources' => array('custom_field', 'manual')
                ),
                'suitableForDiet' => array(
                    'label' => __('Suitable for Diet', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'https://schema.org/VeganDiet' => 'Vegan',
                        'https://schema.org/VegetarianDiet' => 'Vegetarian',
                        'https://schema.org/GlutenFreeDiet' => 'Gluten Free',
                        'https://schema.org/LowCalorieDiet' => 'Low Calorie',
                        'https://schema.org/DiabeticDiet' => 'Diabetic',
                        'https://schema.org/HalalDiet' => 'Halal',
                        'https://schema.org/KosherDiet' => 'Kosher'
                    )
                )
            )
        ),
        'VideoObject' => array(
            'label' => __('Video', 'tam-rank'),
            'description' => __( 'A video with metadata', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Video Title', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'thumbnailUrl' => array(
                    'label' => __('Thumbnail URL', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'custom_field', 'manual')
                ),
                'uploadDate' => array(
                    'label' => __('Upload Date', 'tam-rank'),
                    'required' => true,
                    'type' => 'date',
                    'sources' => array('post_date', 'custom_field', 'manual')
                ),
                'duration' => array(
                    'label' => __('Duration', 'tam-rank'),
                    'required' => false,
                    'type' => 'duration',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'PT5M30S (5:30)'
                ),
                'contentUrl' => array(
                    'label' => __('Video URL', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'https://example.com/video.mp4'
                ),
                'embedUrl' => array(
                    'label' => __('Embed URL', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'https://youtube.com/embed/...'
                ),
                'publisher' => array(
                    'label' => __('Publisher', 'tam-rank'),
                    'required' => false,
                    'type' => 'organization',
                    'sources' => array('global_organization')
                ),
                'interactionStatistic' => array(
                    'label' => __('View Count', 'tam-rank'),
                    'required' => false,
                    'type' => 'number',
                    'sources' => array('custom_field', 'manual')
                ),
                'hasPart' => array(
                    'label' => __('Video Chapters', 'tam-rank'),
                    'required' => false,
                    'type' => 'video_clips',
                    'sources' => array('custom_field', 'manual')
                )
            )
        ),
        'Course' => array(
            'label' => __('Course', 'tam-rank'),
            'description' => __( 'A course or training', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Course Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Course Image', 'tam-rank'),
                    'required' => false,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'manual')
                ),
                'provider' => array(
                    'label' => __('Course Provider', 'tam-rank'),
                    'required' => true,
                    'type' => 'nested_organization',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                ),
                'offers' => array(
                    'label' => __('Course Price', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_offer',
                    'sources' => array('custom_field', 'manual')
                ),
                'hasCourseInstance' => array(
                    'label' => __('Course Instance', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_course_instance',
                    'sources' => array('custom_field', 'manual')
                ),
                'coursePrerequisites' => array(
                    'label' => __('Prerequisites', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                ),
                'educationalLevel' => array(
                    'label' => __('Educational Level', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'Beginner' => 'Beginner',
                        'Intermediate' => 'Intermediate',
                        'Advanced' => 'Advanced',
                        'Expert' => 'Expert'
                    )
                ),
                'inLanguage' => array(
                    'label' => __('Language', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('manual'),
                    'default' => 'nl'
                ),
                'aggregateRating' => array(
                    'label' => __('Rating', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_rating',
                    'sources' => array('custom_field', 'manual')
                ),
                'numberOfCredits' => array(
                    'label' => __('Number of Credits', 'tam-rank'),
                    'required' => false,
                    'type' => 'number',
                    'sources' => array('custom_field', 'manual')
                )
            )
        ),
        'Service' => array(
            'label' => __('Service', 'tam-rank'),
            'description' => __( 'A service', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Service Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Service Image', 'tam-rank'),
                    'required' => false,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'manual')
                ),
                'provider' => array(
                    'label' => __('Service Provider', 'tam-rank'),
                    'required' => true,
                    'type' => 'nested_organization',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                ),
                'serviceType' => array(
                    'label' => __('Service Type', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('category', 'custom_field', 'manual')
                ),
                'areaServed' => array(
                    'label' => __('Service Area', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'Amsterdam, Netherlands', 'tam-rank' )
                ),
                'offers' => array(
                    'label' => __('Service Price', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_offer',
                    'sources' => array('custom_field', 'manual')
                ),
                'aggregateRating' => array(
                    'label' => __('Rating', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_rating',
                    'sources' => array('custom_field', 'manual')
                ),
                'hasOfferCatalog' => array(
                    'label' => __('Service Catalog', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_catalog',
                    'sources' => array('custom_field', 'manual')
                ),
                'termsOfService' => array(
                    'label' => __('Terms of Service URL', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('custom_field', 'manual')
                ),
                'availableChannel' => array(
                    'label' => __('Available Through', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'Website, Phone, Email', 'tam-rank' )
                )
            )
        ),
        'SoftwareApplication' => array(
            'label' => __('Software Application', 'tam-rank'),
            'description' => __( 'A software application or app', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Application Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('App Screenshot/Icon', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'manual')
                ),
                'applicationCategory' => array(
                    'label' => __('Category', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'BusinessApplication' => 'Business',
                        'GameApplication' => 'Games',
                        'SocialNetworkingApplication' => 'Social Networking',
                        'EducationalApplication' => 'Education',
                        'LifestyleApplication' => 'Lifestyle',
                        'UtilitiesApplication' => 'Utilities',
                        'MultimediaApplication' => 'Multimedia',
                        'HealthApplication' => 'Health & Fitness'
                    )
                ),
                'operatingSystem' => array(
                    'label' => __('Operating System', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'Windows, macOS, iOS, Android'
                ),
                'softwareVersion' => array(
                    'label' => __('Software Version', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '1.0.0'
                ),
                'offers' => array(
                    'label' => __('Price', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_offer',
                    'sources' => array('custom_field', 'manual')
                ),
                'aggregateRating' => array(
                    'label' => __('Rating', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_rating',
                    'sources' => array('custom_field', 'manual')
                ),
                'downloadUrl' => array(
                    'label' => __('Download URL', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('custom_field', 'manual')
                ),
                'installUrl' => array(
                    'label' => __('Install URL (App Store)', 'tam-rank'),
                    'required' => false,
                    'type' => 'url',
                    'sources' => array('custom_field', 'manual')
                ),
                'fileSize' => array(
                    'label' => __('File Size', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '50MB'
                ),
                'author' => array(
                    'label' => __('Developer/Author', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_organization',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                )
            )
        ),
        'JobPosting' => array(
            'label' => __('Job Posting', 'tam-rank'),
            'description' => __( 'A job vacancy or position', 'tam-rank' ),
            'properties' => array(
                'title' => array(
                    'label' => __('Job Title', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Job Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('content', 'meta_description', 'excerpt', 'manual')
                ),
                'hiringOrganization' => array(
                    'label' => __('Hiring Organization', 'tam-rank'),
                    'required' => true,
                    'type' => 'nested_organization',
                    'sources' => array('global_organization', 'custom_field', 'manual')
                ),
                'datePosted' => array(
                    'label' => __('Date Posted', 'tam-rank'),
                    'required' => true,
                    'type' => 'date',
                    'sources' => array('post_date', 'custom_field', 'manual')
                ),
                'validThrough' => array(
                    'label' => __('Valid Through', 'tam-rank'),
                    'required' => false,
                    'type' => 'date',
                    'sources' => array('custom_field', 'manual')
                ),
                'employmentType' => array(
                    'label' => __('Employment Type', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'FULL_TIME' => 'Full Time',
                        'PART_TIME' => 'Part Time',
                        'CONTRACTOR' => 'Contractor',
                        'TEMPORARY' => 'Temporary',
                        'INTERN' => 'Internship',
                        'VOLUNTEER' => 'Volunteer',
                        'PER_DIEM' => 'Per Diem',
                        'OTHER' => 'Other'
                    )
                ),
                'jobLocation' => array(
                    'label' => __('Job Location', 'tam-rank'),
                    'required' => true,
                    'type' => 'nested_place',
                    'sources' => array('custom_field', 'manual')
                ),
                'jobLocationType' => array(
                    'label' => __('Location Type', 'tam-rank'),
                    'required' => false,
                    'type' => 'select',
                    'sources' => array('manual'),
                    'options' => array(
                        'TELECOMMUTE' => 'Remote/Telecommute',
                        '' => 'On-site'
                    )
                ),
                'baseSalary' => array(
                    'label' => __('Base Salary', 'tam-rank'),
                    'required' => false,
                    'type' => 'nested_salary',
                    'sources' => array('custom_field', 'manual')
                ),
                'experienceRequirements' => array(
                    'label' => __('Experience Requirements', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => '3+ years experience'
                ),
                'qualifications' => array(
                    'label' => __('Qualifications', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                ),
                'skills' => array(
                    'label' => __('Required Skills', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => 'PHP, JavaScript, WordPress'
                ),
                'industry' => array(
                    'label' => __('Industry', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual')
                )
            )
        ),
        'FAQPage' => array(
            'label' => __('FAQ Page', 'tam-rank'),
            'description' => __( 'A FAQ page with question and answer pairs', 'tam-rank' ),
            'properties' => array(
                'mainEntity' => array(
                    'label' => __('FAQ Items', 'tam-rank'),
                    'required' => true,
                    'type' => 'faq_list',
                    'sources' => array('custom_field', 'manual')
                )
            )
        ),
        'HowTo' => array(
            'label' => __('How To', 'tam-rank'),
            'description' => __( 'A step-by-step plan or tutorial', 'tam-rank' ),
            'properties' => array(
                'name' => array(
                    'label' => __('Name', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('post_title', 'custom_field', 'manual')
                ),
                'description' => array(
                    'label' => __('Description', 'tam-rank'),
                    'required' => true,
                    'type' => 'text',
                    'sources' => array('meta_description', 'excerpt', 'content_excerpt', 'manual')
                ),
                'image' => array(
                    'label' => __('Image', 'tam-rank'),
                    'required' => true,
                    'type' => 'image',
                    'sources' => array('featured_image', 'first_content_image', 'manual')
                ),
                'totalTime' => array(
                    'label' => __('Total Time (ISO 8601)', 'tam-rank'),
                    'required' => false,
                    'type' => 'text',
                    'sources' => array('custom_field', 'manual'),
                    'placeholder' => __( 'PT30M (30 minutes)', 'tam-rank' )
                ),
                'step' => array(
                    'label' => __('Steps', 'tam-rank'),
                    'required' => true,
                    'type' => 'steps_list',
                    'sources' => array('custom_field', 'manual')
                )
            )
        ),
        'Custom' => array(
            'label' => __('Custom JSON-LD', 'tam-rank'),
            'description' => __( 'Advanced: Write your own JSON-LD schema', 'tam-rank' ),
            'is_custom' => true,
            'properties' => array(
                'custom_jsonld' => array(
                    'label' => __('Custom JSON-LD Code', 'tam-rank'),
                    'required' => true,
                    'type' => 'custom_jsonld',
                    'sources' => array('manual')
                )
            )
        )
    );
}

/**
 * Get available data sources for field mapping
 *
 * @return array Data sources
 */
function tamrank_get_field_sources() {
    return array(
        // Post data sources
        'post_title' => __('Post Title', 'tam-rank'),
        'post_url' => __('Post URL', 'tam-rank'),
        'meta_description' => __('TamRank Meta Description', 'tam-rank'),
        'excerpt' => __('WordPress Excerpt', 'tam-rank'),
        'content' => __('Full Content', 'tam-rank'),
        'content_excerpt' => __('First 160 characters of content', 'tam-rank'),
        'featured_image' => __('Featured Image', 'tam-rank'),
        'first_content_image' => __('First image in content', 'tam-rank'),
        'author_name' => __('Author Name', 'tam-rank'),
        'author_url' => __('Author URL', 'tam-rank'),
        'post_date' => __('Publication Date', 'tam-rank'),
        'post_modified' => __('Modified Date', 'tam-rank'),

        // Taxonomy sources
        'category' => __('Category', 'tam-rank'),
        'tags' => __('Tags', 'tam-rank'),

        // Auto-calculated sources
        'auto_wordcount' => __('Automatic (Word count)', 'tam-rank'),

        // Site/Organization sources
        'site_url' => __('Website URL', 'tam-rank'),
        'global_organization' => __('Global Organization Data', 'tam-rank'),
        'global_logo' => __('Global Logo', 'tam-rank'),

        // WooCommerce sources
        'woo_price' => __('WooCommerce Price', 'tam-rank'),
        'woo_currency' => __('WooCommerce Currency', 'tam-rank'),
        'woo_stock' => __('WooCommerce Stock Status', 'tam-rank'),
        'woo_sku' => __('WooCommerce SKU', 'tam-rank'),
        'woo_weight' => __('WooCommerce Weight', 'tam-rank'),
        'woo_category' => __('WooCommerce Category', 'tam-rank'),
        'woo_rating' => __('WooCommerce Rating', 'tam-rank'),
        'woo_reviews' => __('WooCommerce Reviews', 'tam-rank'),
        'woo_offer' => __('WooCommerce Offer', 'tam-rank'),

        // Manual sources
        'custom_field' => __('Custom Field (Meta Key)', 'tam-rank'),
        'manual' => __('Manual Input Per Post', 'tam-rank')
    );
}

/**
 * Get default template configuration for a schema type
 *
 * @param string $schema_type Schema type
 * @return array Default configuration
 */
function tamrank_get_default_template_config($schema_type) {
    $defaults = array(
        'Article' => array(
            'headline' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'author' => array('source' => 'author_name'),
            'datePublished' => array('source' => 'post_date'),
            'dateModified' => array('source' => 'post_modified'),
            'publisher' => array('source' => 'global_organization'),
            'articleSection' => array('source' => 'category'),
            'wordCount' => array('source' => 'auto_wordcount'),
            'keywords' => array('source' => 'tags'),
            'mainEntityOfPage' => array('source' => 'post_url')
        ),
        'NewsArticle' => array(
            'headline' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'author' => array('source' => 'author_name'),
            'datePublished' => array('source' => 'post_date'),
            'dateModified' => array('source' => 'post_modified'),
            'publisher' => array('source' => 'global_organization')
        ),
        'BlogPosting' => array(
            'headline' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'author' => array('source' => 'author_name'),
            'datePublished' => array('source' => 'post_date'),
            'dateModified' => array('source' => 'post_modified'),
            'publisher' => array('source' => 'global_organization')
        ),
        'Product' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'price' => array('source' => 'woo_price'),
            'priceCurrency' => array('source' => 'woo_currency', 'value' => 'EUR'),
            'availability' => array('source' => 'woo_stock', 'value' => 'https://schema.org/InStock'),
            'sku' => array('source' => 'woo_sku'),
            'aggregateRating' => array('source' => 'woo_rating'),
            'category' => array('source' => 'woo_category')
        ),
        'LocalBusiness' => array(
            'name' => array('source' => 'global_organization'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'global_logo'),
            'address' => array('source' => 'global_organization'),
            'telephone' => array('source' => 'global_organization'),
            'url' => array('source' => 'site_url'),
            'sameAs' => array('source' => 'global_organization')
        ),
        'Event' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'startDate' => array('source' => 'manual'),
            'location' => array('source' => 'manual'),
            'organizer' => array('source' => 'global_organization'),
            'eventStatus' => array('source' => 'manual', 'value' => 'https://schema.org/EventScheduled')
        ),
        'Recipe' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'author' => array('source' => 'author_name'),
            'datePublished' => array('source' => 'post_date'),
            'recipeIngredient' => array('source' => 'manual'),
            'recipeInstructions' => array('source' => 'manual'),
            'recipeCategory' => array('source' => 'category'),
            'keywords' => array('source' => 'tags')
        ),
        'VideoObject' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'thumbnailUrl' => array('source' => 'featured_image'),
            'uploadDate' => array('source' => 'post_date'),
            'publisher' => array('source' => 'global_organization')
        ),
        'Course' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'provider' => array('source' => 'global_organization'),
            'inLanguage' => array('source' => 'manual', 'value' => 'nl')
        ),
        'Service' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'provider' => array('source' => 'global_organization'),
            'serviceType' => array('source' => 'category')
        ),
        'SoftwareApplication' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'author' => array('source' => 'global_organization')
        ),
        'JobPosting' => array(
            'title' => array('source' => 'post_title'),
            'description' => array('source' => 'content'),
            'hiringOrganization' => array('source' => 'global_organization'),
            'datePosted' => array('source' => 'post_date'),
            'jobLocation' => array('source' => 'manual')
        ),
        'FAQPage' => array(
            'mainEntity' => array('source' => 'manual')
        ),
        'HowTo' => array(
            'name' => array('source' => 'post_title'),
            'description' => array('source' => 'meta_description'),
            'image' => array('source' => 'featured_image'),
            'step' => array('source' => 'manual')
        ),
        'Custom' => array()
    );

    return isset($defaults[$schema_type]) ? $defaults[$schema_type] : array();
}

/**
 * Validate JSON-LD schema structure
 *
 * @param string $json_string JSON string to validate
 * @return array Validation result with 'valid', 'errors', and 'warnings' keys
 */
function tamrank_validate_jsonld($json_string) {
    $result = array(
        'valid' => true,
        'errors' => array(),
        'warnings' => array(),
        'parsed' => null
    );

    // Check if empty
    if (empty(trim($json_string))) {
        $result['valid'] = false;
        $result['errors'][] = __('JSON-LD is empty', 'tam-rank');
        return $result;
    }

    // Try to decode JSON
    $decoded = json_decode($json_string, true);
    if (json_last_error() !== JSON_ERROR_NONE) {
        $result['valid'] = false;
        // translators: %s is the JSON parser error message.
        $result['errors'][] = sprintf( __('Invalid JSON syntax: %s', 'tam-rank'), json_last_error_msg() );
        return $result;
    }

    $result['parsed'] = $decoded;

    // Check for @context
    if (!isset($decoded['@context'])) {
        $result['warnings'][] = __('@context is missing. Add "https://schema.org" for correct operation.', 'tam-rank');
    } elseif ($decoded['@context'] !== 'https://schema.org' && $decoded['@context'] !== 'http://schema.org') {
        $result['warnings'][] = __('@context should be "https://schema.org".', 'tam-rank');
    }

    // Check for @type
    if (!isset($decoded['@type'])) {
        $result['valid'] = false;
        $result['errors'][] = __('@type is required. Specify the schema type (e.g. "Article", "Product", etc.)', 'tam-rank');
    } else {
        // Validate known types
        $known_types = array(
            'Article', 'NewsArticle', 'BlogPosting', 'Product', 'LocalBusiness',
            'Event', 'Recipe', 'VideoObject', 'Course', 'Service', 'SoftwareApplication',
            'JobPosting', 'FAQPage', 'HowTo', 'Organization', 'Person', 'Place',
            'WebSite', 'WebPage', 'BreadcrumbList', 'Review', 'AggregateRating',
            'Offer', 'ImageObject', 'CreativeWork', 'Thing', 'Action'
        );

        $type = $decoded['@type'];
        if (is_string($type) && !in_array($type, $known_types)) {
            $result['warnings'][] = sprintf( tamrank__('schema_validate_uncommon_type', "Schema type '%s' is not a common type. Check the spelling."), $type );
        }
    }

    // Check for common required fields based on type
    if (isset($decoded['@type'])) {
        $type = $decoded['@type'];
        $missing_recommended = array();

        switch ($type) {
            case 'Article':
            case 'NewsArticle':
            case 'BlogPosting':
                if (!isset($decoded['headline'])) $missing_recommended[] = 'headline';
                if (!isset($decoded['author'])) $missing_recommended[] = 'author';
                if (!isset($decoded['datePublished'])) $missing_recommended[] = 'datePublished';
                if (!isset($decoded['image'])) $missing_recommended[] = 'image';
                break;

            case 'Product':
                if (!isset($decoded['name'])) $missing_recommended[] = 'name';
                if (!isset($decoded['image'])) $missing_recommended[] = 'image';
                if (!isset($decoded['offers']) && !isset($decoded['price'])) $missing_recommended[] = 'offers of price';
                break;

            case 'Event':
                if (!isset($decoded['name'])) $missing_recommended[] = 'name';
                if (!isset($decoded['startDate'])) $missing_recommended[] = 'startDate';
                if (!isset($decoded['location'])) $missing_recommended[] = 'location';
                break;

            case 'Recipe':
                if (!isset($decoded['name'])) $missing_recommended[] = 'name';
                if (!isset($decoded['recipeIngredient'])) $missing_recommended[] = 'recipeIngredient';
                if (!isset($decoded['recipeInstructions'])) $missing_recommended[] = 'recipeInstructions';
                break;

            case 'LocalBusiness':
                if (!isset($decoded['name'])) $missing_recommended[] = 'name';
                if (!isset($decoded['address'])) $missing_recommended[] = 'address';
                break;

            case 'JobPosting':
                if (!isset($decoded['title'])) $missing_recommended[] = 'title';
                if (!isset($decoded['description'])) $missing_recommended[] = 'description';
                if (!isset($decoded['datePosted'])) $missing_recommended[] = 'datePosted';
                if (!isset($decoded['hiringOrganization'])) $missing_recommended[] = 'hiringOrganization';
                break;

            case 'VideoObject':
                if (!isset($decoded['name'])) $missing_recommended[] = 'name';
                if (!isset($decoded['thumbnailUrl'])) $missing_recommended[] = 'thumbnailUrl';
                if (!isset($decoded['uploadDate'])) $missing_recommended[] = 'uploadDate';
                break;
        }

        if (!empty($missing_recommended)) {
            $result['warnings'][] = sprintf( tamrank__('schema_validate_missing_recommended', 'Recommended fields missing for %1$s: %2$s'), $type, implode(', ', $missing_recommended) );
        }
    }

    // Check for invalid URL formats
    $url_fields = array('url', 'image', 'logo', 'thumbnailUrl', 'contentUrl', 'embedUrl', '@id');
    foreach ($url_fields as $field) {
        if (isset($decoded[$field])) {
            $url_value = is_array($decoded[$field]) ? ($decoded[$field]['url'] ?? null) : $decoded[$field];
            if ($url_value && is_string($url_value) && !filter_var($url_value, FILTER_VALIDATE_URL)) {
                if (strpos($url_value, '{{') === false && strpos($url_value, '{%') === false) {
                    $result['warnings'][] = sprintf( tamrank__('schema_validate_invalid_url', "'%1\$s' does not contain a valid URL: %2\$s"), $field, $url_value );
                }
            }
        }
    }

    // Check for date formats
    $date_fields = array('datePublished', 'dateModified', 'startDate', 'endDate', 'uploadDate', 'datePosted', 'validThrough');
    foreach ($date_fields as $field) {
        if (isset($decoded[$field]) && is_string($decoded[$field])) {
            $date_value = $decoded[$field];
            // Skip template variables
            if (strpos($date_value, '{{') !== false || strpos($date_value, '{%') !== false) {
                continue;
            }
            // Check ISO 8601 format
            if (!preg_match('/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2})?([+-]\d{2}:\d{2}|Z)?)?$/', $date_value)) {
                $result['warnings'][] = sprintf( tamrank__('schema_validate_iso8601', "'%s' should be in ISO 8601 format (e.g. 2025-01-15 or 2025-01-15T14:30:00)"), $field );
            }
        }
    }

    // Check for nested objects structure
    $nested_fields = array('author', 'publisher', 'offers', 'aggregateRating', 'address', 'location', 'organization');
    foreach ($nested_fields as $field) {
        if (isset($decoded[$field]) && is_array($decoded[$field]) && !isset($decoded[$field]['@type'])) {
            // Check if it's not a @id reference
            if (!isset($decoded[$field]['@id'])) {
                $result['warnings'][] = sprintf( tamrank__('schema_validate_object_missing_type', "'%s' is an object but is missing @type"), $field );
            }
        }
    }

    return $result;
}

