<?php
declare(strict_types=1);

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

use LolaCore\Marketing\AddonCatalog;

$lolacore_addon_cards = AddonCatalog::getCatalogForAddonsPage();
?>
<div class="lc-settings-container lc-addons-page">
    <div class="lc-settings-header">
        <div class="lc-settings-header-text">
            <span class="lc-eyebrow"><?php echo esc_html__('Lola', 'lolacore'); ?> &middot; <?php echo esc_html__('Addons', 'lolacore'); ?></span>
            <h2><?php echo esc_html__('Addons', 'lolacore'); ?></h2>
            <span class="lc-header-subtitle"><?php echo esc_html__(
                'Lola learns by addon. Each one adds a domain: store operations, code, support tickets, email marketing. Install what your site needs and skip what it doesn\'t.',
                'lolacore'
            ); ?></span>
        </div>
    </div>

    <div class="lc-card lc-addons-grid-card">
        <div class="lc-addon-grid">
            <?php foreach ($lolacore_addon_cards as $lolacore_addon_card) : ?>
                <?php
                $lolacore_addon_card_context = 'catalog';
                require __DIR__ . '/partials/addon-catalog-card.php';
                ?>
            <?php endforeach; ?>
        </div>
    </div>

    <?php
    $lolacore_crossdomain_chains = [
        [
            'domains' => __('memory · store · code', 'lolacore'),
            'title'   => __('Answer from history', 'lolacore'),
            'body'    => __(
                'In January you ask how the holiday sale went. Lola answers with revenue, coupon usage, and how many Black Friday customers came back — and notes she reused that campaign\'s banner snippet. She didn\'t re-scan anything. She remembered.',
                'lolacore'
            ),
        ],
        [
            'domains' => __('tickets · store · campaigns', 'lolacore'),
            'title'   => __('Turn tickets into sales', 'lolacore'),
            'body'    => __(
                'Five tickets in one week ask how to do something your premium product already handles. Lola spots the pattern, checks what each customer bought, and drafts a personal reply with the upgrade they\'re missing. The support queue starts paying for itself.',
                'lolacore'
            ),
        ],
        [
            'domains' => __('code · store · tickets · campaigns', 'lolacore'),
            'title'   => __('Trace the cause', 'lolacore'),
            'body'    => __(
                'A snippet breaks the checkout overnight and tickets start coming in. Lola traces them to the broken line, fixes it, drafts the replies, refunds the failed order, and excludes the affected customers from today\'s email sequence. One conversation.',
                'lolacore'
            ),
        ],
    ];
    $lolacore_crossdomain_url = \LolaCore\Marketing\MarketingUrlBuilder::build(
        'https://lolacore.com/add-ons/',
        \LolaCore\Marketing\MarketingUrlBuilder::MEDIUM_SUBMENU_ADDONS,
        'cross_domain'
    );
    ?>
    <div class="lc-card lc-crossdomain-panel">
        <div class="lc-card-header">
            <h3><?php echo esc_html__('One memory, every domain', 'lolacore'); ?></h3>
        </div>
        <p class="description"><?php echo esc_html__(
            'Each addon teaches Lola one domain. Active together, they stop being separate jobs: Lola\'s memory is shared, so the store, the code, the tickets, and the campaigns become one picture — causes and effects included.',
            'lolacore'
        ); ?></p>
        <div class="lc-addon-grid">
            <?php foreach ($lolacore_crossdomain_chains as $lolacore_chain) : ?>
                <article class="lc-addon-card">
                    <p class="lc-addon-card-count"><?php echo esc_html($lolacore_chain['domains']); ?></p>
                    <h4 class="lc-addon-card-title"><?php echo esc_html($lolacore_chain['title']); ?></h4>
                    <p class="lc-addon-card-tagline"><?php echo esc_html($lolacore_chain['body']); ?></p>
                </article>
            <?php endforeach; ?>
        </div>
        <p class="description" style="margin-top: 16px; margin-bottom: 0;">
            <?php echo esc_html__(
                'Nothing to configure. Addons share Lola\'s memory automatically while they\'re active — each one you add widens what she can connect.',
                'lolacore'
            ); ?>
            <a class="lc-addon-card-link" href="<?php echo esc_url($lolacore_crossdomain_url); ?>" target="_blank" rel="noopener noreferrer">
                <?php echo esc_html__('How cross-domain intelligence works →', 'lolacore'); ?>
            </a>
        </p>
    </div>
</div>
