<?php
/**
 * Carts template.
 *
 * @package CartNinjaRecovery
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
?>
<div class="wrap cartninja-wrap">
	<h1 class="screen-reader-text"><?php esc_html_e( 'Abandoned Carts', 'cartninja-recovery-for-woocommerce' ); ?></h1>
	<div class="cartninja-page-hero cartninja-page-hero--carts">
		<div class="cartninja-page-hero__content">
			<span class="cartninja-page-hero__eyebrow"><?php esc_html_e( 'Recovery Queue', 'cartninja-recovery-for-woocommerce' ); ?></span>
			<div class="cartninja-hero-title"><?php esc_html_e( 'Abandoned Carts', 'cartninja-recovery-for-woocommerce' ); ?></div>
			<p><?php esc_html_e( 'Review abandoned sessions, inspect reminder delivery, and jump into a specific cart record when you need to troubleshoot or follow up.', 'cartninja-recovery-for-woocommerce' ); ?></p>
		</div>
		<div class="cartninja-page-hero__badge">
			<span class="dashicons dashicons-list-view" aria-hidden="true"></span>
			<div>
				<strong><?php echo esc_html( $list_table->get_pagination_arg( 'total_items' ) ); ?></strong>
				<p><?php esc_html_e( 'Visible cart records', 'cartninja-recovery-for-woocommerce' ); ?></p>
			</div>
		</div>
	</div>
	<?php if ( isset( $_GET['deleted'] ) ) : ?>
		<div class="notice notice-success is-dismissible"><p><?php esc_html_e( 'Cart deleted.', 'cartninja-recovery-for-woocommerce' ); ?></p></div>
	<?php endif; ?>
	<?php if ( isset( $_GET['cartninja_resend_done'] ) ) : ?>
		<div class="notice <?php echo '1' === sanitize_text_field( wp_unslash( $_GET['cartninja_resend_done'] ) ) ? 'notice-success' : 'notice-error'; ?> is-dismissible"><p><?php echo '1' === sanitize_text_field( wp_unslash( $_GET['cartninja_resend_done'] ) ) ? esc_html__( 'Reminder resent.', 'cartninja-recovery-for-woocommerce' ) : esc_html__( 'Reminder could not be resent.', 'cartninja-recovery-for-woocommerce' ); ?></p></div>
	<?php endif; ?>
	<div class="cartninja-table-shell">
		<div class="cartninja-table-shell__head">
			<div>
				<h2><?php esc_html_e( 'Cart Records', 'cartninja-recovery-for-woocommerce' ); ?></h2>
				<p><?php esc_html_e( 'Use filters to narrow the list and the reminder icons to quickly spot delivery state.', 'cartninja-recovery-for-woocommerce' ); ?></p>
			</div>
		</div>
		<form method="get">
			<input type="hidden" name="page" value="cartninja-carts" />
			<?php $list_table->display(); ?>
		</form>
	</div>
	<div class="cartninja-modal" id="cartninja-cart-modal" hidden>
		<div class="cartninja-modal__backdrop"></div>
		<div class="cartninja-modal__dialog" role="dialog" aria-modal="true" aria-labelledby="cartninja-cart-modal-title">
			<button type="button" class="cartninja-modal__close" aria-label="<?php esc_attr_e( 'Close cart inspector', 'cartninja-recovery-for-woocommerce' ); ?>">
				<span class="dashicons dashicons-no-alt" aria-hidden="true"></span>
			</button>
			<div class="cartninja-modal__content" id="cartninja-cart-modal-content">
				<div class="cartninja-cart-details cartninja-cart-details--drawer">
					<div class="cartninja-cart-details__head">
						<div>
							<span class="cartninja-page-hero__eyebrow"><?php esc_html_e( 'Cart Inspector', 'cartninja-recovery-for-woocommerce' ); ?></span>
							<h2 id="cartninja-cart-modal-title"><?php esc_html_e( 'Cart Details', 'cartninja-recovery-for-woocommerce' ); ?></h2>
						</div>
					</div>
					<p><?php esc_html_e( 'Loading cart details...', 'cartninja-recovery-for-woocommerce' ); ?></p>
				</div>
			</div>
		</div>
	</div>
</div>
