<?php
if (!defined('ABSPATH')) exit;
if (!isset($white_label_name)) {
    require_once MEMENTOR_TTS_PLUGIN_DIR . 'admin/partials/header-branding.php';
}

// Per-request connection state — used for the onboarding banner + gated-page lock.
$tts_is_connected = ( 'connected' === Mementor_TTS_Connect::get_connection_status() );

// Pages can suppress the auto-injected banner with: $tts_hide_onboarding = true;
// (The partial still loads on disconnected pages so its shared CSS is available — it just skips the banner HTML.)
// Pages that should be greyed-out while disconnected set: $tts_requires_connection = true;
$tts_lock_class = ( ! $tts_is_connected && ! empty( $tts_requires_connection ) ) ? ' is-locked' : '';
?>
<div class="tts-admin-wrap">
  <?php include MEMENTOR_TTS_PLUGIN_DIR . 'admin/partials/sidebar.php'; ?>
  <div class="tts-main">
    <?php if (empty($tts_hide_topbar)) : ?>
    <div class="tts-topbar">
      <div class="tts-topbar-left">
        <span class="tts-topbar-title"><?php echo esc_html($tts_page_title); ?></span>
        <?php if ( ! empty( $tts_topbar_meta ) ) : ?>
          <div class="tts-topbar-meta"><?php
            echo wp_kses( $tts_topbar_meta, array(
              'span'   => array( 'class' => true ),
              'strong' => array( 'class' => true ),
              'a'      => array( 'href' => true, 'class' => true, 'target' => true, 'rel' => true ),
            ) );
          ?></div>
        <?php endif; ?>
      </div>
      <div class="tts-topbar-actions">
        <?php
        if (!empty($tts_topbar_actions)) {
            echo wp_kses($tts_topbar_actions, array(
                'button' => array(
                    'type'     => true,
                    'form'     => true,
                    'class'    => true,
                    'id'       => true,
                    'title'    => true,
                    'onclick'  => true,
                    'disabled' => true,
                ),
                'input' => array(
                    'type'   => true,
                    'id'     => true,
                    'class'  => true,
                    'name'   => true,
                    'accept' => true,
                    'style'  => true,
                ),
                'a' => array(
                    'href'   => true,
                    'class'  => true,
                    'id'     => true,
                    'target' => true,
                    'rel'    => true,
                ),
                'span' => array(
                    'class' => true,
                    'id'    => true,
                ),
            ));
        }
        ?>
      </div>
    </div>
    <?php endif; ?>
    <div class="tts-main-content<?php echo esc_attr( $tts_lock_class ); ?>">
    <?php if ( ! $tts_is_connected ) { include MEMENTOR_TTS_PLUGIN_DIR . 'admin/partials/onboarding-banner.php'; } ?>
