File size: 38,910 Bytes
4bea261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9cf72a
4bea261
 
 
 
 
 
 
 
 
 
a9cf72a
4bea261
a9cf72a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4bea261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9cf72a
4bea261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a9cf72a
4bea261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
---
import '../styles/global.css';
import crypto from 'node:crypto';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.jsx';
import SplashScreen from '../components/SplashScreen.jsx';

import { txasupabase } from '../lib/txasupabase.js';

interface Props {
  title?: string;
  description?: string;
  image?: string;
  type?: string;
  slug?: string;
}

import { ClientRouter } from 'astro:transitions';

const settings = await txasupabase.getSettings() || {};
const siteName = settings.site_name || 'DPTXA';
const siteDescription = settings.site_description || 'DPTXA - Động Phim TXA | Nền tảng xem phim trực tuyến miễn phí với kho phim khổng lồ, cập nhật liên tục mỗi ngày. Phim bộ, phim lẻ, hoạt hình Full HD Vietsub.';
const siteKeywords = settings.site_keywords || 'xem phim online, phim vietsub, phim hd, phim moi, phim bo, phim le, hoat hinh, dptxa, dong phim txa';
const siteUrl = await txasupabase.getSiteUrl(Astro.request);

const {
  title = 'Động Phim Đỉnh Cao',
  description = siteDescription,
  image = 'https://dongmephim.online/og-image.jpg',
  type = 'website',
  slug = ''
} = Astro.props;

// Automatically replace TPHIMX / DPTXA with the dynamic siteName from Admin Dashboard
const dynamicTitle = title.replace(/TPHIMX|DPTXA/gi, siteName);
const dynamicDescription = description.replace(/TPHIMX|DPTXA/gi, siteName);
const dynamicKeywords = siteKeywords.replace(/TPHIMX|DPTXA/gi, siteName);

// --- REFERRER DECOY GATEKEEPER & ZALO ACCESS GATEKEEPER ---
const currentPath = Astro.url.pathname;

// Các trang được miễn trừ bộ lọc ngụy trang (để Admin làm việc và các API hoạt động)
const isExempted = currentPath.startsWith('/admin') || 
                   currentPath.startsWith('/api/') ||
                   currentPath === '/dang-nhap' ||
                   currentPath === '/dang-ky';

const referer = Astro.request.headers.get('referer') || '';
const url = new URL(Astro.request.url);
const refParam = url.searchParams.get('ref') || url.searchParams.get('from') || '';
const bypassParam = url.searchParams.get('bypass') || '';

let isReferred = Astro.cookies.get('nrotxa_referred')?.value === 'true';

if (bypassParam === 'true') {
  isReferred = true;
  Astro.cookies.set('nrotxa_referred', 'true', { path: '/', maxAge: 365 * 24 * 60 * 60 });
  Astro.cookies.set('zalo_access_approved', 'true', { path: '/', maxAge: 365 * 24 * 60 * 60 });
}

// --- ADMIN ABSOLUTE BYPASS ---
let isAdmin = false;
const token = Astro.cookies.get('auth_token')?.value;
if (token) {
  try {
    const user = JSON.parse(Buffer.from(token, 'base64').toString('utf-8'));
    if (user && user.role === 'admin') {
      isAdmin = true;
      isReferred = true; // Admin luôn được bypass trang ngụy trang
    }
  } catch(e) {}
}

// Nếu chưa được xác định nguồn giới thiệu và trang hiện tại không được miễn trừ, tiến hành xác thực bảo mật
if (!isReferred && !isExempted) {
  // 1. Xác thực HMAC SHA256 Token bảo mật từ film.nrotxa.online
  const SECURE_KEY = 'TPhimX_Gatekeeper_Secret_Signature_Key_2026';
  const tTimeParam = url.searchParams.get('t_time') || '';
  const tTokenParam = url.searchParams.get('t_token') || '';

  let isTokenValid = false;
  if (tTimeParam && tTokenParam) {
    try {
      const timestamp = parseInt(tTimeParam, 10);
      const now = Math.floor(Date.now() / 1000);
      const timeDiff = Math.abs(now - timestamp);
      
      // Token hợp lệ trong vòng 1 tiếng (3600 giây) kể từ lúc sinh ra
      if (timeDiff <= 3600) {
        const expectedSignature = crypto
          .createHmac('sha256', SECURE_KEY)
          .update(tTimeParam)
          .digest('hex');
        
        if (crypto.timingSafeEqual(Buffer.from(tTokenParam, 'hex'), Buffer.from(expectedSignature, 'hex'))) {
          isTokenValid = true;
        }
      }
    } catch (e) {
      console.error("Lỗi xác thực token bảo mật:", e);
    }
  }

  // 2. Chấp nhận nếu token bảo mật hợp lệ HOẶC đi từ domain chính thức cũ qua Referer
  const isRefererValid = referer.includes('film.nrotxa.online');
  
  if (isTokenValid || isRefererValid) {
    isReferred = true;
    Astro.cookies.set('nrotxa_referred', 'true', { path: '/', maxAge: 365 * 24 * 60 * 60 });
  }
}

