<!DOCTYPE html>
<html lang="tr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ $page->meta_title ?? 'Ana Sayfa' }} - {{ $agency->name }}</title>

    <meta name="description" content="{{ $page->meta_description }}">
    <meta name="keywords" content="{{ $page->meta_keywords }}">

    @if($agency->logo)
        <link rel="icon" href="{{ asset('storage/' . $agency->logo) }}">
    @endif

    <!-- Fonts -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&display=swap"
        rel="stylesheet">

    <!-- Icons -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">

    <style>
        :root {
            --primary: {{ $themeSettings['colors']['primary'] ?? '#FF6B35' }};
            --primary-rgb: {{ hexToRgb($themeSettings['colors']['primary'] ?? '#FF6B35') }};
            --secondary: {{ $themeSettings['colors']['secondary'] ?? '#004E89' }};
            --secondary-rgb: {{ hexToRgb($themeSettings['colors']['secondary'] ?? '#004E89') }};
            --accent: {{ $themeSettings['colors']['accent'] ?? '#FFD23F' }};
            --accent-rgb: {{ hexToRgb($themeSettings['colors']['accent'] ?? '#FFD23F') }};

            /* Ek renkler */
            --bg-light: #f8f9fa;
            --bg-dark: #1a1a1a;
            --text-primary: #2c3e50;
            --text-secondary: #6c757d;
            --border-color: #e0e0e0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: var(--font-family);
            line-height: 1.6;
            color: #374151;
            padding-top: 80px;
        }

        h1, h2, h3, h4, h5, h6 {
            font-family: var(--heading-font);
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 0 1rem;
        }

        section {
            padding: 4rem 0;
        }

        /* Header Styles */
        .site-header {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            background: white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
            z-index: 1000;
            transition: all 0.3s;
        }

        .site-header.scrolled {
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
        }

        .header-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 1rem;
            max-width: 1400px;
            margin: 0 auto;
        }

        .site-logo {
            display: flex;
            align-items: center;
            gap: 0.75rem;
            text-decoration: none;
            transition: transform 0.2s;
        }

        .site-logo:hover {
            transform: scale(1.02);
        }

        .site-logo img {
            height: 48px;
            width: auto;
            object-fit: contain;
        }

        .site-logo-text {
            font-size: 1.5rem;
            font-weight: 700;
            color: #111827;
            font-family: var(--heading-font);
        }

        .main-nav {
            display: flex;
            align-items: center;
            gap: 2.5rem;
        }

        .nav-link {
            color: #374151;
            text-decoration: none;
            font-weight: 500;
            font-size: 0.938rem;
            transition: color 0.2s;
            position: relative;
            padding: 0.5rem 0;
        }

        .nav-link:hover {
            color: var(--primary);
        }

        .nav-link::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 0;
            height: 2px;
            background: var(--primary);
            transition: width 0.3s;
        }

        .nav-link:hover::after {
            width: 100%;
        }

        .nav-dropdown {
            position: relative;
        }

        .nav-dropdown-toggle {
            display: flex;
            align-items: center;
            gap: 0.375rem;
            cursor: pointer;
        }

        .nav-dropdown-menu {
            position: absolute;
            top: 100%;
            left: 0;
            background: white;
            min-width: 240px;
            border-radius: 12px;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
            opacity: 0;
            visibility: hidden;
            transform: translateY(-10px);
            transition: all 0.3s;
            padding: 0.75rem 0;
            margin-top: 0.5rem;
        }

        .nav-dropdown:hover .nav-dropdown-menu {
            opacity: 1;
            visibility: visible;
            transform: translateY(0);
        }

        .nav-dropdown-menu a {
            display: block;
            padding: 0.75rem 1.25rem;
            color: #374151;
            text-decoration: none;
            font-size: 0.938rem;
            transition: all 0.2s;
        }

        .nav-dropdown-menu a:hover {
            background: #F3F4F6;
            color: var(--primary);
            padding-left: 1.5rem;
        }

        .header-cta {
            background: linear-gradient(135deg, var(--primary), var(--secondary));
            color: white;
            padding: 0.75rem 1.75rem;
            border-radius: 50px;
            text-decoration: none;
            font-weight: 600;
            font-size: 0.938rem;
            display: inline-flex;
            align-items: center;
            gap: 0.5rem;
            box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
            transition: all 0.2s;
        }

        .header-cta:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
        }

        /* Mobile Menu */
        .mobile-menu-toggle {
            display: none;
            background: none;
            border: none;
            font-size: 1.5rem;
            color: #374151;
            cursor: pointer;
            padding: 0.5rem;
        }

        .mobile-nav {
            display: none;
            position: fixed;
            top: 80px;
            left: 0;
            right: 0;
            background: white;
            box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
            max-height: calc(100vh - 80px);
            overflow-y: auto;
            z-index: 999;
        }

        .mobile-nav.active {
            display: block;
        }

        .mobile-nav-links {
            display: flex;
            flex-direction: column;
            padding: 1rem;
        }

        .mobile-nav-links a,
        .mobile-nav-links .nav-dropdown-toggle {
            padding: 1rem;
            color: #374151;
            text-decoration: none;
            font-weight: 500;
            border-bottom: 1px solid #F3F4F6;
        }

        @media (max-width: 992px) {
            .main-nav {
                display: none;
            }

            .mobile-menu-toggle {
                display: block;
            }

            body {
                padding-top: 70px;
            }

            .header-container {
                padding: 0.75rem 1rem;
            }

            .site-logo img {
                height: 40px;
            }
        }

        @media (max-width: 768px) {
            section {
                padding: 2rem 0;
            }
        }
    </style>

    @stack('styles')
