<?php

/**
 * Provide a admin area view for the plugin post analytics
 *
 * This file is used to markup the admin-facing post analytics of the plugin.
 *
 * @link       https://pinnerpress.com
 * @since      1.2.0
 *
 * @package    PinnerPress
 * @subpackage PinnerPress/admin/partials
 */

// If this file is called directly, abort.
if (!defined('WPINC')) {
    die;
}

// Check if user has premium access
$is_premium = function_exists('pinnerpress_is_premium') ? pinnerpress_is_premium() : false;

// Check if user can use premium features (includes trial users)
$can_use_premium_features = function_exists('pinnerpress_can_use_premium_features') ? pinnerpress_can_use_premium_features() : false;
$has_truly_premium = function_exists('pinnerpress_is_truly_premium') ? pinnerpress_is_truly_premium() : false;

// Check if analytics is enabled
$analytics_enabled = get_option('pinnerpress_analytics_enabled', '1') === '1';

if (!$analytics_enabled) {
    ?>
    <div class="wrap pinnerpress-admin">
        <h1><?php echo esc_html__('PinnerPress Post Analytics', 'pinnerpress'); ?></h1>

        <div class="pinnerpress-admin-header">
            <div class="pinnerpress-logo">
                <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedImage -- Plugin logo asset ?>
                <img src="<?php echo esc_url(plugin_dir_url(dirname(__FILE__)) . 'images/pinnerpress-logo.png'); ?>" alt="<?php echo esc_attr__('PinnerPress Logo', 'pinnerpress'); ?>">
            </div>
            <div class="pinnerpress-header-content">
                <h2><?php esc_html_e('PinnerPress Post Analytics', 'pinnerpress'); ?></h2>
                <p><?php esc_html_e('Track impressions, clicks, and conversion rates for your posts.', 'pinnerpress'); ?></p>
            </div>
        </div>

        <div class="pinnerpress-analytics-disabled-notice" style="background: #fff; border: 1px solid #c3c4c7; border-radius: 4px; padding: 60px 40px; text-align: center; margin: 20px auto 0; max-width: 800px;">
            <span class="dashicons dashicons-chart-bar" style="font-size: 48px; width: 48px; height: 48px; color: #c3c4c7; margin-bottom: 20px;"></span>
            <h2 style="font-size: 24px; margin: 0 0 15px 0; color: #1d2327;"><?php esc_html_e('Analytics Disabled', 'pinnerpress'); ?></h2>
            <p style="font-size: 14px; color: #646970; margin: 0 0 25px 0; max-width: 500px; margin-left: auto; margin-right: auto;">
                <?php esc_html_e('Analytics tracking is currently turned off. Enable analytics to start collecting data about your Pinterest engagement.', 'pinnerpress'); ?>
            </p>
            <a href="<?php echo esc_url(admin_url('admin.php?page=pinnerpress-settings&tab=general#analytics-settings')); ?>" class="button button-primary button-hero">
                <?php esc_html_e('Enable Analytics in Settings', 'pinnerpress'); ?>
            </a>
        </div>
    </div>
    <?php
    return;
}

// Check if user has premium analytics access
$has_premium_analytics = pinnerpress_is_feature_enabled('analytics_unlimited');

// Set default date range
$default_end_date = current_time('Y-m-d');
$default_start_date = gmdate('Y-m-d', strtotime('-30 days', strtotime($default_end_date)));

?>

<div class="wrap pinnerpress-admin pinnerpress-post-analytics-page" data-server-date="<?php echo esc_attr($default_end_date); ?>">
    <h1><?php echo esc_html(get_admin_page_title()); ?></h1>
    
    <div class="pinnerpress-admin-header">
        <div class="pinnerpress-logo">
            <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedImage -- Plugin logo asset ?>
            <img src="<?php echo esc_url(plugin_dir_url(dirname(__FILE__)) . 'images/pinnerpress-logo.png'); ?>" alt="<?php echo esc_attr__('PinnerPress Logo', 'pinnerpress'); ?>">
        </div>
        <div class="pinnerpress-header-content">
            <h2><?php esc_html_e('PinnerPress Post Analytics', 'pinnerpress'); ?></h2>
            <p><?php esc_html_e('Track impressions, clicks, and conversion rates for your posts.', 'pinnerpress'); ?></p>
        </div>
    </div>