// Nếu không đến từ film.nrotxa.online và không phải trang miễn trừ -> kích hoạt trạng thái ngụy trang (Decoy)
const showDecoy = !isReferred && !isExempted;

// Nếu đã được xác định nguồn giới thiệu, nhưng truy cập trang xem phim/trang chủ mà CHƯA ĐƯỢC DUYỆT Zalo -> đá về Landing Page (/)
let forceRedirect = false;
if (!showDecoy && !isExempted && currentPath !== '/') {
  const isApproved = Astro.cookies.get('zalo_access_approved')?.value === 'true';
  if (!isApproved && !isAdmin) {
    forceRedirect = true;
  }
}

const finalTitle = dynamicTitle.includes(siteName) ? dynamicTitle : `${dynamicTitle} | ${siteName}`;
const canonical = `${siteUrl}${slug}`;

// Override metadata for Decoy Tech Blog to ensure Google Search only indexes technology content!
let seoTitle = finalTitle;
let seoDesc = dynamicDescription;
let seoKeywords = dynamicKeywords;
let seoImage = image;

if (showDecoy) {
  seoTitle = `TxaTech Studio - Giải Pháp Công Nghệ Đột Phá Doanh Nghiệp 2026`;
  seoDesc = `TxaTech Studio chuyên cung cấp giải pháp phần mềm, ứng dụng di động hiệu năng cao và các dịch vụ bảo mật mạng doanh nghiệp toàn diện.`;
  seoKeywords = `txatech, lập trình di động, phát triển website, bảo mật hệ thống, phần mềm doanh nghiệp, công nghệ số 2026`;
  seoImage = `https://images.unsplash.com/photo-1517694712202-14dd9538aa97?q=80&w=600`;
}
---

