<?php
require_once 'includes/config.php';
require_once 'includes/db.php';
require_once 'includes/functions.php';

// Dobijanje trenutnog URL-a
$current_page = basename($_SERVER['PHP_SELF']);

// Dobijanje kategorija za meni
$categories = get_rows("SELECT id, name, slug FROM categories WHERE parent_id IS NULL ORDER BY name ASC");

// Broj stavki u korpi
$cart_count = 0;
$cart = get_cart();
foreach ($cart as $quantity) {
    $cart_count += $quantity;
}
?>
<!DOCTYPE html>
<html lang="sr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <?php
    // Ako su meta podaci dinamički, postaviti ih ovde
    echo generate_meta_tags();
    ?>
    
    <!-- Favicon -->
    <link rel="icon" href="/favicon.ico">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    
    <!-- Preload fontova -->
    <link rel="preload" href="/assets/fonts/HugongIcons.woff2" as="font" type="font/woff2" crossorigin>
    
    <!-- CSS -->
    <!--<link rel="stylesheet" href="/assets/css/styles.css">-->
    <!--<link rel="stylesheet" href="/assets/css/home.css">-->
    <!--<link rel="stylesheet" href="/assets/css/mobile-product.css">-->
    <!--<link rel="stylesheet" href="/assets/css/product-modern.css">-->
    <!--<link rel="stylesheet" href="/assets/css/mobile-navbar.css">-->
    <!--<link rel="stylesheet" href="/assets/css/navbar-redesign.css">-->
    
    <link rel="stylesheet" href="/assets/css/new/variables.css">
    <link rel="stylesheet" href="/assets/css/new/base.css">
    <link rel="stylesheet" href="/assets/css/new/layout.css">
    <link rel="stylesheet" href="/assets/css/new/components.css">
    <link rel="stylesheet" href="/assets/css/new/pages/home.css">
    <link rel="stylesheet" href="/assets/css/new/pages/product.css">
    <link rel="stylesheet" href="/assets/css/new/pages/category.css">
    <link rel="stylesheet" href="/assets/css/new/pages/checkout.css">
    <link rel="stylesheet" href="/assets/css/new/responsive.css">
    
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">



    
    <!-- Strukturirani podaci za organizaciju -->
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "Organization",
      "name": "<?php echo get_setting('site_name', 'Hugong Aparati'); ?>",
      "url": "<?php echo SITE_URL; ?>",
      "logo": "<?php echo SITE_URL; ?>/uploads/hugong-logo.png",
      "contactPoint": {
        "@type": "ContactPoint",
        "telephone": "<?php echo get_setting('contact_phone', '+381 65 8065 065'); ?>",
        "contactType": "customer service",
        "availableLanguage": "Serbian"
      },
      "sameAs": [
        "https://www.facebook.com/hugongaparati",
        "https://www.instagram.com/hugongaparati"
      ]
    }
    </script>
</head>
<body>

<!-- Desktop Header -->
<header class="site-header desktop-only">
    <div class="container">
        <div class="header-main">
            <!-- Logo -->
            <a href="/" class="logo">
                <?php if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/uploads/hugong-logo.png')): ?>
                    <img src="/uploads/hugong-logo.png" alt="<?php echo get_setting('site_name', 'Hugong Aparati'); ?>" width="180" height="60">
                <?php else: ?>
                    <h1><?php echo get_setting('site_name', 'HUGONG APARATI'); ?></h1>
                <?php endif; ?>
            </a>

            <!-- Navigation and Info Section -->
            <div class="header-right">
                <!-- Main Navigation Links -->
                <div class="top-nav">
                    <ul class="main-links">
                        <li class="<?php echo $current_page === 'aparati-za-varenje' ? 'active' : ''; ?>">
                            <a href="aparati-za-varenje">SVI APARATI</a>
                        </li>
                        <li class="<?php echo $current_page === 'o-nama' ? 'active' : ''; ?>">
                            <a href="/o-nama">O NAMA</a>
                        </li>
                        <li class="<?php echo $current_page === 'kontakt' ? 'active' : ''; ?>">
                            <a href="/kontakt">KONTAKT</a>
                        </li>
                    </ul>
                    
                    <div class="contact-info">
                        <div class="location">
                            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
                                <circle cx="12" cy="10" r="3"></circle>
                            </svg>
                            <span>Oskara Davičа 2, Kragujevac</span>
                        </div>
                        <div class="phone">
                            <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                                <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"></path>
                            </svg>
                            <span>065/8-065-065</span>
                        </div>
                    </div>
                    
                    <!-- Shopping Cart -->
                    <a href="/cart.php" class="cart-icon">
                        <svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                            <circle cx="9" cy="21" r="1"></circle>
                            <circle cx="20" cy="21" r="1"></circle>
                            <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
                        </svg>
                        <span class="cart-count"><?php echo $cart_count; ?></span>
                    </a>
                </div>
            </div>
        </div>
    </div>
    
    <!-- Main Navigation -->