<style>
.pinnerpress-analytics-limitation {
    border-left: 4px solid #E60023;
    padding: 12px;
    background-color: #fef4f4;
    margin: 20px 0;
}

.pinnerpress-analytics-limitation h4 {
    margin-top: 0;
    color: #E60023;
}

.pinnerpress-analytics-limitation p {
    margin-bottom: 10px;
}
</style>

    <div class="pinnerpress-admin-content">
        <?php if (!$can_use_premium_features): ?>
            <?php 
            // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Function returns properly escaped HTML
            echo pinnerpress_get_upgrade_notification(); 
            ?>
        <?php endif; ?>

    <!-- Main Content Area -->
    <div class="pinnerpress-content">
        <!-- Date Controls -->
        <div class="pinnerpress-analytics-controls">
            <div class="pinnerpress-date-controls">
                <label for="pinnerpress-start-date"><?php esc_html_e('Start Date:', 'pinnerpress'); ?></label>
                <input type="date" id="pinnerpress-start-date" value="<?php echo esc_attr($default_start_date); ?>" <?php echo !$can_use_premium_features ? 'disabled' : ''; ?> />
                
                <label for="pinnerpress-end-date"><?php esc_html_e('End Date:', 'pinnerpress'); ?></label>
                <input type="date" id="pinnerpress-end-date" value="<?php echo esc_attr($default_end_date); ?>" <?php echo !$can_use_premium_features ? 'disabled' : ''; ?> />
                
                <button type="button" id="pinnerpress-update-chart" class="button button-primary" <?php echo !$can_use_premium_features ? 'disabled' : ''; ?>>
                    <?php esc_html_e('Update Chart', 'pinnerpress'); ?>
                </button>
                
                <?php if (!$can_use_premium_features): ?>
                    <span class="pinnerpress-locked-icon" title="<?php esc_attr_e('Premium feature - upgrade to unlock custom date ranges', 'pinnerpress'); ?>">🔒</span>
                <?php endif; ?>
                
                <div class="pinnerpress-date-presets">
                    <button class="pinnerpress-date-preset" data-days="7"><?php esc_html_e('Last 7 Days', 'pinnerpress'); ?></button>
                    <button class="pinnerpress-date-preset active" data-days="30"><?php esc_html_e('Last 30 Days', 'pinnerpress'); ?></button>
                    <button class="pinnerpress-date-preset" data-days="90" <?php if (!$has_truly_premium) echo 'disabled'; ?>><?php esc_html_e('Last 90 Days', 'pinnerpress'); ?></button>
                </div>
            </div>
        </div>
        <!-- Summary Stats -->
        <div class="summary-stats" style="display: none;">
            <div class="stat-card">
                <h3><?php esc_html_e('Total Posts', 'pinnerpress'); ?></h3>
                <p class="stat-value" id="total-posts">0</p>
            </div>
            <?php /* DISABLED: Impressions tracking removed
            <div class="stat-card">
                <h3><?php esc_html_e('Total Impressions', 'pinnerpress'); ?></h3>
                <p class="stat-value" id="total-impressions">0</p>
            </div>
            */ ?>
            <div class="stat-card">
                <h3><?php esc_html_e('Total Clicks', 'pinnerpress'); ?></h3>
                <p class="stat-value" id="total-clicks">0</p>
            </div>
            <?php /* DISABLED: Conversion rate requires impressions
            <div class="stat-card">
                <h3><?php esc_html_e('Avg Conversion Rate', 'pinnerpress'); ?></h3>
                <p class="stat-value" id="avg-conversion">0%</p>
            </div>
            */ ?>
        </div>
        
        <!-- Export Controls - Moved below summary stats -->
        <div class="pinnerpress-post-controls">
            <div class="pinnerpress-controls-row">
                <div class="pinnerpress-posts-per-page">
                    <label for="posts-per-page"><?php esc_html_e('Show:', 'pinnerpress'); ?></label>
                    <select id="posts-per-page" class="posts-per-page-select <?php echo !$can_use_premium_features ? 'pinnerpress-premium-disabled' : ''; ?>" <?php echo !$can_use_premium_features ? 'disabled' : ''; ?>>
                        <option value="25" selected>25</option>
                        <?php if ($can_use_premium_features): ?>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        <?php endif; ?>
                    </select>
                    <span><?php esc_html_e('posts per page', 'pinnerpress'); ?></span>
                    <?php if (!$can_use_premium_features): ?>
                        <span class="pinnerpress-premium-badge">PRO</span>
                    <?php endif; ?>
                </div>
                <div class="pinnerpress-export-controls">
                    <button type="button" 
                            class="button <?php echo pinnerpress_is_feature_enabled('analytics_export_csv') ? 'pinnerpress-export-button' : 'pinnerpress-export-button pinnerpress-premium-disabled'; ?>" 
                            id="export-csv"
                            <?php echo !pinnerpress_is_feature_enabled('analytics_export_csv') ? 'disabled title="' . esc_attr__('Upgrade to Premium for CSV export', 'pinnerpress') . '"' : ''; ?>>
                        <?php esc_html_e('Export CSV', 'pinnerpress'); ?>
                        <?php if (!pinnerpress_is_feature_enabled('analytics_export_csv')): ?>
                            <span class="pinnerpress-premium-badge">PRO</span>
                        <?php endif; ?>
                    </button>
                </div>
            </div>
        </div>
        
        <!-- Posts Table Container -->
        <div class="post-analytics-container">
            <div class="pinnerpress-loading" style="display: none;">
                <span class="spinner is-active"></span>
                <?php esc_html_e('Loading post analytics data...', 'pinnerpress'); ?>
            </div>
            
            <!-- Posts Table -->
            <div class="post-table-container" style="display: none;">
                <table class="wp-list-table widefat fixed striped" id="post-analytics-table">
                    <thead>
                        <tr>
                            <th class="column-preview" style="width: 50px;"></th>
                            <th class="column-title sortable" data-sort="title">
                                <a href="#">
                                    <?php esc_html_e('Post Title', 'pinnerpress'); ?>
                                    <span class="sorting-indicator"></span>
                                </a>
                            </th>
                            <th class="column-pin-clicks sortable" data-sort="pin-clicks" style="width: 75px;">
                                <a href="#">
                                    <?php esc_html_e('Pin Clicks', 'pinnerpress'); ?>
                                    <span class="sorting-indicator"></span>
                                </a>
                            </th>
                            <th class="column-banner-clicks sortable" data-sort="banner-clicks" style="width: 75px;">
                                <a href="#">
                                    <?php esc_html_e('Banner Clicks', 'pinnerpress'); ?>
                                    <span class="sorting-indicator"></span>
                                </a>
                            </th>
                            <th class="column-follow-clicks sortable" data-sort="follow-clicks" style="width: 75px;">
                                <a href="#">
                                    <?php esc_html_e('Follow Clicks', 'pinnerpress'); ?>
                                    <span class="sorting-indicator"></span>
                                </a>
                            </th>
                            <th class="column-callout-clicks sortable" data-sort="callout-clicks" style="width: 75px;">
                                <a href="#">
                                    <?php esc_html_e('Callout Clicks', 'pinnerpress'); ?>
                                    <span class="sorting-indicator"></span>
                                </a>
                            </th>
                            <th class="column-block-clicks sortable" data-sort="block-clicks" style="width: 75px;">
                                <a href="#">
                                    <?php esc_html_e('Block Clicks', 'pinnerpress'); ?>
                                    <span class="sorting-indicator"></span>
                                </a>
                            </th>
                            <th class="column-actions" style="width: 70px;"><?php esc_html_e('Actions', 'pinnerpress'); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                        <!-- Table rows will be populated by JavaScript -->
                    </tbody>
                </table>
                
                <!-- Pagination Controls -->
                <div class="pinnerpress-pagination" style="display: none;">
                    <div class="pagination-info">
                        <span class="displaying-num"></span>
                    </div>
                    <div class="pagination-links">
                        <button class="button first-page" disabled>&laquo;</button>
                        <button class="button prev-page" disabled>&lsaquo;</button>
                        <span class="paging-input">
                            <span class="current-page-text"><?php esc_html_e('Page', 'pinnerpress'); ?></span>
                            <input type="number" class="current-page" value="1" min="1" style="width: 60px; text-align: center;">
                            <span class="total-pages-text"><?php esc_html_e('of', 'pinnerpress'); ?> <span class="total-pages">1</span></span>
                        </span>
                        <button class="button next-page" disabled>&rsaquo;</button>
                        <button class="button last-page" disabled>&raquo;</button>
                    </div>
                </div>
            </div>
            
            <!-- No Data Message -->
            <div class="no-data-message" style="display: none;">
                <p><?php esc_html_e('No analytics data found for the selected date range.', 'pinnerpress'); ?></p>
            </div>
        </div>
    </div>
