---
import '../styles/global.css'
import CookieBanner from '../components/consent/CookieBanner.astro';
import ConsentModal from '../components/consent/ConsentModal.astro';

interface Props {
  title?: string;
  description?: string;
}

const { title = 'moreminimore | รับทำเว็บไซต์ฟรี + จ่ายค่า Server รายปี', description = 'SMEs ไทยไม่ต้องง้องบทำเว็บหลักหมื่นอีกต่อไป' } = Astro.props;
---

<!doctype html>
<html lang="th">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="description" content={description} />
    <title>{title}</title>
    <link rel="icon" type="image/png" sizes="32x32" href="/branding/favicon-32.png" />
    <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=Noto+Sans+Thai:wght@100;200;300;400;500;600;700;800;900&display=swap" rel="stylesheet" />
    <style>
      @font-face { font-family: 'Kanit'; font-weight: 400; src: url('https://www.moreminimore.com/wp-content/uploads/2022/03/Kanit-400.woff') format('woff'); }
      @font-face { font-family: 'Kanit'; font-weight: 700; src: url('https://www.moreminimore.com/wp-content/uploads/2022/03/Kanit-700.woff') format('woff'); }
    </style>
  </head>
  <body class="flex flex-col min-h-screen">
    <!-- Single Merged Header -->
    <header class="sticky-header">
      <div class="container mx-auto px-4 py-3">
        <div class="flex justify-between items-center">
          <a href="/" class="flex-shrink-0">
            <img src="/branding/logo-long-black.png" alt="MoreminiMore Logo" class="h-10 w-auto" width="180" height="45" />
          </a>
          <nav class="hidden lg:flex gap-8 items-center">
            <div class="relative group">
              <button class="font-medium hover:text-secondary transition flex items-center gap-1">บริการ<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg></button>
              <div class="absolute top-full left-0 mt-2 w-64 bg-white rounded-lg shadow-xl opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-200 z-50">
                <div class="py-2">
                  <a href="/website-development" class="block px-4 py-3 hover:bg-gray-50 transition border-b border-gray-100"><div class="font-medium text-secondary">Web Development</div><div class="text-xs text-gray-500">WordPress ฟรี!</div></a>
                  <a href="/ai-automation" class="block px-4 py-3 hover:bg-gray-50 transition border-b border-gray-100"><div class="font-medium text-secondary">AI Automation</div><div class="text-xs text-gray-500">ลดงานซ้ำซ้อน</div></a>
                  <a href="/ai-consult" class="block px-4 py-3 hover:bg-gray-50 transition"><div class="font-medium text-secondary">AI Consult</div><div class="text-xs text-gray-500">ที่ปรึกษา AI</div></a>
                </div>
              </div>
            </div>
            <a href="/services" class="font-medium hover:text-secondary transition">บริการ</a>
            <a href="/process" class="font-medium hover:text-secondary transition">ขั้นตอน</a>
            <a href="/about-us" class="font-medium hover:text-secondary transition">เกี่ยวกับเรา</a>
            <a href="/blog" class="font-medium hover:text-secondary transition">เรื่องน่ารู้</a>
            <a href="/contact-us" class="bg-secondary text-white px-6 py-2 rounded-full hover:bg-secondary-hover transition font-medium">ติดต่อเรา</a>
          </nav>
          <button class="lg:hidden text-black" id="mobile-menu-btn">
            <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16"/></svg>
          </button>
        </div>
        <div class="lg:hidden hidden mt-4 pt-4 border-t border-gray-200" id="mobile-menu">
          <div class="flex flex-col gap-4">
            <details class="group">
              <summary class="font-medium hover:text-secondary transition cursor-pointer flex items-center justify-between">
                บริการ<svg class="w-4 h-4 group-open:rotate-180 transition" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/></svg>
              </summary>
              <div class="flex flex-col gap-2 mt-2 ml-4">
                <a href="/website-development" class="text-base hover:text-secondary transition">Web Development</a>
                <a href="/ai-automation" class="text-base hover:text-secondary transition">AI Automation</a>
                <a href="/ai-consult" class="text-base hover:text-secondary transition">AI Consult</a>
              </div>
            </details>
            <a href="/services" class="font-medium hover:text-secondary transition">บริการ</a>
            <a href="/process" class="font-medium hover:text-secondary transition">ขั้นตอน</a>
            <a href="/about-us" class="font-medium hover:text-secondary transition">เกี่ยวกับเรา</a>
            <a href="/blog" class="font-medium hover:text-secondary transition">เรื่องน่ารู้</a>
            <a href="/contact-us" class="bg-secondary text-white px-6 py-2 rounded-full hover:bg-secondary-hover transition font-medium text-center">ติดต่อเรา</a>
          </div>
        </div>
      </div>
    </header>
    
    <main class="flex-grow"><slot /></main>
    
    <footer class="bg-gray-dark text-gray-300 py-12">
      <div class="container mx-auto px-4">
        <div class="grid md:grid-cols-4 gap-8">
          <div>
            <img src="/branding/logo-long.png" alt="MoreminiMore Logo" class="h-10 w-auto mb-4 bg-white p-2 rounded" width="180" height="45" />
            <p class="text-base mb-4">IT Services สำหรับ SMEs ไทย</p>
            <div class="flex gap-3">
              <a href="https://www.facebook.com/moreminimore" target="_blank" rel="noopener noreferrer" class="text-gray-300 hover:text-primary transition"><svg class="w-6 h-6" fill="#1877F2" viewBox="0 0 24 24"><path d="M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"/></svg></a>
              <a href="https://twitter.com/moreminimore" target="_blank" rel="noopener noreferrer" class="text-gray-300 hover:text-primary transition"><svg class="w-6 h-6" fill="#1DA1F2" viewBox="0 0 24 24"><path d="M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"/></svg></a>
              <a href="https://www.linkedin.com/company/moreminimore" target="_blank" rel="noopener noreferrer" class="text-gray-300 hover:text-primary transition"><svg class="w-6 h-6" fill="#0A66C2" viewBox="0 0 24 24"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452z"/></svg></a>
            </div>
          </div>
          <div>
            <h3 class="font-bold mb-4 text-lg text-white">บริการ</h3>
            <ul class="space-y-2 text-base">
              <li><a href="/website-development" class="hover:text-primary transition">Web Development</a></li>
              <li><a href="/ai-automation" class="hover:text-primary transition">AI Automation Setup</a></li>
              <li><a href="/ai-consult" class="hover:text-primary transition">AI Consult & Implementation</a></li>
            </ul>
          </div>
          <div>
            <h3 class="font-bold mb-4 text-lg text-white">บริษัท</h3>
            <ul class="space-y-2 text-base">
              <li><a href="/about-us" class="hover:text-primary transition">เกี่ยวกับเรา</a></li>
              <li><a href="/process" class="hover:text-primary transition">ขั้นตอนการทำงาน</a></li>
              <li><a href="/contact-us" class="hover:text-primary transition">ติดต่อเรา</a></li>
            </ul>
          </div>
          <div>
            <h3 class="font-bold mb-4 text-lg text-white">ติดต่อ</h3>
            <ul class="space-y-3 text-base">
              <li class="flex items-center gap-2"><span>📞</span><a href="tel:0809955945" class="hover:text-primary transition">080-995-5945</a></li>
              <li class="flex items-center gap-2"><span>📧</span><a href="mailto:contact@moreminimore.com" class="hover:text-primary transition">contact@moreminimore.com</a></li>
              <li class="flex items-center gap-2"><span>💬</span><span>Line: @moreminimore</span></li>
              <li class="flex items-center gap-2"><span>🕒</span><span>จ-ศ: 9:00 - 18:00 น.</span></li>
            </ul>
          </div>
        </div>
        <div class="border-t border-gray-700 mt-8 pt-8 text-center text-base">
          <div class="flex justify-center gap-6 mb-4">
            <a href="/terms-and-conditions" class="hover:text-primary transition">ข้อกำหนดและเงื่อนไข</a>
            <a href="/privacy-policy" class="hover:text-primary transition">นโยบายความเป็นส่วนตัว</a>
            <button id="consent-preferences-btn" class="hover:text-primary transition">ตั้งค่าคุกกี้</button>
          </div>
          <p>&copy; {new Date().getFullYear()} moreminimore. สงวนลิขสิทธิ์</p>
        </div>
      </div>
    </footer>
    
    <!-- Floating Contact Buttons -->
    <div class="floating-contact">
      <a href="https://line.me/" target="_blank" rel="noopener noreferrer" class="floating-contact-btn bg-[#06C755] text-white" title="ทัก Line">
        <svg class="w-8 h-8" fill="currentColor" viewBox="0 0 24 24"><path d="M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85 3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433c-1.144 0-2.063-.926-2.063-2.065 0-1.138.92-2.063 2.063-2.063 1.14 0 2.064.925 2.064 2.063 0 1.139-.925 2.065-2.064 2.065zm1.782 13.019H3.555V9h3.564v11.452z"/></svg>
      </a>
      <a href="tel:0809955945" class="floating-contact-btn bg-secondary text-white" title="โทรเลย">
        <svg class="w-8 h-8" fill="currentColor" viewBox="0 0 24 24"><path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56a.977.977 0 00-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/></svg>
      </a>
    </div>
    
    <!-- Cookie Consent Banner -->
    <CookieBanner />
    
    <!-- Consent Modal for custom preferences -->
    <ConsentModal />
    
    <!-- Consent preferences button in footer should open modal -->
    <script is:inline>
      const consentBtn = document.getElementById('consent-preferences-btn');
      if (consentBtn) {
        consentBtn.addEventListener('click', () => {
          if (typeof window.openConsentModal === 'function') {
            window.openConsentModal();
          }
        });
      }
    </script>
    
    <!-- Umami Analytics (Conditional Loading) -->
    <script is:inline>
      const consent = JSON.parse(localStorage.getItem('consent-preferences') || '{}');
      if (consent.analytics) {
        const script = document.createElement('script');
        script.defer = true;
        script.src = 'https://umami.moreminimore.com/script.js';
        script.setAttribute('data-website-id', 'b2e87a6c-0b64-43c8-bb09-e406ffca0af1');
        document.head.appendChild(script);
      }
    </script>
    
    <script>
      const menuBtn = document.getElementById('mobile-menu-btn');
      const mobileMenu = document.getElementById('mobile-menu');
      if (menuBtn && mobileMenu) { menuBtn.addEventListener('click', () => mobileMenu.classList.toggle('hidden')); }
    </script>
  </body>
</html>
