<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}
$avi_lang = 'en';
if ( function_exists( 'avi_get_current_lang' ) ) { $avi_lang = avi_get_current_lang(); }
if ( $avi_lang === 'en' && isset( $_SERVER['REQUEST_URI'] ) ) {
    $req = $_SERVER['REQUEST_URI'];
    if ( strpos( $req, '/fr/' ) === 0 ) { $avi_lang = 'fr'; }
    elseif ( strpos( $req, '/es/' ) === 0 ) { $avi_lang = 'es'; }
}
if ( $avi_lang !== 'en' ) { set_query_var( 'avi_lang', $avi_lang ); }
$is_fr = ( $avi_lang === 'fr' );
$is_es = ( $avi_lang === 'es' );

$avi_meta_title = 'Contact — Avision';
$avi_meta_desc  = 'Get in touch with Avision. Questions about your account, billing, API security, partnerships, or anything else — we respond within 72 hours.';
$avi_schema_json = array(
	'@context' => 'https://schema.org',
	'@type'    => 'ContactPage',
	'name'     => 'Contact — Avision',
	'url'      => 'https://avision.org/contact/',
);

if ( ! class_exists( 'Avision_Page_Template' ) ) {
	require_once AVISION_PLUGIN_DIR . 'includes/class-avision-page-template.php';
}

$hero = array(
	'badge' => 'Get in touch',
	'title' => 'Contact Avision',
	'align' => 'center',
	'size'  => 'small',
);

$avi_contact_departments = array(
	array(
		'icon'    => '🔐',
		'title'   => 'Privacy & Data Requests',
		'desc'    => 'GDPR data access, export, or deletion requests. API data policy questions.',
		'subject' => 'Privacy+Request',
	),
	array(
		'icon'    => '🛡️',
		'title'   => 'API Security',
		'desc'    => 'Questions about our Google OAuth integration, data handling, or security practices.',
		'subject' => 'API+Security',
	),
	array(
		'icon'    => '💼',
		'title'   => 'Agency Partnerships',
		'desc'    => 'Wholesale pricing, custom contracts, or agency onboarding.',
		'subject' => 'Agency+Partnership',
	),
	array(
		'icon'    => '🤝',
		'title'   => 'Nonprofits Program',
		'desc'    => 'Applications for the 50% nonprofit discount program.',
		'subject' => 'Nonprofit+Application',
	),
	array(
		'icon'    => '🐛',
		'title'   => 'Technical Support',
		'desc'    => 'Bug reports, account issues, or technical problems.',
		'subject' => 'Support',
	),
	array(
		'icon'    => '📢',
		'title'   => 'General Inquiries',
		'desc'    => 'Press, partnerships, or anything else.',
		'subject' => 'General',
	),
);

Avision_Page_Template::render(
	'contact',
	$hero,
	static function () use ( $avi_schema_json, $avi_contact_departments ) {
		?>
		<style>
			.avi-contact-page__support-wrap { max-width: 640px; margin: 0 auto 40px; }
			.avi-contact-page__support {
				background: #0f1e35;
				border-left: 4px solid #6C3FC5;
				border-radius: 12px;
				padding: 32px 36px;
			}
			.avi-contact-page__support h2 {
				margin: 0 0 16px;
				font-size: 20px;
				font-weight: 800;
				color: #ffffff;
				line-height: 1.3;
			}
			.avi-contact-page__support p {
				margin: 0 0 14px;
				color: #cbd5e1;
				line-height: 1.8;
				font-size: 15px;
			}
			.avi-contact-page__support p:last-child { margin-bottom: 0; }
			.avi-contact-page__support a {
				color: #F59E0B;
				text-decoration: none;
				font-weight: 600;
			}
			.avi-contact-page__support a:hover { text-decoration: underline; }
			.avi-contact-page__support strong.avi-contact-page__hours { color: #ffffff; font-weight: 700; }
			.avi-contact-page__support em.avi-contact-page__personal { color: #94a3b8; font-style: italic; }
		</style>
		<section class="avi-content-section" style="padding-top:32px !important;padding-bottom:56px !important">
			<div class="avi-container">

				<div style="text-align:center;margin-bottom:40px">
					<div style="font-size:36px;margin-bottom:10px">✉️</div>
					<a href="mailto:contact@avision.org"
					   style="font-size:18px;font-weight:700;
							  color:var(--avi-text,#fff);
							  text-decoration:none;
							  border-bottom:2px solid var(--avi-accent,#F0A030);
							  padding-bottom:2px">
						contact@avision.org
					</a>
					<p style="margin-top:8px;
							  color:var(--avi-text-muted,#A0B4D0);
							  font-size:13px">
						We respond within 72 hours · Advantage Synergies LLP, London
					</p>
				</div>

				<div class="avi-contact-page__support-wrap">
					<div class="avi-contact-page__support">
						<h2>How support works</h2>
						<p>AVI handles first-line support directly from your dashboard — ask any question about your profile, your plan, or how the platform works, and AVI answers instantly with real data from your account.</p>
						<p>For anything AVI can't resolve — billing, account issues, technical problems — reach the founder directly at <a href="mailto:contact@avision.org">contact@avision.org</a>.</p>
						<p>Response within <strong class="avi-contact-page__hours">72 business hours</strong>, guaranteed. <em class="avi-contact-page__personal">Handled personally.</em></p>
					</div>
				</div>

				<div class="avi-grid avi-grid--auto" style="margin-bottom:40px">
					<?php foreach ( $avi_contact_departments as $dept ) : ?>
						<div class="avi-card">
							<div style="font-size:28px;margin-bottom:10px"><?php echo esc_html( $dept['icon'] ); ?></div>
							<h3 style="font-size:15px;margin-bottom:8px;color:var(--avi-text,#fff)">
								<?php echo esc_html( $dept['title'] ); ?>
							</h3>
							<p style="font-size:13px;line-height:1.6;color:var(--avi-text-muted,#A0B4D0);margin-bottom:12px">
								<?php echo esc_html( $dept['desc'] ); ?>
							</p>
							<a href="<?php echo esc_url( 'mailto:contact@avision.org?subject=' . $dept['subject'] ); ?>"
							   style="font-size:12px;color:var(--avi-primary-light,#6B9FE8);text-decoration:none">
								Send email →
							</a>
						</div>
					<?php endforeach; ?>
				</div>

				<div class="avi-info-card" style="text-align:center;max-width:600px;margin:0 auto">
					<p style="color:var(--avi-text-muted,#A0B4D0);font-size:14px;margin:0">
						<strong style="color:var(--avi-text,#fff)">Response time:</strong>
						72 hours for all inquiries. Privacy and data requests handled within 48 hours (GDPR Art. 12).
					</p>
				</div>

			</div>
		</section>
		<script type="application/ld+json"><?php echo wp_json_encode( $avi_schema_json, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE ); ?></script>
		<?php
	}
);