</div>

<!-- Post Detail Modal -->
<div class="pinnerpress-post-detail-modal" style="display: none;">
    <div class="modal-content">
        <span class="close">&times;</span>
        <h2><?php esc_html_e('Post Analytics Details', 'pinnerpress'); ?></h2>
        <div class="modal-body">
            <!-- Modal content will be populated by JavaScript -->
        </div>
    </div>
</div>

<!-- Add nonce field -->
<?php wp_nonce_field('pinnerpress_analytics_nonce', 'pinnerpress_analytics_nonce'); ?>

<style>
/* Post Analytics Page Styles - Matching Image Analytics */
.pinnerpress-post-analytics-page {
    /* Post analytics specific styles */
}

/* Header styles are inherited from main admin CSS */

.pinnerpress-analytics-controls {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    overflow-x: auto;
}

.pinnerpress-post-controls {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 15px 20px;
    margin-bottom: 20px;
    margin-top: 20px;
    display: block;
    width: 100%;
    clear: both;
    box-sizing: border-box;
}

.pinnerpress-controls-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    width: 100%;
}

.pinnerpress-posts-per-page {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pinnerpress-posts-per-page .pinnerpress-premium-badge {
    display: inline-block;
    background: #E60023;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: 5px;
}

select.pinnerpress-premium-disabled {
    background-color: #f1f1f1;
    color: #999;
    cursor: not-allowed;
}

.pinnerpress-posts-per-page label {
    font-weight: 600;
}

.posts-per-page-select {
    min-width: 80px;
}

.pinnerpress-export-controls {
    margin-left: auto; /* Push export button to far right */
}

.pinnerpress-date-controls {
    margin-bottom: 0;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 15px;
}

.pinnerpress-date-controls label {
    font-weight: 600;
    white-space: nowrap;
}

.pinnerpress-date-controls input[type="date"] {
    margin-right: 5px;
    min-width: 130px;
}

.pinnerpress-free-date-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: nowrap;
}

