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

$title = $ctx['title'] ?? __('BLR Backline', 'blr-backline');
$nav = $ctx['nav'] ?? [];
$page = $ctx['page'] ?? '';
$dashboard_slug = $ctx['dashboard_slug'] ?? 'blr-backline';
$theme_mode = \BLR\Backline\Core\SettingsPage::current_theme_mode();

\BLR\Backline\Core\Assets::set_frontend_context('app');
?>
<!DOCTYPE html>
<html <?php language_attributes(); ?> data-blr-theme="<?php echo esc_attr($theme_mode); ?>" data-bs-theme="<?php echo esc_attr($theme_mode); ?>">
<head>
  <meta charset="<?php echo esc_attr(get_bloginfo('charset')); ?>">
  <meta name="viewport" content="width=device-width,initial-scale=1">
  <title><?php echo esc_html($title); ?></title>

  <?php wp_head(); ?>
</head>
<body class="blr-ba-app" data-blr-theme="<?php echo esc_attr($theme_mode); ?>" data-bs-theme="<?php echo esc_attr($theme_mode); ?>">
<?php if (function_exists('wp_body_open')) { wp_body_open(); } ?>

<div class="wrapper">
  <?php include BLR_BA_DIR . 'app/Views/partials/sidebar.php'; ?>
  <div class="main">
    <?php include BLR_BA_DIR . 'app/Views/partials/navbar.php'; ?>
    <main class="content blr-content-shell">
    <div id="blr-content-loader" class="blr-content-loader" aria-hidden="true">
      <div class="blr-content-loader__spinner"></div>
    </div>
      <?php
      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Trusted plugin-rendered HTML from internal view templates.
      echo $ctx['page_html'] ?? '';
      ?>
    </main>
    <?php include BLR_BA_DIR . 'app/Views/partials/footer.php'; ?>
  </div>
</div>

<div class="modal fade" id="blr-ba-delete-modal" tabindex="-1" aria-hidden="true">
  <div class="modal-dialog modal-dialog-centered">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title"><?php echo esc_html__('Delete item?', 'blr-backline'); ?></h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="<?php echo esc_attr__('Close', 'blr-backline'); ?>"></button>
      </div>
      <div class="modal-body">
        <p class="mb-0" id="blr-ba-delete-text"><?php echo esc_html__('This permanently deletes the record. Some deletes also remove plugin-owned media and linked attachments.', 'blr-backline'); ?></p>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-outline-secondary" data-bs-dismiss="modal"><?php echo esc_html__('Cancel', 'blr-backline'); ?></button>
        <button type="button" class="btn btn-danger" id="blr-ba-delete-confirm"><?php echo esc_html__('Delete', 'blr-backline'); ?></button>
      </div>
    </div>
  </div>
</div>

<?php wp_footer(); ?>
</body>
</html>