<!DOCTYPE html>
<html lang="pt-BR">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
    <meta name="theme-color" content="<?php echo e($lojaAtual?->cor_primaria ?? '#FF6B35'); ?>">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta name="apple-mobile-web-app-title" content="<?php echo e($lojaAtual?->nome ?? config('app.name')); ?>">
    <meta name="description" content="<?php echo e($lojaAtual?->descricao ?? 'Peça sua comida favorita com facilidade'); ?>">
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
    <meta name="app-url" content="<?php echo e(config('app.url')); ?>">

    <title><?php echo $__env->yieldContent('titulo', $lojaAtual?->nome ?? config('app.name')); ?></title>

    <!-- PWA Manifest -->
    <link rel="manifest" href="/manifest.json">
    <!-- Ícones -->
    <link rel="icon" type="image/png" href="/img/icones/icon-192x192.png">
    <link rel="apple-touch-icon" href="/img/icones/icon-192x192.png">

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

    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">

    <!-- CSS do sistema -->
    <link rel="stylesheet" href="<?php echo e(asset('css/app.css')); ?>">

    <!-- Variáveis de cor da loja -->
    <style>
        :root {
            --cor-primaria: <?php echo e($lojaAtual?->cor_primaria ?? '#FF6B35'); ?>;
            --cor-secundaria: <?php echo e($lojaAtual?->cor_secundaria ?? '#2C3E50'); ?>;
        }
    </style>

    <?php echo $__env->yieldPushContent('styles'); ?>
