<?php
/**
 * Shared Store Navigation Bar — slim strip
 * Include at the top of any store-related admin view.
 * Auto-detects the active tab from the current URI.
 */
$_ci  =& get_instance();
$_uri = $_ci->uri->uri_string();

$_store_nav_items = [
    ['icon' => 'bi-speedometer2',   'label' => __('admin.overview'),            'url' => base_url('admincontrol/store_dashboard'), 'match' => ['store_dashboard']],
    ['icon' => 'bi-box-seam',       'label' => __('admin.store_cart_products'), 'url' => base_url('admincontrol/listproduct'),     'match' => ['listproduct']],
    ['icon' => 'bi-bag-check',      'label' => __('admin.store_sales_products'),'url' => base_url('Productsales/index'),           'match' => ['Productsales', 'productsales', 'product_campaign', 'product_campaign/form']],
    ['icon' => 'bi-cart3',          'label' => __('admin.orders'),              'url' => base_url('admincontrol/listorders'),      'match' => ['listorders']],
    ['icon' => 'bi-tags',           'label' => __('admin.categories'),          'url' => base_url('admincontrol/store_category'), 'match' => ['store_category']],
    ['icon' => 'bi-people',         'label' => __('admin.clients'),             'url' => base_url('admincontrol/listclients'),     'match' => ['listclients']],
    ['icon' => 'bi-graph-up-arrow', 'label' => __('admin.store_analytics'),     'url' => base_url('admincontrol/store_analytics'),'match' => ['store_analytics']],
    ['icon' => 'bi-gear-fill',      'label' => __('admin.store_settings'),      'url' => base_url('admincontrol/store_setting'),   'match' => ['store_setting']],
    ['icon' => 'bi-funnel-fill',    'label' => __('admin.nav_sales_funnels'),   'url' => base_url('admincontrol/sales_funnels'),    'match' => ['sales_funnels']],
    ['icon' => 'bi-tag-fill',       'label' => __('admin.funnel_pricing'),      'url' => base_url('admincontrol/funnel_pricing'),   'match' => ['funnel_pricing']],
];
?>
<div style="background:#1e3a5f;border-bottom:3px solid #2d5986;margin-bottom:16px;">
    <div style="display:flex;align-items:center;overflow-x:auto;scrollbar-width:none;-ms-overflow-style:none;white-space:nowrap;">
        <!-- Store logo / back link -->
        <a href="<?= base_url('admincontrol/store_dashboard') ?>"
           style="display:inline-flex;align-items:center;gap:6px;padding:0 14px;height:40px;color:rgba(255,255,255,.9);text-decoration:none;font-size:.78rem;font-weight:700;border-right:1px solid rgba(255,255,255,.15);flex-shrink:0;letter-spacing:.3px;">
            <i class="bi bi-shop" style="font-size:.9rem;"></i>
            <span class="d-none d-md-inline"><?= __('admin.store') ?></span>
        </a>
        <!-- Tabs -->
        <?php foreach ($_store_nav_items as $_snNav):
            $_snActive = false;
            foreach ($_snNav['match'] as $_m) {
                if (strpos($_uri, $_m) !== false) { $_snActive = true; break; }
            }
            $tabStyle = $_snActive
                ? 'color:#fff;border-bottom:3px solid #ffc107;font-weight:700;margin-bottom:-3px;'
                : 'color:rgba(255,255,255,.65);border-bottom:3px solid transparent;margin-bottom:-3px;';
        ?>
        <a href="<?= $_snNav['url'] ?>"
           style="display:inline-flex;align-items:center;gap:5px;padding:0 13px;height:40px;font-size:.78rem;text-decoration:none;flex-shrink:0;transition:color .15s;<?= $tabStyle ?>">
            <i class="bi <?= $_snNav['icon'] ?>" style="font-size:.8rem;"></i>
            <span><?= $_snNav['label'] ?></span>
        </a>
        <?php endforeach; ?>
        <!-- Open store link at the far right -->
        <div style="margin-left:auto;padding:0 10px;flex-shrink:0;">
            <a href="<?= base_url('store') ?>" target="_blank"
               style="display:inline-flex;align-items:center;gap:4px;font-size:.75rem;color:rgba(255,255,255,.55);text-decoration:none;">
                <i class="bi bi-box-arrow-up-right"></i>
                <span class="d-none d-lg-inline"><?= __('admin.view_store') ?></span>
            </a>
        </div>
    </div>
</div>
