<?php
if (!defined('ABSPATH')) exit;

/**
 * FormForge admin section tabs. Renders a horizontal nav bar on every
 * plugin admin page so users can hop between sections without going back
 * to the WP sidebar menu.
 */
class FORMFORGE_Admin_Tabs {

    private static $styles_printed = false;

    public static function tabs() {
        return [
            ['slug' => 'formforge',             'label' => __('All Forms', 'formforge'),    'pro' => false],
            ['slug' => 'formforge-new',         'label' => __('New Form', 'formforge'),     'pro' => false],
            ['slug' => 'formforge-submissions', 'label' => __('Submissions', 'formforge'),  'pro' => false],
            ['slug' => 'formforge-analytics',   'label' => __('Analytics', 'formforge'),    'pro' => true],
            ['slug' => 'formforge-settings',    'label' => __('Settings', 'formforge'),     'pro' => false],
        ];
    }

    public static function render($current = null) {
        // (2026-05-05): the entire top-tabs strip was retired.
        // FormForge has no nested hubs (unlike SEO Forge after ) —
        // every section is now a top-level WP sidebar entry. The
        // duplicated tab strip across the top of every page was the
        // tester's main split-brain complaint, plus it carried a
        // redundant [PRO] badge that the sidebar didn't match. Render
        // method left in place (silently no-op) so we don't have to
        // touch the 5 call-sites scattered across `class-admin.php`.
        return;
    }

    private static function print_styles() {
        if (self::$styles_printed) return;
        self::$styles_printed = true;
        ?>
        <style id="forge-tabs-css">
            /* Freemius `fs-notice.fs-has-title` notices position the plugin-title
 pill `position:absolute; top:100%` and the 30px reserved margin-
 bottom isn't enough to keep the pill off our tabs row below.
 The pill is redundant info (the notice body already says what
 plugin upgraded), so hide it cleanly to remove the overlap. */
            .fs-notice .fs-plugin-title {
                display: none !important;
            }
            .fs-notice.fs-has-title {
                margin-bottom: 0 !important;
            }
            .forge-tabs {
                display: flex;
                gap: 2px;
                margin: 6px 0 20px;
                font-size: 14px;
                /* Pages like Content Brief / Site Audit / Local SEO wrap body
 copy in <div class="wrap" style="max-width:860px"> for
 readability. Keep the tab row on one line; the :has rule
 below lets the wrap auto-grow to fit. */
                flex-wrap: nowrap;
                background: #fff;
                padding: 4px 6px 0;
                align-items: flex-end;
                border: 1px solid #e5e7eb;
                border-radius: 8px;
                box-shadow: 0 1px 2px rgba(15,23,42,.04);
            }
            .forge-tabs .forge-tab {
                padding: 9px 14px;
                text-decoration: none !important;
                color: #50575e;
                border: 0;
                box-shadow: inset 0 -2px 0 transparent;
                transition: color .12s ease, box-shadow .12s ease, background .12s ease;
                display: inline-flex;
                align-items: center;
                gap: 6px;
                line-height: 1.3;
                white-space: nowrap;
                border-radius: 6px 6px 0 0;
            }
            .forge-tabs .forge-tab:hover,
            .forge-tabs .forge-tab:focus {
                color: #1d2327;
                background: #f3f4f6;
                text-decoration: none !important;
                outline: none;
            }
            .forge-tabs .forge-tab.is-active {
                color: var(--forge-tab-accent, #2271b1);
                box-shadow: inset 0 -2px 0 var(--forge-tab-accent, #2271b1);
                background: transparent;
            }
            /* Grid stack: ghost bold text reserves width so active state doesn't reflow. */
            .forge-tabs .forge-tab__label { display: inline-grid; grid-template-areas: 'stack'; }
            .forge-tabs .forge-tab__label > span,
            .forge-tabs .forge-tab__label::before { grid-area: stack; }
            .forge-tabs .forge-tab__label::before { content: attr(data-label); font-weight: 600; visibility: hidden; pointer-events: none; }
            .forge-tabs .forge-tab.is-active .forge-tab__label > span { font-weight: 600; }
            .forge-tabs .forge-tab-pro {
                font-size: 14px;
                padding: 2px 5px;
                background: #fff4e5;
                color: #b45309;
                border: 1px solid #fcd9a8;
                border-radius: 3px;
                letter-spacing: .4px;
                font-weight: 700;
                text-transform: uppercase;
                line-height: 1;
            }
            .lf-forge-tabs  { --forge-tab-accent: #0e8a7a; }
            .sf-forge-tabs  { --forge-tab-accent: #e67e22; }
            .ff-forge-tabs  { --forge-tab-accent: #2271b1; }
            .fdf-forge-tabs { --forge-tab-accent: #d14578; }
            /* Inline max-width on .wrap shouldn't squash the tabs row. Grow
 the wrap to at least the tabs' intrinsic width; content inside
 the wrap that wants to stay narrow can set its own max-width. */
            .wrap:has(> .forge-tabs) {
                min-width: min-content;
            }
        </style>
        <?php
    }
}
