<?php
/**
 * Livada SEO — Admin Header partial
 *
 * Renders the hero banner + tabs navigation. Include from any settings view:
 *
 *     <div class="wrap livada-seo-wrap has-ls-hero">
 *         <?php include LIVADA_SEO_PATH . 'includes/admin/views/_partials/header.php'; ?>
 *         ...
 *     </div>
 *
 * No mutation of globals, no echoed wrap — caller is responsible for the .wrap.
 *
 * @package Livada_SEO
 */

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

// Current page slug. Defaults to the dashboard.
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
$ls_page    = isset( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : 'livada-seo';
$ls_version = defined( 'LIVADA_SEO_VERSION' ) ? LIVADA_SEO_VERSION : '';

/**
 * Tab definitions: slug => [ label, dashicon ].
 * Order = navigation order. Active state derived from $ls_page.
 */
$ls_tabs = [
	'livada-seo'           => [ __( 'Dashboard',     'livada-seo' ), 'dashboard'        ],
	'livada-seo-titles'    => [ __( 'Titles & Metas','livada-seo' ), 'editor-textcolor' ],
	'livada-seo-schema'    => [ __( 'Schema',        'livada-seo' ), 'screenoptions'    ],
	'livada-seo-locations' => [ __( 'Locations',     'livada-seo' ), 'location-alt'     ],
	'livada-seo-social'    => [ __( 'Social',        'livada-seo' ), 'share'            ],
	'livada-seo-sitemap'   => [ __( 'Sitemap',       'livada-seo' ), 'networking'       ],
	'livada-seo-redirects' => [ __( 'Redirections',  'livada-seo' ), 'randomize'        ],
	'livada-seo-robots'    => [ __( 'Robots.txt',    'livada-seo' ), 'media-text'       ],
	'livada-seo-audit'     => [ __( 'Site Audit',    'livada-seo' ), 'clipboard'        ],
	'livada-seo-general'   => [ __( 'General',       'livada-seo' ), 'admin-generic'    ],
	'livada-seo-tools'     => [ __( 'Tools',         'livada-seo' ), 'admin-tools'      ],
	'livada-seo-license'   => [ __( 'Licence',       'livada-seo' ), 'awards'           ],
];

// Subtitle per page (concise hint shown under the hero title).
$ls_subtitles = [
	'livada-seo'           => __( 'SEO + AEO for WordPress — overview & quick wins.', 'livada-seo' ),
	'livada-seo-titles'    => __( 'Templates for document titles & meta descriptions.', 'livada-seo' ),
	'livada-seo-schema'    => __( 'Structured data — LocalBusiness, Organization, services.', 'livada-seo' ),
	'livada-seo-locations' => __( 'Multi-location LocalBusiness — one plugin, N establishments.', 'livada-seo' ),
	'livada-seo-social'    => __( 'Open Graph & Twitter Card — how your pages share.', 'livada-seo' ),
	'livada-seo-sitemap'   => __( 'XML sitemap configuration & inventory.', 'livada-seo' ),
	'livada-seo-redirects' => __( 'Redirections 301/302 — keep your link equity.', 'livada-seo' ),
	'livada-seo-robots'    => __( 'Virtual robots.txt — control what crawlers see.', 'livada-seo' ),
	'livada-seo-audit'     => __( 'Site-wide SEO audit — issues & quick fixes.', 'livada-seo' ),
	'livada-seo-general'   => __( 'Global settings & enabled modules.', 'livada-seo' ),
	'livada-seo-tools'     => __( 'Import, export, reset, IndexNow.', 'livada-seo' ),
	'livada-seo-license'   => __( 'Manage your Livada SEO licence.', 'livada-seo' ),
];

$ls_subtitle = $ls_subtitles[ $ls_page ] ?? __( 'SEO + AEO for WordPress.', 'livada-seo' );
?>
<div class="ls-hero">
	<div class="ls-hero__inner">
		<div class="ls-hero__brand">
			<span class="ls-hero__logo" aria-hidden="true">
				<svg viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
					<circle cx="24" cy="24" r="18"/>
					<line x1="17" y1="29" x2="17" y2="33"/>
					<line x1="24" y1="22" x2="24" y2="33"/>
					<line x1="31" y1="14" x2="31" y2="33"/>
					<line x1="37" y1="37" x2="51" y2="51"/>
				</svg>
			</span>
			<div>
				<h1 class="ls-hero__title"><?php esc_html_e( 'Livada SEO', 'livada-seo' ); ?></h1>
				<p class="ls-hero__subtitle"><?php echo esc_html( $ls_subtitle ); ?></p>
			</div>
		</div>
		<div class="ls-hero__meta">
			<?php if ( '' !== $ls_version ) : ?>
				<span class="ls-badge ls-badge--version">v<?php echo esc_html( $ls_version ); ?></span>
			<?php endif; ?>
			<span class="ls-badge"><?php esc_html_e( 'SEO + AEO', 'livada-seo' ); ?></span>
			<span class="ls-badge ls-badge--pro"><?php esc_html_e( 'Made in France', 'livada-seo' ); ?></span>
		</div>
	</div>
</div>

<nav class="ls-tabs" aria-label="<?php esc_attr_e( 'Livada SEO sections', 'livada-seo' ); ?>">
	<?php foreach ( $ls_tabs as $slug => $meta ) :
		[ $label, $icon ] = $meta;
		$is_active = ( $slug === $ls_page );
		$class     = 'ls-tab' . ( $is_active ? ' is-active' : '' );
		$url       = admin_url( 'admin.php?page=' . $slug );
	?>
		<a class="<?php echo esc_attr( $class ); ?>"
		   href="<?php echo esc_url( $url ); ?>"
		   <?php echo $is_active ? 'aria-current="page"' : ''; ?>>
			<span class="dashicons dashicons-<?php echo esc_attr( $icon ); ?> ls-tab__icon" aria-hidden="true"></span>
			<?php echo esc_html( $label ); ?>
		</a>
	<?php endforeach; ?>
</nav>