.pinnerpress-free-date-controls input[type="date"]:disabled {
    background-color: #f1f1f1;
    color: #666;
    cursor: not-allowed;
}

.pinnerpress-locked-icon {
    font-size: 16px;
    cursor: help;
    color: #d63638;
}

.pinnerpress-date-presets {
    display: inline-flex;
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
    margin-left: auto;
}

.pinnerpress-date-preset {
    height: auto;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    line-height: 1.4;
}

.pinnerpress-date-preset {
    background-color: #fff !important;
    color: #E60023 !important;
    border: 1px solid #E60023 !important;
    transition: all 0.3s ease;
    text-decoration: none !important;
    box-shadow: none !important;
}

.pinnerpress-date-preset:hover:not(.pinnerpress-premium-disabled) {
    background-color: #E60023 !important;
    color: white !important;
}

.pinnerpress-date-preset.active {
    background-color: #E60023 !important;
    color: white !important;
}

.pinnerpress-date-preset.pinnerpress-premium-disabled {
    opacity: 0.6;
    cursor: not-allowed !important;
    background-color: #f1f1f1 !important;
    color: #999 !important;
    border-color: #ccc !important;
}

/* Summary Stats */
.summary-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
}

.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
    font-weight: 400;
    text-transform: uppercase;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: #E60023;
    margin: 0;
}

