File size: 13,763 Bytes
840b62e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>UTM Analytics Pro</title>
    <link rel="icon" type="image/x-icon" href="https://cdn-icons-png.flaticon.com/512/2991/2991148.png">
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
    
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#4f46e5', // Indigo 600
                        secondary: '#64748b', // Slate 500
                    }
                }
            }
        }
    </script>
</head>
<body class="bg-gray-50 text-slate-800 font-sans antialiased overflow-hidden">

    <!-- App Container -->
    <div class="flex h-screen">

        <!-- Sidebar Component -->
        <custom-sidebar class="hidden md:flex flex-col w-64 bg-white border-r border-gray-200 h-full"></custom-sidebar>

        <!-- Main Content Area -->
        <div class="flex-1 flex flex-col h-full relative overflow-hidden">
            
            <!-- Header Component -->
            <custom-header></custom-header>

            <!-- Scrollable Content -->
            <main class="flex-1 overflow-y-auto p-4 md:p-8" id="main-scroll">
                
                <!-- Page Header -->
                <div class="mb-8">
                    <h1 class="text-2xl font-bold text-gray-900">Relatório Detalhado: Vendas vs. Pagamentos por UTM</h1>
                    <p class="text-secondary mt-1">Analise o desempenho das suas campanhas em tempo real.</p>
                </div>

                <!-- Warning Banner -->
                <div id="limitation-banner" class="bg-amber-50 border border-amber-200 rounded-lg p-4 mb-6 flex items-start gap-3">
                    <div class="text-amber-500 mt-0.5"><i data-feather="alert-triangle" class="w-5 h-5"></i></div>
                    <div>
                        <h3 class="text-amber-800 font-semibold text-sm">Limitação de Ambiente</h3>
                        <p class="text-amber-700 text-sm mt-1">Os dados simulados não persistem se você recarregar a página. Mantenha a aba aberta para ver as atualizações.</p>
                    </div>
                </div>

                <!-- Filters Section -->
                <section class="bg-white rounded-xl shadow-sm border border-gray-200 p-6 mb-8">
                    <div class="flex flex-col md:flex-row gap-4 items-end justify-between">
                        <div class="flex flex-col md:flex-row gap-4 w-full md:w-auto">
                            <!-- Date Range Select -->
                            <div class="w-full md:w-48">
                                <label class="block text-sm font-medium text-gray-700 mb-1">Período</label>
                                <div class="relative">
                                    <select id="date-range-select" class="block w-full pl-3 pr-10 py-2 text-base border-gray-300 focus:outline-none focus:ring-primary focus:border-primary sm:text-sm rounded-md border bg-gray-50">
                                        <option value="hoje">Hoje</option>
                                        <option value="ontem">Ontem</option>
                                        <option value="ultimos7">Últimos 7 dias</option>
                                        <option value="ultimos30">Últimos 30 dias</option>
                                        <option value="customizado">Período customizado</option>
                                    </select>
                                </div>
                            </div>

                            <!-- Custom Date Range (Hidden by default) -->
                            <div id="custom-date-container" class="w-full md:w-64 hidden">
                                <label class="block text-sm font-medium text-gray-700 mb-1">Datas</label>
                                <input type="date" id="date-start" class="border border-gray-300 rounded-md p-2 text-sm w-1/2 mr-1">
                                <input type="date" id="date-end" class="border border-gray-300 rounded-md p-2 text-sm w-1/2">
                            </div>
                        </div>

                        <!-- Actions -->
                        <div class="flex gap-3 w-full md:w-auto mt-4 md:mt-0">
                            <button id="refresh-btn" class="flex-1 md:flex-none bg-primary hover:bg-indigo-700 text-white px-4 py-2 rounded-lg shadow-sm transition-all duration-200 flex items-center justify-center gap-2 text-sm font-medium">
                                <i data-feather="refresh-cw" class="w-4 h-4"></i> Atualizar Dados
                            </button>
                            <button id="export-btn" class="flex-1 md:flex-none bg-white border border-gray-300 text-gray-700 hover:bg-gray-50 px-4 py-2 rounded-lg shadow-sm transition-all duration-200 flex items-center justify-center gap-2 text-sm font-medium disabled:opacity-50 disabled:cursor-not-allowed">
                                <i data-feather="download" class="w-4 h-4"></i> Exportar CSV
                            </button>
                        </div>
                    </div>
                </section>

                <!-- Alerts Area -->
                <div id="alerts-area" class="space-y-4 mb-8">
                    <!-- Dynamic Alerts will be injected here -->
                </div>

                <!-- KPI Cards -->
                <section id="kpi-section" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8 hidden">
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
                        <div class="flex items-center gap-4">
                            <div class="p-3 bg-indigo-50 rounded-lg text-primary">
                                <i data-feather="package" class="w-6 h-6"></i>
                            </div>
                            <div>
                                <p class="text-sm font-medium text-gray-500">Total Pedidos</p>
                                <h3 class="text-2xl font-bold text-gray-900" id="kpi-total-orders">0</h3>
                            </div>
                        </div>
                    </div>
                    
                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
                        <div class="flex items-center gap-4">
                            <div class="p-3 bg-emerald-50 rounded-lg text-emerald-600">
                                <i data-feather="dollar-sign" class="w-6 h-6"></i>
                            </div>
                            <div>
                                <p class="text-sm font-medium text-gray-500">Vendas Pagas</p>
                                <h3 class="text-2xl font-bold text-gray-900" id="kpi-paid-sales">R$ 0,00</h3>
                            </div>
                        </div>
                    </div>

                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
                        <div class="flex items-center gap-4">
                            <div class="p-3 bg-blue-50 rounded-lg text-blue-600">
                                <i data-feather="pie-chart" class="w-6 h-6"></i>
                            </div>
                            <div>
                                <p class="text-sm font-medium text-gray-500">Taxa Conversão</p>
                                <h3 class="text-2xl font-bold text-gray-900" id="kpi-conversion-rate">0%</h3>
                            </div>
                        </div>
                    </div>

                    <div class="bg-white p-6 rounded-xl shadow-sm border border-gray-200">
                        <div class="flex items-center gap-4">
                            <div class="p-3 bg-purple-50 rounded-lg text-purple-600">
                                <i data-feather="tag" class="w-6 h-6"></i>
                            </div>
                            <div>
                                <p class="text-sm font-medium text-gray-500">UTMs Únicas</p>
                                <h3 class="text-2xl font-bold text-gray-900" id="kpi-unique-utms">0</h3>
                            </div>
                        </div>
                    </div>
                </section>

                <!-- Table Section -->
                <section class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden min-h-[400px]">
                    <div class="p-6 border-b border-gray-200 flex justify-between items-center">
                        <h2 class="text-lg font-bold text-gray-900">Detalhamento por UTM</h2>
                        <div class="flex items-center gap-2 text-sm text-gray-500">
                            <span>Ordernar por:</span>
                            <select id="sort-select" class="border-none bg-transparent font-medium text-primary focus:ring-0 cursor-pointer">
                                <option value="totalVendas">Vendas (Desc)</option>
                                <option value="taxaPagamento">Taxa Pagamento (Desc)</option>
                                <option value="totalPedidos">Pedidos (Desc)</option>
                            </select>
                        </div>
                    </div>

                    <!-- Loading State -->
                    <div id="table-loading" class="flex flex-col items-center justify-center p-12">
                        <div class="animate-spin rounded-full h-10 w-10 border-b-2 border-primary mb-4"></div>
                        <p class="text-gray-500">Processando dados dos pedidos...</p>
                    </div>

                    <!-- Empty State -->
                    <div id="table-empty" class="hidden flex flex-col items-center justify-center p-12 text-center">
                        <div class="p-4 bg-gray-100 rounded-full mb-4">
                            <i data-feather="inbox" class="w-8 h-8 text-gray-400"></i>
                        </div>
                        <h3 class="text-lg font-medium text-gray-900">Nenhum dado encontrado</h3>
                        <p class="text-gray-500 max-w-sm mt-1">Selecione um período e clique em "Atualizar Dados" para visualizar o relatório.</p>
                    </div>

                    <!-- Data Table -->
                    <div class="overflow-x-auto">
                        <table class="w-full text-left border-collapse hidden" id="data-table">
                            <thead>
                                <tr class="bg-gray-50 text-gray-500 text-xs uppercase tracking-wider">
                                    <th class="p-4 font-semibold cursor-pointer hover:bg-gray-100 transition-colors group" onclick="app.handleSort('utmContent')">
                                        Campanha <i data-feather="chevrons-up-down" class="w-3 h-3 inline ml-1 opacity-50 group-hover:opacity-100"></i>
                                    </th>
                                    <th class="p-4 font-semibold text-right">Pedidos (Pagos/Total)</th>
                                    <th class="p-4 font-semibold text-center">Clientes Únicos</th>
                                    <th class="p-4 font-semibold text-right cursor-pointer hover:bg-gray-100 transition-colors group" onclick="app.handleSort('totalVendas')">
                                        Total Vendas <i data-feather="chevrons-up-down" class="w-3 h-3 inline ml-1 opacity-50 group-hover:opacity-100"></i>
                                    </th>
                                    <th class="p-4 font-semibold text-right cursor-pointer hover:bg-gray-100 transition-colors group" onclick="app.handleSort('vendasPagas')">
                                        Vendas Pagas <i data-feather="chevrons-up-down" class="w-3 h-3 inline ml-1 opacity-50 group-hover:opacity-100"></i>
                                    </th>
                                    <th class="p-4 font-semibold text-center cursor-pointer hover:bg-gray-100 transition-colors group" onclick="app.handleSort('taxaPagamento')">
                                        Taxa Pagamento <i data-feather="chevrons-up-down" class="w-3 h-3 inline ml-1 opacity-50 group-hover:opacity-100"></i>
                                    </th>
                                </tr>
                            </thead>
                            <tbody class="divide-y divide-gray-100 text-sm" id="table-body">
                                <!-- Rows injected via JS -->
                            </tbody>
                            <tfoot class="bg-gray-50 font-semibold text-gray-900 text-sm">
                                <tr id="table-footer">
                                    <!-- Footer totals injected via JS -->
                                </tr>
                            </tfoot>
                        </table>
                    </div>
                </section>

                <footer class="mt-12 mb-6 text-center text-sm text-gray-400">
                    &copy; 2023 UTM Analytics Pro. Todos os direitos reservados.
                </footer>
            </main>
        </div>
    </div>

    <!-- Scripts -->
    <script src="components/sidebar.js"></script>
    <script src="components/header.js"></script>
    <script src="script.js"></script>
    <script>
        feather.replace();
    </script>
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
</body>
</html>