<nav class="main-navigation">
    <div class="container">
        <ul class="nav-menu"
        ><li class="<?php echo $current_page === 'index.php' ? 'active' : ''; ?>"
            ><a href="/">HUGONG APARATI</a
        ></li
        ><?php foreach ($categories as $category): 
        ?><li class="<?php echo isset($_GET['category']) && $_GET['category'] === $category['slug'] ? 'active' : ''; ?>"
            ><a href="/<?php echo $category['slug']; ?>"><?php echo strtoupper($category['name']); ?></a
        ></li
        ><?php endforeach; ?>
        </ul>
    </div>
</nav>
</header>

<!-- Mobile Header -->
<header class="mobile-header mobile-only">
    <!-- Žuta linija na vrhu -->
    <div class="header-top-bar"></div>
    
    <div class="header-main-container">
        <!-- Logo i navigacija -->
        <div class="mobile-header-content">
            <a href="/" class="mobile-logo">
                <img src="/uploads/hugong-logo.png" alt="<?php echo get_setting('site_name', 'Hugong Aparati'); ?>">
            </a>
            
            <div class="mobile-actions">
                <!-- Pretraga -->
                <a href="#" class="search-icon" id="mobile-search-toggle">
                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <circle cx="11" cy="11" r="8"></circle>
                        <line x1="21" y1="21" x2="16.65" y2="16.65"></line>
                    </svg>
                </a>
                
                <!-- Korpa -->
                <a href="/cart.php" class="mobile-cart">
                    <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
                        <circle cx="9" cy="21" r="1"></circle>
                        <circle cx="20" cy="21" r="1"></circle>
                        <path d="M1 1h4l2.68 13.39a2 2 0 0 0 2 1.61h9.72a2 2 0 0 0 2-1.61L23 6H6"></path>
                    </svg>
                    <span class="cart-count"><?php echo $cart_count; ?></span>
                </a>
                
                <!-- Meni dugme -->
                <button id="mobile-menu-toggle" class="menu-button">
                    <span>MENI</span>
                </button>
            </div>
        </div>
    </div>
</header>

<!-- Overlay za padajući meni -->
<div id="mobile-menu-overlay" class="menu-overlay"></div>

<!-- Padajući meni -->
<div id="mobile-drawer" class="mobile-menu-drawer mobile-only">

<!-- Kontakt informacije -->
<div class="drawer-section contact-section">
    <!-- Naziv firme -->
    <div class="contact-item">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M3 3h18v18H3z"></path>
            <path d="M9 3v18"></path>
            <path d="M15 3v18"></path>
        </svg>
        <div class="contact-info">
            <strong>AGRAS D.O.O.</strong>
        </div>
    </div>
    
    <!-- Adresa -->
    <div class="contact-item">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M21 10c0 7-9 13-9 13s-9-6-9-13a9 9 0 0 1 18 0z"></path>
            <circle cx="12" cy="10" r="3"></circle>
        </svg>
        <div class="contact-info">
            <strong>Oškara Daviča 2, 34000 Kragujevac</strong>
        </div>
    </div>
    
    <!-- Telefon -->
    <div class="contact-item">
        <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
            <path d="M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z"></path>
        </svg>
        <div class="contact-info">
            <strong>065/8-065-065</strong>
        </div>
    </div>
</div>

    <!-- Navigacija - kategorije -->
    <div>
        <nav>
            <ul class="mobile-nav-menu" style="font-color:white!important;">
                <li><a href="/">Početna</a></li>
                <li><a href="/hugong-rel-aparati">REL aparati</a></li>
                <li><a href="/hugong-co2-aparati">MIG/MAG (CO2) aparati</a></li>
                <li><a href="/hugong-tig-aparati">TIG aparati</a></li>
                <li><a href="/hugong-plazma-sekac">Plazma sekači</a></li>
                <li><a href="/o-nama">O nama</a></li>
                <li><a href="/kontakt">Kontakt</a></li>
            </ul>
        </nav>
    </div>

    

</div>
    
    <div class="content-wrapper">