<?php
/**
 * Shared Header Include for Service Pages
 * Fetches site settings from DB if available, falls back to defaults
 */
if (!isset($conn)) {
    // Try to load config
    $config_path = dirname(__DIR__) . '/titancore/titanconfig.php';
    if (file_exists($config_path)) {
        require_once $config_path;
    }
}

// Load site settings
if (isset($conn)) {
    $sql = "SELECT site_name, phone, email, address FROM settings WHERE id = 1";
    $result = $conn->query($sql);
    if ($result && $result->num_rows > 0) {
        $settings = $result->fetch_assoc();
        $site_name = $settings['site_name'];
        $phone = $settings['phone'];
        $email = $settings['email'];
        $address = $settings['address'];
    }
}

// Defaults
if (empty($site_name)) { $site_name = "TITAN PRINT PORTAL"; }
if (empty($phone))     { $phone = "9142531828"; }
if (empty($email))     { $email = "support@yourwebsite.com"; }
if (empty($address))   { $address = "Your Office Address, India"; }

// Path offset for assets (services/ is one level down)
$base = '../';
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="theme-color" content="#4361ee">
    <meta name="description" content="<?php echo isset($page_desc) ? htmlspecialchars($page_desc) : htmlspecialchars($site_name) . ' - Professional document printing services'; ?>">

    <!-- Favicons -->
    <link rel="apple-touch-icon" sizes="180x180" href="<?php echo $base; ?>assets/img/favicons/apple-touch-icon.png">
    <link rel="icon" type="image/png" sizes="32x32" href="<?php echo $base; ?>assets/img/favicons/favicon-32x32.png">
    <link rel="shortcut icon" href="<?php echo $base; ?>assets/img/favicons/favicon.ico">

    <title><?php echo isset($page_title) ? htmlspecialchars($page_title) . ' | ' . htmlspecialchars($site_name) : htmlspecialchars($site_name); ?></title>

    <!-- Fonts & Icons -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <!-- Service CSS -->
    <link rel="stylesheet" href="<?php echo $base; ?>assets/css/services.css">
</head>
<body>

<!-- Skip Navigation (Accessibility) -->
<a href="#main-content" class="skip-to-content" style="position:absolute;top:-40px;left:6px;background:#4361ee;color:white;padding:8px;border-radius:4px;text-decoration:none;z-index:1001;">Skip to content</a>

<!-- HEADER -->
<header id="site-header">
    <div class="container">
        <div class="header-container">
            <!-- Logo -->
            <a href="<?php echo $base; ?>index.php" class="logo" aria-label="<?php echo htmlspecialchars($site_name); ?> - Home">
                <svg width="38" height="38" viewBox="0 0 50 50" aria-hidden="true">
                    <circle cx="25" cy="25" r="23" fill="#4361ee"/>
                    <path d="M15,15 L35,15 L35,35 L15,35 Z" fill="none" stroke="#fff" stroke-width="3"/>
                    <path d="M18,20 L32,20" stroke="#fff" stroke-width="2"/>
                    <path d="M18,25 L32,25" stroke="#fff" stroke-width="2"/>
                    <path d="M18,30 L28,30" stroke="#fff" stroke-width="2"/>
                    <circle cx="25" cy="25" r="10" fill="none" stroke="#ffbe0b" stroke-width="2" stroke-dasharray="15,5"/>
                </svg>
                <span>Print<span class="highlight">Portal</span></span>
            </a>

            <!-- Navigation -->
            <nav role="navigation" aria-label="Main navigation">
                <ul class="nav-links" id="navLinks">
                    <li><a href="<?php echo $base; ?>index.php">Home</a></li>
                    <li><a href="<?php echo $base; ?>index.php#how-it-works">How It Works</a></li>
                    <li class="nav-dropdown">
                        <a href="#" aria-haspopup="true" aria-expanded="false">
                            Our Services <i class="fas fa-chevron-down dropdown-arrow"></i>
                        </a>
                        <div class="nav-dropdown-menu" role="menu">
                            <a href="<?php echo $base; ?>services/aadhaar-titan-print.php" role="menuitem"><i class="fas fa-fingerprint"></i> Aadhaar Titan Print</a>
                            <a href="<?php echo $base; ?>services/voter-id-print.php" role="menuitem"><i class="fas fa-vote-yea"></i> Voter ID Card Print</a>
                            <a href="<?php echo $base; ?>services/driving-license-print.php" role="menuitem"><i class="fas fa-car"></i> Driving License Print</a>
                            <a href="<?php echo $base; ?>services/pan-find-portal.php" role="menuitem"><i class="fas fa-search"></i> PAN No. Find Portal</a>
                            <a href="<?php echo $base; ?>services/rc-titan-print.php" role="menuitem"><i class="fas fa-truck"></i> RC Titan Print</a>
                            <a href="<?php echo $base; ?>services/csc-titan-print.php" role="menuitem"><i class="fas fa-network-wired"></i> CSC Titan Print</a>
                        </div>
                    </li>
                    <li><a href="<?php echo $base; ?>index.php#contact">Contact</a></li>
                    <li><a href="<?php echo $base; ?>about">About Us</a></li>
                </ul>
            </nav>

            <!-- Nav Buttons -->
            <div class="nav-buttons" style="display:flex;align-items:center;gap:14px;">
                <a href="<?php echo $base; ?>dashboard/login.php" class="btn secondary-btn" aria-label="Login">
                    <i class="fa fa-key" aria-hidden="true"></i> Login
                </a>
                <a href="<?php echo $base; ?>dashboard/register.php" class="btn primary-btn" aria-label="Register">
                    Register
                </a>
            </div>

            <!-- Mobile Menu Button -->
            <button class="mobile-menu-btn" id="mobileMenuBtn" aria-label="Toggle menu" aria-expanded="false">
                <span></span><span></span><span></span>
            </button>
        </div>
    </div>
</header>

<!-- Breadcrumb bar placed after header and before hero via page content -->