</head>
<body class="pwa-body" data-loja-id="<?php echo e($lojaAtual?->id ?? ''); ?>" data-loja-slug="<?php echo e($lojaAtual?->slug ?? ''); ?>">

    <!-- Navegação Desktop -->
    <header class="site-navbar desktop-only">
        <div class="site-navbar__brand">
            <a href="<?php echo e(url('/')); ?>" class="site-navbar__logo">
                <?php if(isset($lojaAtual) && $lojaAtual->logo): ?>
                    <img src="<?php echo e($lojaAtual->logo_url); ?>" alt="<?php echo e($lojaAtual->nome); ?>">
                <?php else: ?>
                    <span><?php echo e($lojaAtual->nome ?? config('app.name')); ?></span>
                <?php endif; ?>
            </a>
            <div class="site-navbar__info">
                <strong><?php echo e($lojaAtual->nome ?? config('app.name')); ?></strong>
                <small><?php echo e($lojaAtual->descricao ?? 'Experiência completa de delivery online'); ?></small>
            </div>
        </div>

        <nav class="site-navbar__links">
            <a href="<?php echo e(isset($lojaAtual) ? route('cliente.loja', $lojaAtual->slug) : url('/')); ?>" class="<?php echo e(request()->routeIs('cliente.loja') ? 'active' : ''); ?>">Início</a>
            <a href="<?php echo e(route('cliente.lojas')); ?>" class="<?php echo e(request()->routeIs('cliente.lojas') ? 'active' : ''); ?>">Restaurantes</a>
            <a href="<?php echo e(route('cliente.buscar')); ?>" class="<?php echo e(request()->routeIs('cliente.buscar') ? 'active' : ''); ?>">Buscar</a>
            <a href="<?php echo e(route('marketing.landing')); ?>" target="_blank" rel="noopener">Apresentação</a>
            <?php if(auth()->guard()->check()): ?>
            <a href="<?php echo e(route('cliente.pedidos.index')); ?>">Pedidos</a>
            <?php endif; ?>
        </nav>

        <div class="site-navbar__actions">
            <?php if(auth()->guard()->check()): ?>
                <div class="site-navbar__user">
                    <img src="<?php echo e(Auth::user()->foto_perfil_url); ?>" alt="<?php echo e(Auth::user()->nome); ?>">
                    <div>
                        <span><?php echo e(Auth::user()->nome_abreviado); ?></span>
                        <small><?php echo e(Auth::user()->email); ?></small>
                    </div>
                </div>
                <a href="<?php echo e(route('cliente.checkout')); ?>" class="btn btn-primario">Meu carrinho</a>
                <form action="<?php echo e(route('logout')); ?>" method="POST">
                    <?php echo csrf_field(); ?>
                    <button type="submit" class="btn btn-outline">Sair</button>
                </form>
            <?php else: ?>
                <a href="<?php echo e(route('login')); ?>" class="btn btn-outline">Entrar</a>
                <a href="<?php echo e(route('registro')); ?>" class="btn btn-primario">Criar conta</a>
            <?php endif; ?>
        </div>
    </header>

    <!-- Overlay do Sidebar -->
    <div class="sidebar-overlay mobile-only" id="sidebarOverlay" onclick="fecharSidebar()"></div>

    <!-- Sidebar Esquerda -->
    <aside class="sidebar sidebar-left mobile-only" id="sidebarLeft">
        <div class="sidebar-header">
            <div class="sidebar-user">
                <?php if(auth()->guard()->check()): ?>
                <img src="<?php echo e(Auth::user()->foto_perfil_url); ?>" alt="<?php echo e(Auth::user()->nome); ?>" class="sidebar-avatar">
                <div>
                    <div class="sidebar-user-nome"><?php echo e(Auth::user()->nome_abreviado); ?></div>
                    <div class="sidebar-user-email"><?php echo e(Auth::user()->email); ?></div>
                </div>
                <?php else: ?>
                <div class="sidebar-guest">
                    <i class="bi bi-person-circle fs-2"></i>
                    <div>
                        <a href="<?php echo e(route('login')); ?>" class="btn btn-sm btn-primario">Entrar</a>
                        <a href="<?php echo e(route('registro')); ?>" class="btn btn-sm btn-outline ms-1">Cadastrar</a>
                    </div>
                </div>
                <?php endif; ?>
            </div>
            <button class="sidebar-close" onclick="fecharSidebar()"><i class="bi bi-x-lg"></i></button>
        </div>

        <nav class="sidebar-nav">
            <?php if(isset($lojaAtual)): ?>
            <a href="<?php echo e(route('cliente.loja', $lojaAtual->slug)); ?>" class="sidebar-link">
                <i class="bi bi-house"></i> Início
            </a>
            <?php endif; ?>
            <a href="<?php echo e(route('cliente.lojas')); ?>" class="sidebar-link">
                <i class="bi bi-shop"></i> Restaurantes
            </a>
            <a href="<?php echo e(route('marketing.landing')); ?>" target="_blank" class="sidebar-link">
                <i class="bi bi-megaphone"></i> Apresentação
            </a>
            <?php if(auth()->guard()->check()): ?>
            <a href="<?php echo e(route('cliente.pedidos.index')); ?>" class="sidebar-link">
                <i class="bi bi-bag"></i> Meus Pedidos
            </a>
            <a href="<?php echo e(route('perfil.index')); ?>" class="sidebar-link">
                <i class="bi bi-person"></i> Meu Perfil
            </a>
            <a href="<?php echo e(route('notificacoes.index')); ?>" class="sidebar-link">
                <i class="bi bi-bell"></i> Notificações
                <?php $naoLidas = Auth::user()->notificacoesNaoLidas()->count(); ?>
                <?php if($naoLidas > 0): ?>
                <span class="badge-notif"><?php echo e($naoLidas); ?></span>
                <?php endif; ?>
            </a>
            <?php if(Auth::user()->isAdmin() || Auth::user()->isGerente()): ?>
            <div class="sidebar-divider"></div>
            <a href="<?php echo e(route('admin.dashboard')); ?>" class="sidebar-link">
                <i class="bi bi-speedometer2"></i> Painel Admin
            </a>
            <?php endif; ?>
            <?php if(Auth::user()->isEntregador()): ?>
            <div class="sidebar-divider"></div>
            <a href="<?php echo e(route('entregador.dashboard')); ?>" class="sidebar-link">
                <i class="bi bi-bicycle"></i> Painel Entregador
            </a>
            <?php endif; ?>
            <div class="sidebar-divider"></div>
            <form method="POST" action="<?php echo e(route('logout')); ?>">
                <?php echo csrf_field(); ?>
                <button type="submit" class="sidebar-link sidebar-link-danger w-100 text-start border-0 bg-transparent">
                    <i class="bi bi-box-arrow-right"></i> Sair
                </button>
            </form>
            <?php endif; ?>
        </nav>

        <?php if(isset($lojaAtual) && $lojaAtual->estaAberta()): ?>
        <div class="sidebar-loja-status aberta">
            <i class="bi bi-circle-fill"></i> Aberta agora
        </div>
        <?php elseif(isset($lojaAtual)): ?>
        <div class="sidebar-loja-status fechada">
            <i class="bi bi-circle-fill"></i> Fechada no momento
        </div>
        <?php endif; ?>
    </aside>

    <!-- Header Principal -->
    <header class="pwa-header mobile-only" id="pwaHeader">
        <button class="header-btn" onclick="abrirSidebar()" aria-label="Menu">
            <i class="bi bi-list fs-4"></i>
        </button>

        <div class="header-logo">
            <?php if(isset($lojaAtual) && $lojaAtual->logo): ?>
                <img src="<?php echo e($lojaAtual->logo_url); ?>" alt="<?php echo e($lojaAtual->nome); ?>" class="header-logo-img">
            <?php else: ?>
                <span class="header-logo-text"><?php echo e($lojaAtual->nome ?? config('app.name')); ?></span>
            <?php endif; ?>
        </div>

        <div class="header-acoes">
            <a href="<?php echo e(route('cliente.buscar')); ?>" class="header-btn" aria-label="Buscar">
                <i class="bi bi-search fs-5"></i>
            </a>
            <?php if(auth()->guard()->check()): ?>
            <button class="header-btn position-relative" onclick="toggleCarrinho()" aria-label="Carrinho">
                <i class="bi bi-bag fs-5"></i>
                <span class="badge-carrinho" id="badgeCarrinho" style="display:none">0</span>
            </button>
            <?php endif; ?>
        </div>
    </header>

    <!-- Conteúdo Principal -->
    <main class="pwa-main">
        <?php if(session('sucesso')): ?>
        <div class="alerta alerta-sucesso animate-slide-down" id="alertaSucesso">
            <i class="bi bi-check-circle"></i> <?php echo e(session('sucesso')); ?>

        </div>
        <?php endif; ?>
        <?php if(session('erro')): ?>
        <div class="alerta alerta-erro animate-slide-down">
            <i class="bi bi-exclamation-circle"></i> <?php echo e(session('erro')); ?>

        </div>
        <?php endif; ?>
        <?php if(session('info')): ?>
        <div class="alerta alerta-info animate-slide-down">
            <i class="bi bi-info-circle"></i> <?php echo e(session('info')); ?>

        </div>
        <?php endif; ?>

        <?php echo $__env->yieldContent('conteudo'); ?>
    </main>

    <!-- Footer Navigation (Android-like) -->
    <nav class="footer-nav mobile-only" id="footerNav">
        <a href="<?php echo e(isset($lojaAtual) ? route('cliente.loja', $lojaAtual->slug) : route('cliente.home')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('cliente.loja', 'cliente.home') ? 'active' : ''); ?>">
            <i class="bi bi-house-fill"></i>
            <span>Início</span>
        </a>
        <a href="<?php echo e(route('cliente.buscar')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('cliente.buscar') ? 'active' : ''); ?>">
            <i class="bi bi-search"></i>
            <span>Buscar</span>
        </a>
        <?php if(auth()->guard()->check()): ?>
        <a href="<?php echo e(route('cliente.checkout')); ?>"
           class="footer-nav-item footer-nav-carrinho <?php echo e(request()->routeIs('cliente.checkout') ? 'active' : ''); ?>">
            <div class="footer-carrinho-btn">
                <i class="bi bi-bag-fill"></i>
                <span class="footer-carrinho-badge" id="footerCarrinhoBadge" style="display:none">0</span>
            </div>
            <span>Carrinho</span>
        </a>
        <a href="<?php echo e(route('cliente.pedidos.index')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('cliente.pedidos.*') ? 'active' : ''); ?>">
            <i class="bi bi-receipt"></i>
            <span>Pedidos</span>
        </a>
        <a href="<?php echo e(route('perfil.index')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('perfil.*') ? 'active' : ''); ?>">
            <i class="bi bi-person-circle"></i>
            <span>Perfil</span>
        </a>
        <?php else: ?>
        <a href="<?php echo e(route('cliente.lojas')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('cliente.lojas') ? 'active' : ''); ?>">
            <i class="bi bi-shop"></i>
            <span>Lojas</span>
        </a>
        <a href="<?php echo e(route('login')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('login') ? 'active' : ''); ?>">
            <i class="bi bi-box-arrow-in-right"></i>
            <span>Entrar</span>
        </a>
        <a href="<?php echo e(route('registro')); ?>"
           class="footer-nav-item <?php echo e(request()->routeIs('registro') ? 'active' : ''); ?>">
            <i class="bi bi-person-plus"></i>
            <span>Cadastrar</span>
        </a>
        <?php endif; ?>
    </nav>

    <!-- Painel do Carrinho (slide bottom) -->
    <?php if(auth()->guard()->check()): ?>
    <div class="carrinho-overlay mobile-only" id="carrinhoOverlay" onclick="fecharCarrinho()"></div>
    <div class="carrinho-panel mobile-only" id="carrinhoPanel">
        <div class="carrinho-header">
            <h6 class="m-0"><i class="bi bi-bag"></i> Meu Carrinho</h6>
            <button onclick="fecharCarrinho()" class="btn-fechar"><i class="bi bi-x-lg"></i></button>
        </div>
        <div class="carrinho-itens" id="carrinhoItens">
            <div class="carrinho-vazio" id="carrinhoVazio">
                <i class="bi bi-bag-x"></i>
                <p>Seu carrinho está vazio</p>
            </div>
        </div>
        <div class="carrinho-footer" id="carrinhoFooter" style="display:none">
            <div class="carrinho-total">
                <span>Total</span>
                <strong id="carrinhoTotal">R$ 0,00</strong>
            </div>
            <a href="<?php echo e(route('cliente.checkout')); ?>" class="btn btn-primario w-100 mt-2">
                Finalizar Pedido <i class="bi bi-arrow-right"></i>
            </a>
        </div>
    </div>
    <?php endif; ?>

    <!-- Toast de notificação -->
    <div class="toast-container" id="toastContainer"></div>

    <div class="support-fab">
        <a href="https://wa.me/5521981325441" target="_blank" rel="noopener">
            <i class="bi bi-whatsapp"></i>
            <span>Precisa de suporte?</span>
        </a>
    </div>

    
    <?php if(isset($lojaAtual) && $lojaAtual->popup_saida_ativo): ?>
    <?php
        $ps = $lojaAtual;
        $cookieSaida = 'popup_saida_' . $lojaAtual->id;
        $tipoDesc = match($ps->popup_saida_desconto_tipo) {
            'percentual'   => number_format($ps->popup_saida_desconto_valor, 0) . '% OFF',
            'fixo'         => 'R$ ' . number_format($ps->popup_saida_desconto_valor, 2, ',', '.') . ' de desconto',
            'frete_gratis' => 'Frete Grátis',
            default        => number_format($ps->popup_saida_desconto_valor, 0) . '% OFF',
        };
    ?>
    <div id="popupSaidaOverlay" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,.7);z-index:8000;align-items:center;justify-content:center;padding:16px">
        <div style="background:#fff;border-radius:24px;max-width:400px;width:100%;overflow:hidden;position:relative;box-shadow:0 20px 60px rgba(0,0,0,.3)">
            <button onclick="fecharPopupSaida()" style="position:absolute;top:12px;right:12px;background:rgba(0,0,0,.1);border:none;border-radius:50%;width:32px;height:32px;cursor:pointer;font-size:1rem;display:flex;align-items:center;justify-content:center;z-index:1">✕</button>
            <?php if($ps->popup_saida_imagem): ?>
            <img src="<?php echo e(asset('storage/' . $ps->popup_saida_imagem)); ?>" alt="" style="width:100%;height:160px;object-fit:cover">
            <?php else: ?>
            <div style="background:linear-gradient(135deg,<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>,<?php echo e($lojaAtual->cor_secundaria ?? '#2C3E50'); ?>);height:120px;display:flex;align-items:center;justify-content:center;font-size:3rem">🎁</div>
            <?php endif; ?>
            <div style="padding:24px;text-align:center">
                <h2 style="font-size:1.4rem;font-weight:900;color:#2C3E50;margin:0 0 8px"><?php echo e($ps->popup_saida_titulo ?: 'Espere! Temos um presente para você!'); ?></h2>
                <p style="color:#6c757d;margin:0 0 16px;line-height:1.5"><?php echo e($ps->popup_saida_texto ?: 'Não vá embora sem aproveitar este desconto especial!'); ?></p>
                <div style="background:<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>15;border:2px dashed <?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>;border-radius:12px;padding:12px;margin-bottom:16px">
                    <div style="font-size:.8rem;color:#6c757d;margin-bottom:4px">Use o cupom:</div>
                    <div style="font-size:1.5rem;font-weight:900;color:<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>;letter-spacing:3px;cursor:pointer" onclick="copiarCupomSaida()" title="Clique para copiar">
                        <?php echo e($ps->popup_saida_cupom ?: 'FIQUE10'); ?>

                    </div>
                    <div style="font-size:.75rem;color:#6c757d;margin-top:2px"><?php echo e($tipoDesc); ?></div>
                </div>
                <?php if($ps->popup_saida_validade_min): ?>
                <div style="font-size:.8rem;color:#dc3545;margin-bottom:12px">⏱ Oferta válida por <strong id="countdownSaida"><?php echo e($ps->popup_saida_validade_min); ?>:00</strong></div>
                <?php endif; ?>
                <button onclick="usarCupomSaida()" style="width:100%;padding:14px;background:<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>;color:#fff;border:none;border-radius:12px;font-size:1rem;font-weight:800;cursor:pointer;font-family:inherit">
                    🎉 Quero este desconto!
                </button>
                <button onclick="fecharPopupSaida()" style="width:100%;margin-top:8px;padding:10px;background:transparent;color:#6c757d;border:none;cursor:pointer;font-family:inherit;font-size:.85rem">
                    Não, obrigado
                </button>
            </div>
        </div>
    </div>
    <script>
    (function(){
        const COOKIE_KEY = '<?php echo e($cookieSaida); ?>';
        const CUPOM      = '<?php echo e($ps->popup_saida_cupom ?: "FIQUE10"); ?>';
        const VALIDADE   = <?php echo e($ps->popup_saida_validade_min ?? 30); ?>;

        if (document.cookie.includes(COOKIE_KEY)) return;

        let mostrou = false;

        function mostrarPopupSaida() {
            if (mostrou) return;
            mostrou = true;
            const el = document.getElementById('popupSaidaOverlay');
            if (el) { el.style.display = 'flex'; iniciarCountdown(); }
        }

        // Exit intent (desktop)
        document.addEventListener('mouseleave', function(e) {
            if (e.clientY < 10) mostrarPopupSaida();
        });

        // Saída mobile (visibilidade)
        document.addEventListener('visibilitychange', function() {
            if (document.visibilityState === 'hidden') mostrarPopupSaida();
        });

        let countSeg = VALIDADE * 60;
        let intervalCd;
        function iniciarCountdown() {
            if (!VALIDADE) return;
            intervalCd = setInterval(() => {
                countSeg--;
                const el = document.getElementById('countdownSaida');
                if (!el) { clearInterval(intervalCd); return; }
                if (countSeg <= 0) { clearInterval(intervalCd); window.fecharPopupSaida(); return; }
                const m = Math.floor(countSeg / 60);
                const s = countSeg % 60;
                el.textContent = m + ':' + String(s).padStart(2, '0');
            }, 1000);
        }

        window.fecharPopupSaida = function() {
            const el = document.getElementById('popupSaidaOverlay');
            if (el) el.style.display = 'none';
            clearInterval(intervalCd);
            document.cookie = COOKIE_KEY + '=1;path=/;max-age=' + (VALIDADE * 60);
        };

        window.copiarCupomSaida = function() {
            navigator.clipboard?.writeText(CUPOM).then(() => {
                if (typeof mostrarToast === 'function') mostrarToast('Cupom copiado! ' + CUPOM, 'sucesso');
            });
        };

        window.usarCupomSaida = function() {
            copiarCupomSaida();
            fecharPopupSaida();
            const c = document.getElementById('campoCupom');
            if (c) { c.value = CUPOM; c.dispatchEvent(new Event('input')); }
            else { sessionStorage.setItem('cupom_auto', CUPOM); }
        };
    })();
    </script>
    <?php endif; ?>

    
    <?php if(isset($lojaAtual) && $lojaAtual->popup_promo_ativo): ?>
    <?php
        $pp = $lojaAtual;
        $promoExpirada = $pp->popup_promo_expira_em && $pp->popup_promo_expira_em->isPast();
        $cookiePromo   = 'popup_promo_' . $lojaAtual->id;
    ?>
    <?php if(!$promoExpirada): ?>
    <div id="popupPromoOverlay" style="display:none;position:fixed;inset:0;background:rgba(0,0,0,.75);z-index:8001;align-items:center;justify-content:center;padding:16px">
        <div style="background:#fff;border-radius:24px;max-width:380px;width:100%;overflow:hidden;position:relative;box-shadow:0 20px 60px rgba(0,0,0,.4)">
            <button onclick="fecharPopupPromo()" style="position:absolute;top:12px;right:12px;background:rgba(0,0,0,.1);border:none;border-radius:50%;width:32px;height:32px;cursor:pointer;font-size:1rem;z-index:1">✕</button>
            <?php if($pp->popup_promo_imagem): ?>
            <img src="<?php echo e(asset('storage/' . $pp->popup_promo_imagem)); ?>" alt="" style="width:100%;max-height:200px;object-fit:cover">
            <?php else: ?>
            <div style="background:linear-gradient(135deg,#dc3545,#FF6B35);padding:24px;text-align:center;color:#fff">
                <div style="font-size:2.5rem;margin-bottom:4px">⚡</div>
                <div style="font-size:.9rem;font-weight:700;letter-spacing:2px;text-transform:uppercase">Promoção Relâmpago</div>
            </div>
            <?php endif; ?>
            <div style="padding:24px;text-align:center">
                <h2 style="font-size:1.4rem;font-weight:900;color:#2C3E50;margin:0 0 8px"><?php echo e($pp->popup_promo_titulo ?: '⚡ Promoção Relâmpago!'); ?></h2>
                <p style="color:#6c757d;margin:0 0 16px;line-height:1.5"><?php echo e($pp->popup_promo_texto ?: 'Aproveite agora! Oferta por tempo limitado.'); ?></p>
                <?php if($pp->popup_promo_expira_em): ?>
                <div style="background:#dc354515;border:1px solid #dc354540;border-radius:10px;padding:10px;margin-bottom:16px">
                    <div style="font-size:.8rem;color:#dc3545;font-weight:700">⏱ Termina em:</div>
                    <div style="font-size:1.8rem;font-weight:900;color:#dc3545;font-family:monospace" id="countdownPromo">--:--:--</div>
                </div>
                <?php endif; ?>
                <?php if($pp->popup_promo_url): ?>
                <a href="<?php echo e($pp->popup_promo_url); ?>" onclick="fecharPopupPromo()" style="display:block;width:100%;padding:14px;background:#dc3545;color:#fff;border-radius:12px;font-size:1rem;font-weight:800;text-decoration:none;text-align:center">
                    ⚡ Ver Promoção!
                </a>
                <?php endif; ?>
                <button onclick="fecharPopupPromo()" style="width:100%;margin-top:8px;padding:10px;background:transparent;color:#6c757d;border:none;cursor:pointer;font-family:inherit;font-size:.85rem">
                    Fechar
                </button>
            </div>
        </div>
    </div>
    <script>
    (function(){
        const COOKIE_KEY  = '<?php echo e($cookiePromo); ?>';
        const DELAY       = <?php echo e($pp->popup_promo_delay_seg ?? 5); ?> * 1000;
        const EXPIRA_ISO  = '<?php echo e($pp->popup_promo_expira_em?->toISOString() ?? ''); ?>';

        if (document.cookie.includes(COOKIE_KEY)) return;

        setTimeout(function() {
            const el = document.getElementById('popupPromoOverlay');
            if (el) { el.style.display = 'flex'; iniciarCountdownPromo(); }
        }, DELAY);

        function iniciarCountdownPromo() {
            if (!EXPIRA_ISO) return;
            const alvo = new Date(EXPIRA_ISO).getTime();
            const el = document.getElementById('countdownPromo');
            if (!el) return;
            const t = setInterval(() => {
                const diff = alvo - Date.now();
                if (diff <= 0) { clearInterval(t); el.textContent = 'ENCERRADA'; return; }
                const h = Math.floor(diff / 3600000);
                const m = Math.floor((diff % 3600000) / 60000);
                const s = Math.floor((diff % 60000) / 1000);
                el.textContent = [h, m, s].map(v => String(v).padStart(2,'0')).join(':');
            }, 1000);
        }

        window.fecharPopupPromo = function() {
            const el = document.getElementById('popupPromoOverlay');
            if (el) el.style.display = 'none';
            document.cookie = COOKIE_KEY + '=1;path=/;max-age=86400';
        };
    })();
    </script>
    <?php endif; ?>
    <?php endif; ?>

    
    <?php if(isset($lojaAtual)): ?>
    <?php $cookieLgpd = 'lgpd_aceito_' . ($lojaAtual->id ?? 0); ?>
    <div id="bannerLgpd" style="display:none;position:fixed;bottom:0;left:0;right:0;z-index:7999;background:#1a1a2e;color:#e6edf3;padding:16px 20px;font-family:'Nunito',sans-serif;border-top:3px solid <?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>">
        <div style="max-width:800px;margin:0 auto;display:flex;align-items:center;gap:16px;flex-wrap:wrap">
            <div style="flex:1;min-width:240px">
                <strong style="font-size:.95rem">🍪 Usamos cookies</strong>
                <p style="font-size:.82rem;margin:4px 0 0;color:#8b949e;line-height:1.5">
                    <?php echo e($lojaAtual->lgpd_texto_cookies ?: 'Utilizamos cookies para melhorar sua experiência, personalizar conteúdo e analisar o tráfego. Ao continuar, você concorda com nossa Política de Privacidade.'); ?>

                    <?php if($lojaAtual->lgpd_url_politica): ?>
                    <a href="<?php echo e($lojaAtual->lgpd_url_politica); ?>" target="_blank" style="color:<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>">Política de Privacidade</a>
                    <?php endif; ?>
                    <?php if($lojaAtual->lgpd_url_termos): ?>
                     · <a href="<?php echo e($lojaAtual->lgpd_url_termos); ?>" target="_blank" style="color:<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>">Termos de Uso</a>
                    <?php endif; ?>
                </p>
            </div>
            <div style="display:flex;gap:8px;flex-shrink:0">
                <button onclick="recusarCookies()" style="padding:8px 16px;background:transparent;color:#8b949e;border:1px solid #30363d;border-radius:8px;cursor:pointer;font-family:inherit;font-size:.85rem">Recusar</button>
                <button onclick="aceitarCookies()" style="padding:8px 20px;background:<?php echo e($lojaAtual->cor_primaria ?? '#FF6B35'); ?>;color:#fff;border:none;border-radius:8px;cursor:pointer;font-family:inherit;font-size:.85rem;font-weight:700">Aceitar</button>
            </div>
        </div>
    </div>
    <script>
    (function(){
        const COOKIE_KEY = '<?php echo e($cookieLgpd); ?>';
        const LOJA_ID    = <?php echo e($lojaAtual->id ?? 'null'); ?>;

        if (!document.cookie.includes(COOKIE_KEY)) {
            setTimeout(() => {
                const el = document.getElementById('bannerLgpd');
                if (el) el.style.display = 'block';
            }, 1500);
        }

        window.aceitarCookies = function() {
            document.cookie = COOKIE_KEY + '=1;path=/;max-age=' + (365 * 86400);
            document.getElementById('bannerLgpd').style.display = 'none';
            fetch('/lgpd/aceitar', {
                method: 'POST',
                headers: { 'Content-Type': 'application/json', 'X-CSRF-TOKEN': '<?php echo e(csrf_token()); ?>' },
                body: JSON.stringify({ tipo: 'cookies', loja_id: LOJA_ID })
            }).catch(() => {});
        };

        window.recusarCookies = function() {
            document.cookie = COOKIE_KEY + '=recusado;path=/;max-age=' + (7 * 86400);
            document.getElementById('bannerLgpd').style.display = 'none';
        };
    })();
    </script>
    <?php endif; ?>

    <!-- Scripts -->
    <script>
        const APP_URL   = '<?php echo e(config("app.url")); ?>';
        const CSRF_TOKEN= '<?php echo e(csrf_token()); ?>';
        const USUARIO_ID= <?php echo e(auth()->id() ?? 'null'); ?>;
        const LOJA_ID   = <?php echo e($lojaAtual->id ?? 'null'); ?>;
        const LOJA_SLUG = '<?php echo e($lojaAtual->slug ?? ""); ?>';
    </script>

    <script src="<?php echo e(asset('js/app.js')); ?>"></script>
    <?php echo $__env->yieldPushContent('scripts'); ?>

    <!-- Service Worker -->
    <script>
        if ('serviceWorker' in navigator) {
            window.addEventListener('load', () => {
                navigator.serviceWorker.register('/sw.js')
                    .catch(err => console.warn('SW não registrado:', err));
            });
        }
    </script>
</body>
</html>
<?php /**PATH /home/nanodelivery/public_html/resources/views/layouts/pwa.blade.php ENDPATH**/ ?>