/* Table Container */
.post-analytics-container {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    padding: 0;
}

/* Table Styles - Matching Image Analytics */
.post-table-container {
    background: #fff;
    border-radius: 4px;
    padding: 20px;
    margin-top: 0;
    overflow-x: auto;
}

#post-analytics-table {
    background: #fff;
    border: none;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
}

#post-analytics-table th {
    background: #fff;
    border-bottom: 1px solid #ccd0d4;
    font-weight: 600;
    color: #23282d;
    text-align: center;
    vertical-align: middle;
}

#post-analytics-table th.sortable {
    cursor: pointer;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.2;
    padding: 12px 8px;
}

/* Remove hover background on table headers */
#post-analytics-table th.sortable:hover {
    background: #fff;
}

#post-analytics-table th.sortable a {
    text-decoration: none;
    color: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 4px 2px;
    line-height: 1.2;
    flex-direction: row-reverse;
    text-align: center;
    height: 100%;
    min-height: 40px;
}

/* Special alignment for title column */
#post-analytics-table th.column-title,
#post-analytics-table td.column-title {
    text-align: left !important;
}

#post-analytics-table th.column-title {
    text-align: left !important;
}

#post-analytics-table th.column-title a {
    justify-content: flex-start;
    padding-left: 4px;
    text-align: left;
    flex-direction: row;
}

/* Ensure title column content is left-aligned */
#post-analytics-table .column-title {
    text-align: left !important;
    vertical-align: middle;
}

#post-analytics-table .column-preview img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
}

#post-analytics-table .column-title {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#post-analytics-table .column-impressions,
#post-analytics-table .column-pin-clicks,
#post-analytics-table .column-pin-ctr,
#post-analytics-table .column-banner-clicks,
#post-analytics-table .column-banner-ctr,
#post-analytics-table .column-follow-clicks,
#post-analytics-table .column-follow-ctr,
#post-analytics-table .column-callout-clicks,
#post-analytics-table .column-callout-ctr,
#post-analytics-table .column-block-clicks,
#post-analytics-table .column-block-ctr,
#post-analytics-table .column-conversion,
#post-analytics-table .column-actions {
    text-align: center;
    vertical-align: middle;
}

/* Override for title column - force left alignment */
#post-analytics-table th.column-title,
#post-analytics-table td.column-title,
#post-analytics-table .column-title {
    text-align: left !important;
}



/* Additional table styling */
#post-analytics-table td {
    padding: 12px 8px;
    border-bottom: 1px solid #e1e1e1;
    vertical-align: middle;
}

#post-analytics-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#post-analytics-table tbody tr:hover {
    background: #f6f7f7;
}

.sorting-indicator {
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    margin-left: auto;
}

#post-analytics-table th.asc .sorting-indicator {
    border-bottom: 4px solid #E60023;
}

#post-analytics-table th.desc .sorting-indicator {
    border-top: 4px solid #E60023;
}

/* Action buttons styling */
#post-analytics-table .column-actions .button {
    padding: 6px 8px;
    margin-right: 4px;
    min-width: auto;
    background: transparent;
    border: none;
    box-shadow: none;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

#post-analytics-table .column-actions .button:last-child {
    margin-right: 0;
}

#post-analytics-table .column-actions .button .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
    line-height: 1;
    color: #E60023;
}

#post-analytics-table .column-actions .button:hover {
    background: rgba(230, 0, 35, 0.1);
    border-radius: 4px;
}

#post-analytics-table .column-actions .button:hover .dashicons {
    color: #bd051f;
}

/* CTR column styling */
#post-analytics-table .column-pin-ctr,
#post-analytics-table .column-banner-ctr,
#post-analytics-table .column-follow-ctr,
#post-analytics-table .column-callout-ctr,
#post-analytics-table .column-block-ctr {
    font-weight: 500;
}

#post-analytics-table .image-stats-cell {
    font-size: 12px;
    color: #666;
}

#post-analytics-table .image-stats-cell .stats-separator {
    color: #ddd;
    margin: 0 4px;
}

#post-analytics-table a.image-stats-cell {
    color: #666;
    text-decoration: none;
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