</head>
<body>
<!-- Header -->
<header class="site-header" id="siteHeader">
    <div class="header-container">
        <a href="{{ route('page.agency.show', $agency->slug) }}" class="site-logo">
            @if($agency->logo)
                <img src="{{ asset('storage/' . $agency->logo) }}" alt="{{ $agency->name }}">
            @else
                <span class="site-logo-text">{{ $agency->name }}</span>
            @endif
        </a>

        <nav class="main-nav">
            <a href="{{ route('customer.agency.show', $agency->slug) }}" class="nav-link">Ana Sayfa</a>

            <a href="{{ route('customer.agency.show', $agency->slug) }}#about" class="nav-link">Hakkımızda</a>
            <a href="{{ route('customer.agency.show', $agency->slug) }}#contact" class="nav-link">İletişim</a>

            <a href="#contact" class="header-cta">
                <i class="fas fa-phone"></i>
                Bize Ulaşın
            </a>
        </nav>

        <button class="mobile-menu-toggle" id="mobileMenuToggle">
            <i class="fas fa-bars"></i>
        </button>
    </div>
</header>

<!-- Mobile Navigation -->
<div class="mobile-nav" id="mobileNav">
    <div class="mobile-nav-links">
        <a href="{{ route('customer.agency.show', $agency->slug) }}">
            <i class="fas fa-home"></i> Ana Sayfa
        </a>

        @if($categories->isNotEmpty())
            <div
                style="padding: 1rem; font-weight: 600; color: #6B7280; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em;">
                Turlarımız
            </div>
            @foreach($categories as $category)
                <a href="" style="padding-left: 2rem;">
                    @if($category->icon)
                        <i class="{{ $category->icon }}"></i>
                    @endif
                    {{ $category->name }}
                </a>
            @endforeach
            <a href="" style="padding-left: 2rem; font-weight: 600;">
                <i class="fas fa-th-large"></i> Tüm Turlar
            </a>
        @endif

        <a href="{{ route('customer.agency.show', $agency->slug) }}#about">
            <i class="fas fa-info-circle"></i> Hakkımızda
        </a>
        <a href="{{ route('customer.agency.show', $agency->slug) }}#contact">
            <i class="fas fa-envelope"></i> İletişim
        </a>
    </div>
</div>

<!-- Main Content -->
{{$slot}}

<!-- Scripts -->
<script>
    // Header scroll effect
    window.addEventListener('scroll', function () {
        const header = document.getElementById('siteHeader');
        if (window.scrollY > 50) {
            header.classList.add('scrolled');
        } else {
            header.classList.remove('scrolled');
        }
    });

    // Mobile menu toggle
    const mobileMenuToggle = document.getElementById('mobileMenuToggle');
    const mobileNav = document.getElementById('mobileNav');
    const mobileMenuIcon = mobileMenuToggle.querySelector('i');

    mobileMenuToggle.addEventListener('click', function () {
        mobileNav.classList.toggle('active');

        if (mobileNav.classList.contains('active')) {
            mobileMenuIcon.classList.remove('fa-bars');
            mobileMenuIcon.classList.add('fa-times');
            document.body.style.overflow = 'hidden';
        } else {
            mobileMenuIcon.classList.add('fa-bars');
            mobileMenuIcon.classList.remove('fa-times');
            document.body.style.overflow = '';
        }
    });

    // Close mobile menu when clicking a link
    document.querySelectorAll('.mobile-nav-links a').forEach(link => {
        link.addEventListener('click', function () {
            mobileNav.classList.remove('active');
            mobileMenuIcon.classList.add('fa-bars');
            mobileMenuIcon.classList.remove('fa-times');
            document.body.style.overflow = '';
        });
    });
</script>

@stack('scripts')
</body>
</html>
