<?php get_header(); ?>

<?php
while ( have_posts() ) : the_post();

    // Imagem do Banner
    $banner_bg = get_the_post_thumbnail_url( get_the_ID(), 'full' );
    if ( empty( $banner_bg ) ) {
        $banner_bg = 'https://images.unsplash.com/photo-1507643192792-213580d3a301?q=80&w=2070';
    }

    // LÓGICA DE COMPARTILHAMENTO
    $share_link = get_permalink();
    $share_title = get_the_title();
    
    $share_excerpt = get_the_excerpt();
    if (empty($share_excerpt)) {
        $share_excerpt = wp_trim_words(get_the_content(), 20, '...');
    }
    
    $enc_link = urlencode($share_link);
    $enc_text = urlencode($share_excerpt . " - " . $share_link);
    $enc_title = urlencode($share_title);

    $fb_url = "https://www.facebook.com/sharer/sharer.php?u={$enc_link}";
    $tw_url = "https://twitter.com/intent/tweet?text={$enc_title}&url={$enc_link}";
    $wa_url = "https://api.whatsapp.com/send?text={$enc_text}"; 
    $mail_url = "mailto:?subject={$enc_title}&body={$enc_text}";
?>

    <style>
        /* --- 1. REMOVER ÍCONES FLUTUANTES DA LATERAL --- */
        .floating-social, .floating-icons, .heateor_sss_vertical_sharing, .heateor_sss_floating_content, #heateor_sss_sharing_toolbox_left { 
            display: none !important; 
        }

        /* --- 2. CORREÇÕES DE HEADER (TRANSPARENTE / SOBREPOSTO) --- */
        html, body { margin-top: 0 !important; padding-top: 0 !important; overflow-x: hidden; }

        /* Ajuste: Menu Absoluto e Transparente */
        header, .site-header, #masthead, .navbar {
            margin-top: 0px !important; 
            top: 0px !important; 
            position: absolute !important; /* Permite que a imagem suba */
            left: 0 !important;
            z-index: 9999 !important; 
            width: 100% !important; 
            background-color: transparent !important; /* Fundo transparente */
            display: block !important; 
            visibility: visible !important;
            padding-top: 60px !important; 
            padding-bottom: 20px !important;
            border-bottom: none !important;
        }

        .site-logo img, .custom-logo-link img, .header-logo img, #logo img {
            display: block !important; visibility: visible !important; opacity: 1 !important;
            max-height: 85px; width: auto; margin-top: 0px !important; position: relative; z-index: 10010;
        }

        /* --- BARRA DE TOPO (SEMI-TRANSPARENTE) --- */
        .custom-top-bar-wrapper { 
            position: absolute; 
            top: 0; 
            left: 0; 
            width: 100%; 
            height: 45px; 
            background-color: rgba(0,0,0,0.3) !important; /* Semi-transparente */
            border-bottom: 1px solid rgba(255,255,255,0.1); 
            z-index: 10005; 
            display: flex; 
            justify-content: center; 
        }
        
        .custom-top-bar-inner { width: 100%; max-width: 1280px; padding: 0 20px; display: flex; justify-content: space-between; align-items: center; height: 100%; }
        .top-contact-info { display: flex; gap: 25px; align-items: center; }
        .contact-item { display: flex; align-items: center; gap: 8px; color: #ffffff; font-size: 13px; font-family: sans-serif; text-decoration: none; transition: color 0.3s; letter-spacing: 0.5px; }
        .contact-item:hover { color: #d4af37; text-decoration: none; }
        .contact-item svg { width: 14px; height: 14px; fill: currentColor; }
        .top-social-icons { display: flex; gap: 15px; align-items: center; }
        .custom-top-icon { color: #ffffff; font-size: 14px; text-decoration: none; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; cursor: pointer; padding: 5px; }
        .custom-top-icon:hover { color: #d4af37; transform: translateY(-2px); }
        .custom-top-icon svg { width: 16px; height: 16px; fill: currentColor; }

        @media (max-width: 992px) {
            .custom-top-bar-wrapper { display: none !important; }
            header, .site-header, #masthead, .navbar { padding-top: 15px !important; padding-bottom: 15px !important; position: relative !important; background-color: #1a1a1a !important; } /* Mobile mantém fundo para legibilidade */
            .site-logo img, .custom-logo-link img, .header-logo img, #logo img { max-height: 60px; margin-top: 0 !important; }
        }

        /* --- MODAL DE BUSCA --- */
        .search-modal { display: none; position: fixed; z-index: 999999; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.95); align-items: center; justify-content: center; animation: fadeIn 0.3s; }
        .search-modal.open { display: flex; }
        .search-modal-content { position: relative; width: 80%; max-width: 700px; text-align: center; }
        .search-modal input { width: 100%; padding: 20px; font-size: 24px; border: none; border-bottom: 2px solid #fff; background: transparent; color: #fff; outline: none; text-align: center; }
        .search-modal-close { position: absolute; top: 30px; right: 30px; color: #fff; font-size: 40px; cursor: pointer; }
        @keyframes fadeIn { from {opacity: 0;} to {opacity: 1;} }

        /* --- GERAL --- */
        img { max-width: 100%; height: auto; }

        /* --- BANNER TOPO (HERO) --- */
        .page-header { 
            position: relative; 
            height: 450px; 
            background-color: #1a1a1a; 
            background-size: cover; 
            background-position: center; 
            display: flex; align-items: center; justify-content: center; text-align: center; 
            margin-top: 0;
            padding-top: 80px; 
        }
        .page-header::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1; }
        .page-header-content { position: relative; z-index: 2; color: #fff; width: 100%; max-width: 900px; padding: 0 20px; }
        
        .page-title { 
            font-size: 3.5rem; 
            font-family: var(--font-title); 
            margin-bottom: 20px; 
            line-height: 1.1; 
            word-wrap: break-word; 
        }

        /* Meta Banner */
        .header-meta {
            display: flex; justify-content: center; align-items: center;
            gap: 15px; font-size: 0.95rem; color: #fff; margin-top: 10px;
            flex-wrap: wrap;
        }
        .meta-date { display: flex; align-items: center; gap: 6px; font-weight: 500; }
        .meta-date svg { width: 14px; height: 14px; fill: var(--color-btn); display: block; }
        .header-sep { opacity: 0.4; font-size: 0.8rem; position: relative; top: -1px; }
        .meta-author { font-size: 0.85rem; opacity: 0.8; font-weight: 400; letter-spacing: 0.5px; }
        .meta-author strong { font-weight: 600; color: #fff; }

        /* --- LAYOUT GRID --- */
        .main-content-area { padding: 80px 0; }
        .layout-grid {
            display: grid; 
            grid-template-columns: 1fr 340px; 
            gap: 50px; 
            max-width: 1280px; 
            margin: 0 auto; 
            position: relative; z-index: 10; 
            margin-top: -50px; /* AJUSTADO: Desceu a caixa branca (era -100px) */
        }
        
        /* Coluna Esquerda (Post) */
        .content-container { 
            background: #fff; 
            padding: 80px; 
            border-radius: 0; 
            box-shadow: 0 10px 40px rgba(0,0,0,0.05); 
            /* ALTERADO: Largura máxima aumentada de 900px para 1050px */
            max-width: 1050px; 
            margin: 0 auto;
        }
        
        /* Coluna Direita (Sidebar) */
        .site-sidebar { 
            display: flex; flex-direction: column; gap: 40px; 
            margin-top: 120px; 
        }

        /* --- BARRA AÇÕES E BREADCRUMB --- */
        .meta-share-wrapper {
            display: flex; justify-content: space-between; align-items: center;
            border-bottom: 1px solid #eee; padding-bottom: 25px; margin-bottom: 40px;
            flex-wrap: wrap; gap: 20px;
        }
        
        /* Breadcrumbs Ajustado */
        .breadcrumbs-dark { 
            font-size: 0.75rem; 
            text-transform: uppercase; 
            letter-spacing: 1px; 
            color: #888; 
            display: flex;
            align-items: center;
            flex-wrap: wrap;
            gap: 5px;
        }
        .breadcrumbs-dark a { color: #666; text-decoration: none; font-weight: 600; }
        .breadcrumbs-dark a:hover { color: var(--color-btn); }
        .breadcrumbs-dark .separator { opacity: 0.4; }
        .breadcrumbs-dark .current { font-weight: bold; color: #333; }

        .actions-right { display: flex; align-items: center; gap: 15px; }
        .action-sep { width: 1px; height: 25px; background-color: #eee; margin: 0 5px; }
        .share-btn, .like-btn {
            width: 36px; height: 36px; border-radius: 50%;
            display: flex; align-items: center; justify-content: center;
            color: #fff; transition: all 0.2s ease; 
            text-decoration: none !important; border: none; cursor: pointer;
        }
        .share-btn svg, .like-btn svg { width: 18px; height: 18px; fill: currentColor; }
        .share-btn:hover, .like-btn:hover { transform: translateY(-2px); opacity: 0.9; }
        .share-wa { background-color: #25D366; }
        .share-fb { background-color: #1877F2; }
        .share-tw { background-color: #000; }
        .share-email { background-color: #888; }
        
        .like-btn { background-color: transparent; color: #ccc; border: 2px solid #eee; }
        .like-btn svg { fill: transparent; stroke: currentColor; stroke-width: 2px; transition: all 0.3s; }
        .like-btn.liked { background-color: #fff0f0; color: #ff4757; border-color: #ff4757; animation: pulse 0.4s ease-in-out; }
        .like-btn.liked svg { fill: #ff4757; stroke: #ff4757; }
        @keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

        /* --- WIDGETS --- */
        .widget-box { background: transparent; box-shadow: none; padding: 0; margin-bottom: 20px; }
        .widget-title { 
            font-family: var(--font-title); font-size: 1.3rem; color: #222; 
            margin-bottom: 25px; padding-bottom: 10px; 
            border-bottom: 1px solid rgba(0,0,0,0.1); position: relative;
        }
        .widget-title::after { content: ''; position: absolute; bottom: -1px; left: 0; width: 50px; height: 2px; background-color: var(--color-btn); }
        .banner-widget img { width: 100%; max-width: 300px; height: auto; border-radius: 12px; display: block; margin: 0 auto; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }

        .sidebar-posts-list { list-style: none; padding: 0; margin: 0; }
        .sidebar-post-item { display: flex; align-items: center; gap: 15px; margin-bottom: 25px; border-bottom: 1px solid rgba(0,0,0,0.05); padding-bottom: 15px; }
        .sidebar-post-item:last-child { border-bottom: none; margin-bottom: 0; }
        .sidebar-thumb { width: 65px; height: 65px; object-fit: cover; border-radius: 50%; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.1); border: 2px solid #fff; }
        .sidebar-post-info { display: flex; flex-direction: column; justify-content: center; }
        .sidebar-post-title { font-size: 0.95rem; font-weight: 700; line-height: 1.4; margin-bottom: 4px; color: #333; text-decoration: none; transition: color 0.2s; font-family: var(--font-title); }
        .sidebar-post-title:hover { color: var(--color-btn); }
        .sidebar-post-date { font-size: 0.75rem; color: #999; letter-spacing: 0.5px; }

        .sidebar-categories-list { list-style: none; padding: 0; }
        .sidebar-categories-list li { margin-bottom: 8px; }
        .sidebar-categories-list a { display: flex; align-items: center; color: #555; font-size: 0.95rem; font-weight: 500; padding: 10px 15px; background-color: #fff; border-radius: 8px; box-shadow: 0 2px 5px rgba(0,0,0,0.02); transition: all 0.2s ease; }
        .sidebar-categories-list a:hover { background-color: var(--color-btn); color: #fff; transform: translateX(5px); }
        .sidebar-categories-list a span { margin-left: 10px; font-size: 0.75rem; background-color: rgba(0,0,0,0.05); padding: 2px 8px; border-radius: 10px; font-weight: 600; color: #888; }
        .sidebar-categories-list a:hover span { background-color: rgba(255,255,255,0.2); color: #fff; }

        /* --- TIPOGRAFIA --- */
        .entry-content { line-height: 1.9; font-size: 1.25rem; color: #444; font-family: var(--font-text); }
        .entry-content p { margin-bottom: 1.5em !important; display: block; }
        .entry-content h2 { font-size: 2rem; margin-top: 40px; margin-bottom: 15px; font-family: var(--font-title); color: #222; }
        .entry-content h3 { font-size: 1.6rem; margin-top: 30px; margin-bottom: 10px; font-family: var(--font-title); color: #333; }
        .entry-content blockquote { border-left: 5px solid var(--color-btn); background-color: #F9F9F9; margin: 40px 0; padding: 25px 35px; font-family: var(--font-title); font-size: 1.25rem; font-style: normal; color: #555; position: relative; border-radius: 0 10px 10px 0; }
        .entry-content blockquote::before { content: '“'; font-size: 3.5rem; color: var(--color-btn); opacity: 0.3; position: absolute; top: 5px; left: 10px; line-height: 1; }
        .entry-content blockquote cite { display: block; font-size: 0.9rem; margin-top: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: #888; }

        /* --- NOVO: BOX CTA (Chamada para Ação) --- */
        .post-cta-box {
            background-color: #F9F9F9;
            border-left: 5px solid #d4af37;
            padding: 45px 30px;
            margin: 60px 0 40px 0;
            border-radius: 8px;
            display: flex; flex-direction: column; align-items: center; text-align: center; gap: 20px;
            box-shadow: 0 5px 20px rgba(0,0,0,0.03);
        }
        .post-cta-box h3 { font-family: var(--font-title, serif); color: #222; margin: 0; font-size: 1.6rem; }
        .post-cta-box p { font-family: var(--font-text, sans-serif); color: #666; font-size: 1rem; max-width: 600px; margin: 0; line-height: 1.5; }
        .cta-buttons-row { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
        .btn-cta { 
            padding: 12px 30px; border-radius: 50px; text-decoration: none !important; font-weight: 600; 
            text-transform: uppercase; font-size: 0.85rem; letter-spacing: 1px; transition: all 0.3s ease; 
        }
        .btn-cta-newsletter { background-color: #1a1a1a; color: #fff; border: 2px solid #1a1a1a; }
        .btn-cta-newsletter:hover { background-color: transparent; color: #1a1a1a; transform: translateY(-2px); }
        .btn-cta-donate { background-color: transparent; color: #d4af37; border: 2px solid #d4af37; }
        .btn-cta-donate:hover { background-color: #d4af37; color: #fff; transform: translateY(-2px); }

        /* Navegação */
        .post-navigation-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 30px; margin-top: 60px; padding-top: 50px; border-top: 1px solid #eee; }
        .nav-link-box { display: flex; flex-direction: column; text-decoration: none; group: hover; }
        .nav-link-box:hover .nav-title { color: var(--color-btn); }
        .nav-thumb { height: 180px; width: 100%; object-fit: cover; border-radius: 12px; margin-bottom: 15px; background-color: #eee; transition: transform 0.3s ease; }
        .nav-link-box:hover .nav-thumb { transform: scale(1.02); }
        .nav-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; color: #999; margin-bottom: 5px; font-weight: 600; }
        .nav-title { font-family: var(--font-title); font-size: 1.3rem; color: #333; line-height: 1.4; transition: color 0.3s; }

        /* --- RESPONSIVIDADE COMPLETA (MOBILE) --- */
        
        /* Tablet (max 1024px) */
        @media (max-width: 1024px) {
            .site-sidebar { display: none; } /* Oculta Sidebar */
            .layout-grid { grid-template-columns: 1fr; max-width: 900px; gap: 0; }
            .page-title { font-size: 3rem; }
            .content-container { padding: 50px 40px; margin-top: -60px; }
        }

        /* Celular (max 768px) */
        @media (max-width: 768px) {
            /* AJUSTE SOLICITADO: Subir titulo h1 no mobile */
            .page-header { 
                height: 400px; /* Mais altura para caber o texto */
                align-items: flex-end; /* Alinha o conteudo embaixo */
                padding-bottom: 80px; /* Empurra o texto para cima, fugindo do corte branco */
            }
            .page-title { font-size: 2.2rem; margin-bottom: 10px; }
            
            .header-meta { flex-direction: column; gap: 5px; }
            .header-sep { display: none; }
            
            .main-content-area { padding: 40px 0; }
            .content-container { 
                padding: 30px 20px; 
                margin-top: -30px; /* Sobe um pouco a caixa branca (ajustado de -50px) */
                width: 95%; 
                margin-left: auto; margin-right: auto;
            }
            
            .meta-share-wrapper { flex-direction: column; align-items: flex-start; gap: 20px; }
            .actions-right { width: 100%; justify-content: space-between; }
            
            .entry-content { font-size: 1.15rem; } /* Fonte um pouco menor */
            .entry-content blockquote { padding: 20px; font-size: 1.1rem; }
            
            /* Ajuste CTA Mobile */
            .cta-buttons-row { flex-direction: column; width: 100%; gap: 10px; }
            .btn-cta { width: 100%; text-align: center; }

            /* Navegação empilhada */
            .post-navigation-grid { grid-template-columns: 1fr; gap: 30px; }
            .nav-link-box.next-link { text-align: left !important; align-items: flex-start !important; }
        }

        /* Celular Pequeno (max 480px) */
        @media (max-width: 480px) {
            .page-title { font-size: 1.8rem; }
            .content-container { padding: 25px 15px; width: 100%; border-radius: 0; }
            .breadcrumbs-dark { font-size: 0.75rem; }
        }

        /* Correção Rodapé Interno */
        footer, .site-footer, #footer { margin-top: 60px !important; padding-top: 40px !important; }
    </style>

    <div id="siteSearchModal" class="search-modal">
        <span class="search-modal-close" onclick="closeSearchModal()">&times;</span>
        <div class="search-modal-content">
            <form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
                <input type="text" value="" name="s" id="s" placeholder="O que você procura? Digite e Enter..." />
            </form>
        </div>
    </div>

    <section class="page-header" style="background-image: url('<?php echo esc_url( $banner_bg ); ?>');">
        <div class="page-header-content">
            <h1 class="page-title"><?php the_title(); ?></h1>
            <div class="header-meta">
                <span class="meta-date">
                    <svg viewBox="0 0 24 24"><path d="M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20a2 2 0 0 0 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 16H5V10h14v10zm0-12H5V6h14v2z"/></svg>
                    <?php echo get_the_modified_date('d/m/Y H\hi'); ?>
                </span>
                <span class="header-sep">|</span>
                <span class="meta-author">Por: <strong><?php the_author(); ?></strong></span>
            </div>
        </div>
    </section>

    <main class="main-content-area">
        <div class="container">
            <div class="layout-grid">
                
                <div class="content-container">
                    
                    <div class="meta-share-wrapper">
                        <div class="breadcrumbs-dark">
                            <a href="<?php echo home_url(); ?>">Início</a>
                            <span class="separator">/</span>
                            
                            <?php
                            global $post;
                            
                            // 1. Verifica se é uma PÁGINA com hierarquia (Pai > Filho)
                            if ( is_page() && $post->post_parent ) {
                                $ancestors = get_post_ancestors( $post->ID );
                                $ancestors = array_reverse( $ancestors );
                                foreach ( $ancestors as $ancestor ) {
                                    echo '<a href="' . get_permalink( $ancestor ) . '">' . get_the_title( $ancestor ) . '</a> <span class="separator">/</span>';
                                }
                            }
                            
                            // 2. Se for POST com Categoria (Fallback)
                            elseif ( has_category() ) {
                                $cats = get_the_category();
                                if ( $cats ) {
                                    echo '<a href="' . get_category_link( $cats[0]->term_id ) . '">' . $cats[0]->name . '</a> <span class="separator">/</span>';
                                }
                            }
                            ?>
                            
                            <span class="current"><?php the_title(); ?></span>
                        </div>

                        <div class="actions-right">
                            <button class="like-btn" onclick="this.classList.toggle('liked')" aria-label="Gostei">
                                <svg viewBox="0 0 24 24"><path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/></svg>
                            </button>
                            <div class="action-sep"></div>
                            <a href="<?php echo esc_url($mail_url); ?>" class="share-btn share-email" aria-label="Enviar por E-mail">
                                <svg viewBox="0 0 24 24"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>
                            </a>
                            <a href="<?php echo esc_url($wa_url); ?>" target="_blank" class="share-btn share-wa" aria-label="WhatsApp">
                                <svg viewBox="0 0 24 24"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413z"/></svg>
                            </a>
                            <a href="<?php echo esc_url($fb_url); ?>" target="_blank" class="share-btn share-fb" aria-label="Facebook">
                                <svg viewBox="0 0 24 24"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"></path></svg>
                            </a>
                            <a href="<?php echo esc_url($tw_url); ?>" target="_blank" class="share-btn share-tw" aria-label="X">
                                <svg viewBox="0 0 24 24"><path d="M18.901 1.153h3.68l-8.04 9.19L24 22.846h-7.406l-5.8-7.584-6.638 7.584H.474l8.6-9.83L0 1.154h7.594l5.243 6.932ZM17.61 20.644h2.039L6.486 3.24H4.298Z"></path></svg>
                            </a>
                        </div>
                    </div>

                    <article class="entry-content">
                        <?php the_content(); ?>
                    </article>

                    <div class="post-cta-box">
                        <h3>Gostou desta leitura?</h3>
                        <p>Faça parte da nossa comunidade e receba estudos exclusivos, ou apoie nosso ministério com uma oferta de amor.</p>
                        <div class="cta-buttons-row">
                            <a href="#" class="btn-cta btn-cta-newsletter">Assinar Newsletter</a>
                            <a href="#" class="btn-cta btn-cta-donate">Fazer Doação</a>
                        </div>
                    </div>

                    <div class="post-navigation-grid">
                        <?php
                        $prev_post = get_previous_post();
                        if (!empty($prev_post)) {
                            $prev_thumb = get_the_post_thumbnail_url($prev_post->ID, 'medium');
                            if(empty($prev_thumb)) $prev_thumb = 'https://via.placeholder.com/600x400?text=Versiculo+Vivo';
                            ?>
                            <a href="<?php echo get_permalink($prev_post->ID); ?>" class="nav-link-box prev-link">
                                <img src="<?php echo esc_url($prev_thumb); ?>" alt="Anterior" class="nav-thumb">
                                <span class="nav-label">← Anterior</span>
                                <h4 class="nav-title"><?php echo get_the_title($prev_post->ID); ?></h4>
                            </a>
                        <?php } else { echo '<div></div>'; } ?>

                        <?php
                        $next_post = get_next_post();
                        if (!empty($next_post)) {
                            $next_thumb = get_the_post_thumbnail_url($next_post->ID, 'medium');
                            if(empty($next_thumb)) $next_thumb = 'https://via.placeholder.com/600x400?text=Versiculo+Vivo';
                            ?>
                            <a href="<?php echo get_permalink($next_post->ID); ?>" class="nav-link-box next-link" style="text-align: right; align-items: flex-end;">
                                <img src="<?php echo esc_url($next_thumb); ?>" alt="Próximo" class="nav-thumb">
                                <span class="nav-label">Próximo →</span>
                                <h4 class="nav-title"><?php echo get_the_title($next_post->ID); ?></h4>
                            </a>
                        <?php } ?>
                    </div>
                </div>

                <aside class="site-sidebar">
                    
                    <div class="widget-box banner-widget">
                        <img src="https://images.unsplash.com/photo-1493612276216-9c5901955d43?q=80&w=300&h=300&auto=format&fit=crop" alt="Anuncie Aqui">
                    </div>

                    <div class="widget-box">
                        <h3 class="widget-title">Últimos Posts</h3>
                        <ul class="sidebar-posts-list">
                            <?php
                            $recent_posts = new WP_Query( array( 'posts_per_page' => 4, 'post_status' => 'publish', 'ignore_sticky_posts' => 1 ) );
                            if ( $recent_posts->have_posts() ) :
                                while ( $recent_posts->have_posts() ) : $recent_posts->the_post();
                                    $thumb_url = get_the_post_thumbnail_url(get_the_ID(), 'thumbnail');
                                    if(empty($thumb_url)) $thumb_url = 'https://via.placeholder.com/150';
                            ?>
                                <li class="sidebar-post-item">
                                    <img src="<?php echo esc_url($thumb_url); ?>" class="sidebar-thumb" alt="<?php the_title(); ?>">
                                    <div class="sidebar-post-info">
                                        <a href="<?php the_permalink(); ?>" class="sidebar-post-title"><?php the_title(); ?></a>
                                        <span class="sidebar-post-date"><?php echo get_the_date('d M, Y'); ?></span>
                                    </div>
                                </li>
                            <?php 
                                endwhile; 
                                wp_reset_postdata();
                            endif; 
                            ?>
                        </ul>
                    </div>

                    <div class="widget-box">
                        <h3 class="widget-title">Categorias</h3>
                        <ul class="sidebar-categories-list">
                            <?php 
                            $cats = get_categories();
                            foreach($cats as $cat) {
                                echo '<li><a href="'.get_category_link($cat->term_id).'">'.$cat->name.' <span>'.$cat->count.'</span></a></li>';
                            }
                            ?>
                        </ul>
                    </div>

                </aside>

            </div>
        </div>
    </main>

<?php endwhile; ?>

<script>
    function openSearchModal() {
        document.getElementById('siteSearchModal').classList.add('open');
        document.getElementById('s').focus();
    }
    function closeSearchModal() {
        document.getElementById('siteSearchModal').classList.remove('open');
    }

    document.addEventListener('DOMContentLoaded', function() {
        
        const newLogoUrl = 'https://versiculovivo.com.br/wp-content/uploads/2024/12/logo-versiculo-vivo-e1768917206498.png';
        const logos = document.querySelectorAll('.site-logo img, .custom-logo-link img, .header-logo img, #logo img');
        logos.forEach(img => {
            img.src = newLogoUrl;
            img.srcset = '';
        });

        if (!document.querySelector('.custom-top-bar-wrapper')) {
            const topBarHTML = `
                <div class="custom-top-bar-wrapper">
                    <div class="custom-top-bar-inner">
                        <div class="top-contact-info">
                            <a href="tel:+5511974554942" class="contact-item">
                                 <svg viewBox="0 0 24 24" fill="currentColor"><path d="M6.62 10.79c1.44 2.83 3.76 5.14 6.59 6.59l2.2-2.2c.27-.27.67-.36 1.02-.24 1.12.37 2.33.57 3.57.57.55 0 1 .45 1 1V20c0 .55-.45 1-1 1-9.39 0-17-7.61-17-17 0-.55.45-1 1-1h3.5c.55 0 1 .45 1 1 1.25 0 2.45.2 3.57.57.35.11.74.03 1.02-.24l2.2-2.2z"/></svg>
                                 (11) 9.7455.4942
                            </a>
                            <a href="mailto:contato@versiculovivo.com.br" class="contact-item">
                                <svg viewBox="0 0 24 24" fill="currentColor"><path d="M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4l-8 5-8-5V6l8 5 8-5v2z"/></svg>
                                contato@versiculovivo.com.br
                            </a>
                        </div>

                        <div class="top-social-icons">
                            <a href="#" class="custom-top-icon" onclick="openSearchModal(); return false;" title="Buscar">
                                <svg viewBox="0 0 24 24"><path d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" fill="none"></path></svg>
                            </a>
                            <a href="https://facebook.com/versiculovivo" target="_blank" class="custom-top-icon" title="Facebook">
                                <svg viewBox="0 0 24 24" fill="currentColor"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"></path></svg>
                            </a>
                            <a href="https://linkedin.com" target="_blank" class="custom-top-icon" title="LinkedIn">
                                <svg viewBox="0 0 24 24" fill="currentColor"><path d="M16 8a6 6 0 0 1 6 6v7h-4v-7a2 2 0 0 0-2-2 2 2 0 0 0-2 2v7h-4v-7a6 6 0 0 1 6-6z"></path><rect x="2" y="9" width="4" height="12"></rect><circle cx="4" cy="4" r="2"></circle></svg>
                            </a>
                            <a href="https://wa.me/5511974554942" target="_blank" class="custom-top-icon" title="WhatsApp">
                                <svg viewBox="0 0 24 24" fill="currentColor"><path d="M17.472 14.382c-.297-.149-1.758-.867-2.03-.967-.273-.099-.471-.148-.67.15-.197.297-.767.966-.94 1.164-.173.199-.347.223-.644.075-.297-.15-1.255-.463-2.39-1.475-.883-.788-1.48-1.761-1.653-2.059-.173-.297-.018-.458.13-.606.134-.133.298-.347.446-.52.149-.174.198-.298.298-.497.099-.198.05-.371-.025-.52-.075-.149-.669-1.612-.916-2.207-.242-.579-.487-.5-.669-.51-.173-.008-.371-.01-.57-.01-.198 0-.52.074-.792.372-.272.297-1.04 1.016-1.04 2.479 0 1.462 1.065 2.875 1.213 3.074.149.198 2.096 3.2 5.077 4.487.709.306 1.262.489 1.694.625.712.227 1.36.195 1.871.118.571-.085 1.758-.719 2.006-1.413.248-.694.248-1.289.173-1.413-.074-.124-.272-.198-.57-.347m-5.421 7.403h-.004a9.87 9.87 0 01-5.031-1.378l-.361-.214-3.741.982.998-3.648-.235-.374a9.86 9.86 0 01-1.51-5.26c.001-5.45 4.436-9.884 9.888-9.884 2.64 0 5.122 1.03 6.988 2.898a9.825 9.825 0 012.893 6.994c-.003 5.45-4.437 9.884-9.885 9.884m8.413-18.297A11.815 11.815 0 0012.05 0C5.495 0 .16 5.335.157 11.892c0 2.096.547 4.142 1.588 5.945L.057 24l6.305-1.654a11.882 11.882 0 005.683 1.448h.005c6.554 0 11.89-5.335 11.893-11.893a11.821 11.821 0 00-3.48-8.413Z"/></svg>
                            </a>
                        </div>
                    </div>
                </div>
            `;
            
            const masthead = document.querySelector('#masthead, .site-header, header');
            if(masthead) {
                masthead.insertAdjacentHTML('afterbegin', topBarHTML);
            }
        }
    });
    
    
</script>

<?php get_footer(); ?>