#post-analytics-table a.image-stats-cell:hover {
    background: #E60023;
    color: #fff;
}

#post-analytics-table a.image-stats-cell:hover .stats-separator {
    color: #fff;
}



#post-analytics-table .view-post-btn {
    font-size: 12px;
    padding: 4px 8px;
    height: auto;
    line-height: 1.5;
}

/* Modal Styles */
.pinnerpress-post-detail-modal {
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    overflow-y: auto;
}

.pinnerpress-post-detail-modal .modal-content {
    background-color: #fefefe;
    margin: 50px auto;
    padding: 0;
    border: 1px solid #888;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.pinnerpress-post-detail-modal .close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    padding: 10px 20px;
    cursor: pointer;
}

.pinnerpress-post-detail-modal .close:hover,
.pinnerpress-post-detail-modal .close:focus {
    color: #000;
}

.pinnerpress-post-detail-modal .modal-body {
    padding: 30px;
}

/* Loading State */
.pinnerpress-loading {
    text-align: center;
    padding: 40px;
}

.pinnerpress-loading .spinner {
    float: none;
    margin: 0 auto 10px;
}

/* No Data Message */
.no-data-message {
    text-align: center;
    padding: 40px;
    color: #666;
}

/* Conversion Rate Colors - Badge Style matching Image Analytics */
.conversion-rate {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

.conversion-rate.excellent {
    background-color: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
}

.conversion-rate.good {
    background-color: rgba(255, 152, 0, 0.1);
    color: #FF9800;
}

.conversion-rate.fair {
    background-color: rgba(255, 193, 7, 0.1);
    color: #FFC107;
}

.conversion-rate.poor {
    background-color: rgba(230, 0, 35, 0.1);
    color: #E60023;
}

/* Legacy class mappings for backward compatibility */
.conversion-rate.high {
    background-color: rgba(76, 175, 80, 0.1);
    color: #4CAF50;
}

.conversion-rate.medium {
    background-color: rgba(255, 152, 0, 0.1);
    color: #FF9800;
}

.conversion-rate.low {
    background-color: rgba(230, 0, 35, 0.1);
    color: #E60023;
}

/* Default placeholder image */
.default-placeholder {
    width: 40px;
    height: 40px;
    background: #f0f0f0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 12px;
}

/* Export button styling - outline style */
.pinnerpress-export-button {
    background-color: #ffffff !important;
    color: #E60023 !important;
    border: 1px solid #E60023 !important;
    padding: 4px 12px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: all 0.3s ease;
    text-shadow: none !important;
    box-shadow: none !important;
}

.pinnerpress-export-button:hover {
    background-color: #E60023 !important;
    color: #ffffff !important;
    border-color: #E60023 !important;
}

.pinnerpress-export-button:focus {
    outline: none !important;
    box-shadow: 0 0 0 2px rgba(230, 0, 35, 0.3) !important;
}

.pinnerpress-export-button:disabled {
    background-color: #f1f1f1 !important;
    color: #cccccc !important;
    border-color: #cccccc !important;
    cursor: not-allowed !important;
}

/* Pagination Styles */
.pinnerpress-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.pagination-info {
    color: #666;
}

.pagination-links {
    display: flex;
    align-items: center;
    gap: 5px;
}

.pagination-links .button {
    padding: 4px 8px;
    min-width: 30px;
    height: 30px;
    line-height: 1;
}

.pagination-links .button:disabled {
    opacity: 0.5;
    cursor: default;
}

.paging-input {
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0 10px;
}

.current-page {
    padding: 4px 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
}

@media (max-width: 782px) {
    .pinnerpress-pagination {
        flex-direction: column;
        gap: 15px;
    }
    
    .pinnerpress-controls-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pinnerpress-posts-per-page {
        justify-content: center;
    }
    
    .pinnerpress-export-controls {
        margin-left: 0;
        text-align: center;
        margin-top: 10px;
    }
    
    .pinnerpress-export-button {
        width: 100%;
    }
    
    .pinnerpress-post-controls {
        margin-top: 0;
    }
}
</style>
    </div> <!-- Close pinnerpress-admin-content --> 