<!doctype html>
<html lang="vi">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    {forceRedirect && <meta http-equiv="refresh" content="0;url=/" />}
    <ClientRouter />

    <title>{seoTitle}</title>
    <meta name="description" content={seoDesc} />
    <meta name="keywords" content={seoKeywords} />
    <meta name="author" content={siteName} />
    <meta name="robots" content="index, follow" />
    <link rel="canonical" href={canonical} />
    <link rel="icon" type="image/ico" href="/favicon.ico" />
    <link rel="icon" type="image/png" href="/favicon.png" />

    <!-- Open Graph -->
    <meta property="og:type" content={type} />
    <meta property="og:site_name" content={showDecoy ? "TxaTech Studio" : siteName} />
    <meta property="og:title" content={seoTitle} />
    <meta property="og:description" content={seoDesc} />
    <meta property="og:image" content={seoImage} />
    <meta property="og:url" content={canonical} />
    <meta property="og:locale" content="vi_VN" />

    <!-- Twitter -->
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content={seoTitle} />
    <meta name="twitter:description" content={seoDesc} />
    <meta name="twitter:image" content={seoImage} />

    <!-- Preconnect -->
    <link rel="preconnect" href="https://phimapi.com" />
    <link rel="dns-prefetch" href="https://phimapi.com" />
    <link rel="preconnect" href="https://phimimg.com" />
    <link rel="dns-prefetch" href="https://phimimg.com" />

    <!-- External Assets -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="dns-prefetch" href="https://fonts.googleapis.com">
    <link rel="dns-prefetch" href="https://fonts.gstatic.com">
    <link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" media="print" onload="this.media='all'" />
    <script is:inline src="https://cdn.jsdelivr.net/npm/hls.js@latest" defer></script>
    
    <!-- TXA Core Libraries (Lightweight) -->
    <script is:inline src="/lib/txa/txaformat.js" defer></script>
    <script is:inline src="/lib/txa/txatooltip.js" defer></script>
    <script is:inline src="/lib/txa/txatoast.js" defer></script>
    <script is:inline src="/lib/txa/txamodal.js" type="module" defer></script>

    <!-- Referrer Decoy Gatekeeper Auto-Clean & LocalStorage Bridge -->
    <script is:inline define:vars={{ isReferred }}>
      (function() {
        try {
          const urlParams = new URLSearchParams(window.location.search);
          const hasParams = urlParams.has('ref') || urlParams.has('from') || urlParams.has('t_time') || urlParams.has('t_token');
          const bypass = urlParams.get('bypass');
          const hasLocalToken = localStorage.getItem('txa_referred_token') === 'true';

          // 1. Nếu Server xác thực thành công nguồn giới thiệu (Token/Referer hợp lệ)
          if (isReferred) {
            // Lưu trạng thái vĩnh viễn vào localStorage để lần sau truy cập trực tiếp không bị chặn
            localStorage.setItem('txa_referred_token', 'true');
            
            if (bypass === 'true') {
              localStorage.setItem('zalo_browser_token', 'txabypass');
              localStorage.setItem('zalo_access_status', 'approved');
              document.cookie = "zalo_access_approved=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
            }
            
            // Dọn dẹp thanh địa chỉ ngay lập tức để giữ URL sạch đẹp
            if (hasParams || bypass === 'true') {
              const cleanUrl = window.location.pathname + window.location.hash;
              window.history.replaceState({}, document.title, cleanUrl);
            }
          } 
          // 2. Nếu truy cập trực tiếp nhưng đã có token trong localStorage từ trước
          else if (hasLocalToken) {
            const hasCookie = document.cookie.split('; ').some(row => row.trim().startsWith('nrotxa_referred='));
            if (!hasCookie) {
              // Tự động khôi phục cookie với cờ hỗ trợ iframe (SameSite=None; Secure)
              document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
              
              // Kiểm tra xem cookie có thực sự set được không (tránh lặp reload vô tận nếu trình duyệt chặn cookie trong iframe)
              const verifyCookie = document.cookie.split('; ').some(row => row.trim().startsWith('nrotxa_referred='));
              if (verifyCookie) {
                window.location.reload();
              } else {
                console.warn("[DPTXA] Cookies are blocked by the browser inside this iframe (Hugging Face). Please access directly.");
                // Nếu đang ở trong iframe của Hugging Face và bị chặn cookie, hiển thị thông báo đẹp mắt hướng dẫn truy cập trực tiếp
                if (window.self !== window.top) {
                  document.addEventListener('DOMContentLoaded', () => {
                    const noticeDiv = document.createElement('div');
                    noticeDiv.style.cssText = "position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 100000; background: rgba(18, 20, 29, 0.95); backdrop-filter: blur(20px); color: white; padding: 32px; border-radius: 24px; font-family: 'Outfit', sans-serif; text-align: center; box-shadow: 0 30px 100px rgba(0,0,0,0.8); border: 1px solid rgba(255,255,255,0.1); max-width: 90%; width: 440px; animation: modal-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;";
                    noticeDiv.innerHTML = `
                      <div style="font-size: 40px; margin-bottom: 20px;">⚠️</div>
                      <div style="font-size: 16px; margin-bottom: 12px; font-weight: 900; text-transform: uppercase; tracking-wider; color: #f43f5e;">Bị chặn Cookie trên Iframe</div>
                      <div style="font-size: 13px; opacity: 0.8; margin-bottom: 24px; font-weight: 500; line-height: 1.6; color: #9ca3af;">Trình duyệt của bạn đang chặn Cookie bên thứ ba trong khung Iframe của Hugging Face. Để mở khóa và xem phim mượt mà, vui lòng truy cập trực tiếp bằng liên kết dưới đây:</div>
                      <a href="https://txavlog-dptxa-proxy.hf.space" target="_blank" style="display: block; background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; padding: 14px 20px; border-radius: 12px; text-decoration: none; font-weight: 900; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; transition: all 0.3s; box-shadow: 0 10px 25px rgba(124,58,237,0.3);">Vào rạp phim trực tiếp ngay</a>
                    `;
                    document.body.appendChild(noticeDiv);
                  });
                }
              }
            }
          }

          // 3. Cơ chế Easter Egg mở khóa bí mật (Click liên tiếp 5 lần vào Logo "TxaTech Studio", từ lần 3 có Toast thông báo)
          let decoyClicks = 0;
          let clickTimer = null;

          document.addEventListener('DOMContentLoaded', () => {
            const logoEl = document.getElementById('decoy-logo');
            if (logoEl) {
              logoEl.addEventListener('click', () => {
                // Đảm bảo click liên tiếp nhanh (quãng nghỉ tối đa 800ms)
                clearTimeout(clickTimer);
                clickTimer = setTimeout(() => {
                  decoyClicks = 0;
                }, 800);

                decoyClicks++;

                // Khi click đến lần thứ 3 và 4, có toast thông báo số lần còn lại
                if (decoyClicks === 3 || decoyClicks === 4) {
                  const remaining = 5 - decoyClicks;
                  if (window.txatoast) {
                    window.txatoast.info(`Bạn đang kích hoạt mã ẩn! Click thêm ${remaining} lần nữa để tiếp tục...`, 2000);
                  }
                } 
                // Khi click đủ 5 lần
                else if (decoyClicks >= 5) {
                  decoyClicks = 0; // Reset
                  
                  if (window.txamodal) {
                    window.txamodal.show({
                      title: "Kích Hoạt DPTXA",
                      message: "Nhập mật mã bí mật để mở khóa rạp phim DPTXA Cinema:",
                      type: "info",
                      input: true,
                      inputType: "password",
                      inputPlaceholder: "Nhập mật mã bí mật tại đây...",
                      confirmText: "Mở khóa",
                      cancelText: "Hủy bỏ",
                      onConfirm: (pass) => {
                        if (pass === 'phimtxadinhvai') {
                          localStorage.setItem('txa_referred_token', 'true');
                          document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
                          
                          if (window.txatoast) {
                            window.txatoast.success("🎉 Mật mã chính xác! Đang kết nối rạp phim...", 2000);
                          }
                          
                          setTimeout(() => {
                            window.location.reload();
                          }, 1200);
                          return true; // Đóng modal
                        } else {
                          if (window.txatoast) {
                            window.txatoast.error("❌ Mật mã không chính xác!", 2000);
                          }
                          return false; // Giữ modal mở
                        }
                      }
                    });
                  } else {
                    // Fallback sang prompt truyền thống nếu thư viện chưa load
                    const pass = prompt("Vui lòng nhập mật mã mở khóa DPTXA Cinema:");
                    if (pass === 'phimtxadinhvai') {
                      localStorage.setItem('txa_referred_token', 'true');
                      document.cookie = "nrotxa_referred=true; path=/; max-age=" + (365 * 24 * 60 * 60) + "; SameSite=None; Secure";
                      alert("🎉 Mật mã chính xác! Đang kết nối rạp phim...");
                      window.location.reload();
                    } else if (pass !== null) {
                      alert("❌ Mật mã không chính xác!");
                    }
                  }
                }
              });
            }
          });
        } catch (e) {
          console.error("Referrer decoy helper error:", e);
        }
      })();
    </script>
  </head>
  <body class="flex min-h-screen flex-col bg-[#0f0f0f] text-white antialiased">
    {forceRedirect ? (
      <div class="fixed inset-0 z-[10000] flex flex-col items-center justify-center bg-[#0f0f0f]">
        <div class="h-10 w-10 border-4 border-primary/20 border-t-primary rounded-full animate-spin mb-4"></div>
        <p class="text-xs font-black uppercase tracking-widest text-gray-400">Đang kết nối rạp phim...</p>
      </div>
    ) : showDecoy ? (
      <!-- ==================== PREMIUM HARMLESS DECOY TECH BLOG ==================== -->
      <header class="fixed top-0 left-0 w-full z-50 bg-[#0f0f0f]/80 backdrop-blur-xl border-b border-white/5 py-4 px-6 md:px-12 flex items-center justify-between">
        <div class="flex items-center gap-3 select-none" id="decoy-logo" style="cursor: pointer;" data-txatooltip="Trang chủ TxaTech Studio">
          <div class="h-10 w-10 rounded-2xl bg-gradient-to-tr from-violet-600 to-blue-600 flex items-center justify-center font-black text-lg text-white shadow-lg shadow-violet-500/20 hover:rotate-12 transition-all duration-300">T</div>
          <span class="text-base font-black tracking-tight text-white uppercase">Txa<span class="text-primary animate-pulse">Tech</span> Studio</span>
        </div>
        <nav class="hidden md:flex items-center gap-8 text-xs font-black uppercase tracking-widest text-gray-400">
          <a href="#services" class="hover:text-white transition-colors" data-txatooltip="Khám phá các dịch vụ phần mềm">Dịch vụ</a>
          <a href="#projects" class="hover:text-white transition-colors" data-txatooltip="Các dự án đã triển khai">Dự án</a>
          <a href="#blog" class="hover:text-white transition-colors" data-txatooltip="Thủ thuật lập trình & bảo mật">Tin tức</a>
          <a href="#contact" class="hover:text-white transition-colors" data-txatooltip="Kết nối với đội ngũ tư vấn">Liên hệ</a>
        </nav>
        <a href="#contact" data-txatooltip="Nhận báo giá miễn phí" class="px-5 py-2.5 bg-white/5 border border-white/10 rounded-xl text-[10px] font-black uppercase tracking-wider hover:bg-white/10 hover:border-white/20 transition-all">Tư vấn ngay</a>
      </header>

      <main class="flex-1 pt-24">
        <!-- Hero Section -->
        <section class="px-6 md:px-12 py-16 md:py-24 text-center max-w-4xl mx-auto relative overflow-hidden">
          <div class="absolute -top-12 left-1/2 -translate-x-1/2 w-72 h-72 bg-violet-500/10 blur-[100px] pointer-events-none"></div>
          <div class="absolute -bottom-12 left-1/3 w-96 h-96 bg-blue-500/10 blur-[120px] pointer-events-none"></div>
          
          <span class="inline-flex items-center gap-2 px-4 py-1.5 rounded-full bg-white/5 border border-white/10 text-[9px] font-black uppercase tracking-widest text-blue-400 mb-6">
            <span class="h-1.5 w-1.5 rounded-full bg-blue-500 animate-ping"></span> KỶ NGUYÊN SỐ HÓA 2026
          </span>
          <h1 class="text-3xl md:text-5xl font-black tracking-tighter text-white mb-6 leading-tight uppercase">
            Giải Pháp <span class="bg-gradient-to-r from-blue-400 via-violet-400 to-indigo-500 bg-clip-text text-transparent">Công Nghệ Đột Phá</span> Cho Doanh Nghiệp
          </h1>
          <p class="text-xs md:text-sm text-gray-400 mb-8 max-w-2xl mx-auto leading-relaxed">
            Chúng tôi thiết kế và phát triển các sản phẩm phần mềm, ứng dụng di động hiệu năng cao và hệ thống dữ liệu chuyên nghiệp. Hiện đã phục vụ hơn <span data-txaformat="number" class="text-blue-400 font-bold px-1">1500</span> khách hàng trên toàn cầu.
          </p>
          <div class="flex flex-wrap items-center justify-center gap-4">
            <a href="#contact" class="px-6 py-3.5 bg-gradient-to-r from-blue-600 to-violet-600 rounded-xl text-[10px] font-black uppercase tracking-widest shadow-lg shadow-blue-500/25 hover:scale-105 active:scale-95 transition-all">Khởi đầu dự án</a>
            <a href="#services" class="px-6 py-3.5 bg-white/5 border border-white/10 hover:bg-white/10 rounded-xl text-[10px] font-black uppercase tracking-widest transition-all">Tìm hiểu dịch vụ</a>
          </div>
        </section>

        <!-- Services Section -->
        <section id="services" class="px-6 md:px-12 py-16 bg-white/[0.01] border-y border-white/5">
          <div class="max-w-6xl mx-auto">
            <div class="text-center mb-12">
              <h2 class="text-xl font-black uppercase tracking-widest text-white">Dịch Vụ Lõi Của Chúng Tôi</h2>
              <p class="text-[10px] text-gray-500 uppercase tracking-wider mt-2">Đồng hành cùng sự phát triển bền vững của doanh nghiệp</p>
            </div>
            <div class="grid grid-cols-1 md:grid-cols-3 gap-6">
              <div class="bg-white/[0.02] border border-white/5 rounded-2xl p-8 hover:border-blue-500/30 transition-all duration-300">
                <div class="h-12 w-12 rounded-xl bg-blue-500/10 flex items-center justify-center text-blue-400 mb-6 text-lg"><i class="fas fa-laptop-code"></i></div>
                <h3 class="text-sm font-black text-white mb-3">Phát triển Phần mềm</h3>
                <p class="text-xs text-gray-400 leading-relaxed">Xây dựng ứng dụng web, hệ thống CRM/ERP tối ưu hiệu suất, bảo mật cao và tương thích đa thiết bị.</p>
              </div>
              <div class="bg-white/[0.02] border border-white/5 rounded-2xl p-8 hover:border-violet-500/30 transition-all duration-300">
                <div class="h-12 w-12 rounded-xl bg-violet-500/10 flex items-center justify-center text-violet-400 mb-6 text-lg"><i class="fas fa-mobile-alt"></i></div>
                <h3 class="text-sm font-black text-white mb-3">Lập trình Mobile App</h3>
                <p class="text-xs text-gray-400 leading-relaxed">Phát triển các ứng dụng iOS/Android mượt mà, tối ưu trải nghiệm người dùng với công nghệ React Native, Flutter.</p>
              </div>
              <div class="bg-white/[0.02] border border-white/5 rounded-2xl p-8 hover:border-indigo-500/30 transition-all duration-300">
                <div class="h-12 w-12 rounded-xl bg-indigo-500/10 flex items-center justify-center text-indigo-400 mb-6 text-lg"><i class="fas fa-shield-alt"></i></div>
                <h3 class="text-sm font-black text-white mb-3">Bảo mật hệ thống</h3>
                <p class="text-xs text-gray-400 leading-relaxed">Kiểm tra lỗ hổng bảo mật, thiết lập tường lửa và hệ thống bảo vệ dữ liệu đám mây toàn diện cho doanh nghiệp.</p>
              </div>
            </div>
          </div>
        </section>

        <!-- Tech Blog Section -->
        <section id="blog" class="px-6 md:px-12 py-16 max-w-6xl mx-auto">
          <div class="flex items-end justify-between mb-12">
            <div>
              <h2 class="text-xl font-black uppercase tracking-widest text-white">Tin Tức & Công Nghệ</h2>
              <p class="text-[10px] text-gray-500 uppercase tracking-wider mt-2">Chia sẻ kiến thức chuyên môn, thủ thuật lập trình & bảo mật hệ thống</p>
            </div>
            <a href="#contact" class="hidden sm:inline-flex items-center gap-2 text-[10px] font-black uppercase tracking-wider text-blue-400 hover:underline">Xem thêm <i class="fas fa-arrow-right text-[8px]"></i></a>
          </div>
          
          <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-6">
            <article class="bg-white/[0.01] border border-white/5 rounded-2xl overflow-hidden hover:-translate-y-1 transition-all duration-300 flex flex-col h-full">
              <div class="h-36 bg-gradient-to-br from-blue-900/60 to-indigo-900/60 flex items-center justify-center text-white text-3xl"><i class="fab fa-android"></i></div>
              <div class="p-5 flex-1 flex flex-col justify-between">
                <div>
                  <span class="text-[8px] font-black uppercase tracking-widest text-blue-400 block mb-2">Thủ thuật Mobile</span>
                  <h4 class="text-xs font-black text-white leading-snug mb-3 hover:text-blue-400 transition-colors">Tối ưu hóa hiệu năng Android cho trải nghiệm chơi game mượt mà</h4>
                </div>
                <span class="text-[9px] text-gray-500 font-bold block mt-4">15 Tháng 5, 2026</span>
              </div>
            </article>
            <article class="bg-white/[0.01] border border-white/5 rounded-2xl overflow-hidden hover:-translate-y-1 transition-all duration-300 flex flex-col h-full">
              <div class="h-36 bg-gradient-to-br from-violet-900/60 to-pink-900/60 flex items-center justify-center text-white text-3xl"><i class="fab fa-react"></i></div>
              <div class="p-5 flex-1 flex flex-col justify-between">
                <div>
                  <span class="text-[8px] font-black uppercase tracking-widest text-violet-400 block mb-2">Lập trình</span>
                  <h4 class="text-xs font-black text-white leading-snug mb-3 hover:text-violet-400 transition-colors">Tại sao Flutter lại trở thành tương lai của lập trình đa nền tảng?</h4>
                </div>
                <span class="text-[9px] text-gray-500 font-bold block mt-4">12 Tháng 5, 2026</span>
              </div>
            </article>
            <article class="bg-white/[0.01] border border-white/5 rounded-2xl overflow-hidden hover:-translate-y-1 transition-all duration-300 flex flex-col h-full">
              <div class="h-36 bg-gradient-to-br from-emerald-900/60 to-teal-900/60 flex items-center justify-center text-white text-3xl"><i class="fas fa-user-shield"></i></div>
              <div class="p-5 flex-1 flex flex-col justify-between">
                <div>
                  <span class="text-[8px] font-black uppercase tracking-widest text-emerald-400 block mb-2">Bảo mật</span>
                  <h4 class="text-xs font-black text-white leading-snug mb-3 hover:text-emerald-400 transition-colors">Bảo mật dữ liệu cá nhân trên môi trường Internet năm 2026</h4>
                </div>
                <span class="text-[9px] text-gray-500 font-bold block mt-4">08 Tháng 5, 2026</span>
              </div>
            </article>
            <article class="bg-white/[0.01] border border-white/5 rounded-2xl overflow-hidden hover:-translate-y-1 transition-all duration-300 flex flex-col h-full">
              <div class="h-36 bg-gradient-to-br from-indigo-900/60 to-slate-900/60 flex items-center justify-center text-white text-3xl"><i class="fas fa-rocket"></i></div>
              <div class="p-5 flex-1 flex flex-col justify-between">
                <div>
                  <span class="text-[8px] font-black uppercase tracking-widest text-indigo-400 block mb-2">Web App</span>
                  <h4 class="text-xs font-black text-white leading-snug mb-3 hover:text-indigo-400 transition-colors">Hướng dẫn build hệ thống Web App hiệu năng cao với Astro JS</h4>
                </div>
                <span class="text-[9px] text-gray-500 font-bold block mt-4">05 Tháng 5, 2026</span>
              </div>
            </article>
          </div>
        </section>

        <!-- Contact Section -->
        <section id="contact" class="px-6 md:px-12 py-16 bg-white/[0.01] border-t border-white/5">
          <div class="max-w-xl mx-auto">
            <div class="text-center mb-8">
              <h2 class="text-xl font-black uppercase tracking-widest text-white">Kết Nối Với Chúng Tôi</h2>
              <p class="text-[10px] text-gray-500 uppercase tracking-wider mt-2">Bắt đầu hóa ý tưởng công nghệ của bạn ngay hôm nay</p>
            </div>
            <div class="space-y-4">
              <div class="grid grid-cols-2 gap-4">
                <input type="text" placeholder="Họ và tên" class="bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-xs text-white focus:outline-none focus:border-blue-500 transition-all font-bold bg-[#1f1f1f]" />
                <input type="email" placeholder="Email" class="bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-xs text-white focus:outline-none focus:border-blue-500 transition-all font-bold bg-[#1f1f1f]" />
              </div>
              <input type="text" placeholder="Số điện thoại" class="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-xs text-white focus:outline-none focus:border-blue-500 transition-all font-bold bg-[#1f1f1f]" />
              <textarea placeholder="Mô tả ý tưởng dự án của bạn..." rows="3" class="w-full bg-white/5 border border-white/10 rounded-xl px-4 py-3 text-xs text-white focus:outline-none focus:border-blue-500 transition-all font-bold bg-[#1f1f1f]"></textarea>
              <button onclick="submitTxaContact()" class="w-full py-4 bg-gradient-to-r from-blue-600 to-violet-600 hover:scale-[1.01] transition-all rounded-xl text-[10px] font-black uppercase tracking-widest text-white shadow-lg shadow-blue-500/20 group">
                <span class="group-hover:tracking-[0.2em] transition-all duration-300">Gửi thông tin tư vấn</span>
              </button>
            </div>
            <script is:inline>
              function submitTxaContact() {
                const modalHtml = `
                  <div class="text-center p-4">
                    <div class="w-16 h-16 bg-blue-500/10 rounded-full flex items-center justify-center text-blue-500 mx-auto mb-4 text-3xl animate-bounce"><i class="fas fa-paper-plane"></i></div>
                    <h3 class="text-lg font-black text-white mb-2">Đang xử lý yêu cầu...</h3>
                    <p class="text-xs text-gray-400">Hệ thống đang tiếp nhận thông tin của bạn</p>
                  </div>
                `;
                window.txamodal.show({ message: modalHtml, showCancel: false, showConfirm: false });
                
                setTimeout(() => {
                  window.txamodal.hide();
                  // Fallback ép buộc đóng nếu SPA transition gây kẹt DOM
                  const container = document.getElementById('txamodal-container');
                  if (container) container.style.display = 'none';
                  
                  window.txatoast.success("Cảm ơn bạn! Đội ngũ TxaTech sẽ liên hệ lại trong vòng 24h.");
                }, 1500);
              }
            </script>
          </div>
        </section>
      </main>

      <footer class="py-12 border-t border-white/5 text-center text-[9px] text-gray-600 uppercase tracking-widest bg-black/20">
        <p>&copy; 2026 TxaTech Studio. Tất cả các quyền được bảo hộ.</p>
      </footer>
    ) : (
      <!-- ==================== ACTUAL FILM WEB FOR VERIFIED USERS ==================== -->
      <>
        <!-- Static Splash (Instant) - Added transition:persist for SPA stability -->
        <div id="txa-splash" transition:persist class="fixed inset-0 z-[10000] flex flex-col items-center justify-center bg-[#0f0f0f] transition-all duration-700 opacity-100" style="width: 100vw; height: 100vh; left: 0; top: 0;">
          <div class="absolute inset-0 bg-gradient-to-b from-black/50 to-transparent pointer-events-none"></div>
          <div class="relative z-10 flex flex-col items-center">
            <div class="relative mb-8 transform hover:scale-105 transition-transform duration-500">
              <div class="text-7xl font-black tracking-tighter text-white drop-shadow-[0_0_30px_rgba(124,58,237,0.3)]">
                D<span class="text-primary animate-pulse">P</span>TXA
              </div>
              <div class="absolute -bottom-3 left-0 h-[3px] w-full bg-gradient-to-r from-transparent via-primary to-transparent shadow-[0_0_15px_var(--primary)]"></div>
            </div>
            <div class="flex gap-2">
              <div class="h-3 w-3 rounded-full bg-primary animate-bounce shadow-[0_0_10px_var(--primary)]"></div>
              <div class="h-3 w-3 rounded-full bg-primary animate-bounce shadow-[0_0_10px_var(--primary)]" style="animation-delay: 0.15s"></div>
              <div class="h-3 w-3 rounded-full bg-primary animate-bounce shadow-[0_0_10px_var(--primary)]" style="animation-delay: 0.3s"></div>
            </div>
            <div class="mt-8 text-[10px] font-bold uppercase tracking-[0.4em] text-white/30 animate-pulse">
              Loading Cinematic Experience
            </div>
          </div>
        </div>

        <Header />
        <main class={`flex-1 ${slug === '/' ? 'pt-0' : 'pt-20 md:pt-24'}`}>
          <slot />
        </main>
        <Footer settings={settings} />
      </>
    )}

    <script is:inline>
      let hideTimeout;
      
      const getSplash = () => document.getElementById('txa-splash');

      const hideSplash = async (force = false) => {
        clearTimeout(hideTimeout);
        const splash = getSplash();
        if (!splash) return;

        if (!force && window.txaSplashBarrier) {
          try {
            // Wait for the custom page barrier with a maximum safety timeout of 2.5s
            const barrierPromise = window.txaSplashBarrier;
            const timeoutPromise = new Promise(r => setTimeout(r, 2500));
            await Promise.race([barrierPromise, timeoutPromise]);
          } catch (e) {
            console.warn('[Splash] Barrier error/timeout:', e);
          }
          window.txaSplashBarrier = null;
        }

        splash.style.transition = 'opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1)';
        splash.classList.add('opacity-0');
        hideTimeout = setTimeout(() => {
          splash.style.display = 'none';
        }, 600);
      };

      const showSplash = () => {
        clearTimeout(hideTimeout);
        const splash = getSplash();
        if (splash) {
          splash.style.transition = 'none';
          splash.style.display = 'flex';
          void splash.offsetWidth;
          splash.classList.remove('opacity-0');
          splash.style.opacity = '1';
          
          // Safety timeout: 6 seconds to prevent stuck loader
          hideTimeout = setTimeout(() => hideSplash(true), 6000);
        }
      };

      // Initial hide - wait for complete paint + extra smooth delay
      if (document.readyState === 'complete') {
        setTimeout(() => hideSplash(false), 800);
      } else {
        window.addEventListener('load', () => {
          setTimeout(() => hideSplash(false), 600);
        });
      }
      
      // Astro transitions
      document.addEventListener('astro:before-preparation', showSplash);
      
      // The most reliable way to hide is on page-load
      document.addEventListener('astro:page-load', () => {
        // Smooth base delay (will wait for page barrier if active)
        setTimeout(() => hideSplash(false), 300);
        if (window.initTxaTooltips) window.initTxaTooltips();

        // --- DYNAMIC ACCESS VERIFICATION GUARD ---
        const currentPath = window.location.pathname;
        const isExempted = currentPath.startsWith('/admin') || 
                           currentPath.startsWith('/api/') ||
                           currentPath === '/dang-nhap' ||
                           currentPath === '/dang-ky';
                           
        if (currentPath !== '/' && !isExempted) {
          // Bỏ qua kiểm duyệt nếu là admin
          const isAdmin = document.cookie.split('; ').some(row => row.trim().startsWith('auth_token='));
          if (!isAdmin) {
            const browserToken = localStorage.getItem('zalo_browser_token');
            if (!browserToken) {
              // Bị thiếu token, đá về trang chủ ngay lập tức để lấy token
              window.location.href = '/';
            } else {
              // Gọi ngầm API kiểm tra thực tế từ Database
              fetch(`/api/access/status?token=${browserToken}`)
                .then(res => {
                  if (!res.ok) throw new Error('API Error');
                  return res.json();
                })
                .then(data => {
                  if (!data || data.status !== 'approved') {
                    if (data && data.status === 'not_found') {
                      // Bị xóa vĩnh viễn bởi Admin
                      localStorage.setItem('kicked_out', 'true');
                      localStorage.removeItem('zalo_browser_token');
                      localStorage.removeItem('zalo_access_status');
                    } else if (data && data.status === 'rejected') {
                      // Bị từ chối bởi Admin
                      localStorage.setItem('kicked_out_rejected', 'true');
                      localStorage.removeItem('zalo_browser_token');
                      localStorage.removeItem('zalo_access_status');
                    } else {
                      localStorage.setItem('zalo_access_status', data?.status || 'pending');
                    }
                    // Trạng thái bị thu hồi hoặc pending, xóa cookie và đá về Landing
                    document.cookie = "zalo_access_approved=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;";
                    window.location.href = '/';
                  }
                })
                .catch(err => {
                  console.error("Lỗi kiểm tra bảo mật ngầm:", err);
                });
            }
          }
        }
      });

      // Safety hide for any interrupted transitions
      document.addEventListener('astro:after-swap', () => {
        setTimeout(hideSplash, 1500);
      });
      
      // Fix for "Back" button hanging - hide if we're already loaded
      window.addEventListener('popstate', () => {
        setTimeout(hideSplash, 500);
      });
    </script>
  </body>
</html>