<!DOCTYPE html>
<html lang="en">
<head>
    
<meta name="viewport" content="width=device-width, initial-scale=1.0">

    <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/head2.php';?>
    <title>Trang Chủ | <?=$lxtdev['ten_web'];?></title>
    <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/nav.php';?>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <style>
        /* ===== ANIMATED BACKGROUND ===== */
        .hero-bg {
            position: relative;
            overflow: hidden;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 200px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 16px;
            margin-bottom: 1.25rem;
            padding: 1.5rem 1rem;
        }

        .hero-bg::before {
            content: '';
            position: absolute;
            width: 200%;
            height: 200%;
            top: -50%;
            left: -50%;
            background: radial-gradient(circle, rgba(255,255,255,0.08) 1px, transparent 1px);
            background-size: 50px 50px;
            animation: bgMove 20s linear infinite;
        }

        @keyframes bgMove {
            0% { transform: translate(0, 0); }
            100% { transform: translate(50px, 50px); }
        }

        .hero-content {
            position: relative;
            z-index: 2;
            text-align: center;
            width: 100%;
        }

        .hero-title {
            font-size: 1.5rem;
            font-weight: 800;
            color: #fff;
            text-shadow: 0 2px 20px rgba(0,0,0,0.2);
            margin-bottom: 0.4rem;
            line-height: 1.3;
            animation: fadeInUp 0.8s ease;
        }

        .hero-subtitle {
            color: rgba(255,255,255,0.9);
            font-size: 0.85rem;
            line-height: 1.5;
            animation: fadeInUp 0.8s ease 0.2s both;
        }

        @keyframes fadeInUp {
            from { opacity: 0; transform: translateY(20px); }
            to { opacity: 1; transform: translateY(0); }
        }

        /* ===== FLOATING PARTICLES ===== */
        .particle {
            position: absolute;
            border-radius: 50%;
            background: rgba(255,255,255,0.12);
            animation: float 6s ease-in-out infinite;
            /* Ẩn particle trên mobile nhỏ để tối ưu performance */
            display: none;
        }

        @keyframes float {
            0%, 100% { transform: translateY(0) scale(1); opacity: 0.4; }
            50% { transform: translateY(-15px) scale(1.15); opacity: 0.7; }
        }

        /* ===== PREMIUM PRODUCT CARD ===== */
        .premium-product-card {
            border: 1px solid rgba(0, 0, 0, 0.04) !important;
            border-radius: 16px !important;
            transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease !important;
            overflow: hidden;
            background: #ffffff;
            position: relative;
            padding: 0.875rem !important;
        }

        [data-bs-theme="dark"] .premium-product-card {
            background: #1e1e2d;
            border: 1px solid rgba(255, 255, 255, 0.05) !important;
        }

        .premium-product-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: -100%;
            width: 100%;
            height: 100%;
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
            transition: left 0.5s;
            z-index: 3;
            pointer-events: none;
        }

        .premium-product-card:hover::before {
            left: 100%;
        }

        /* ===== PRODUCT IMAGE WRAPPER ===== */
        .product-img-wrapper {
            position: relative;
            width: 100%;
            padding-top: 56.25%;
            overflow: hidden;
            border-radius: 12px;
            background: linear-gradient(135deg, #f5f8fa 0%, #e8ecf1 100%);
        }

        [data-bs-theme="dark"] .product-img-wrapper {
            background: linear-gradient(135deg, #151521 0%, #1e1e2d 100%);
        }

        .product-img-wrapper img {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            object-fit: cover;
            transition: transform 0.5s ease;
        }

        /* Image overlay */
        .img-overlay {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: linear-gradient(to top, rgba(0,0,0,0.5) 0%, transparent 60%);
            opacity: 0;
            transition: opacity 0.3s ease;
            display: flex;
            align-items: flex-end;
            justify-content: center;
            padding-bottom: 0.75rem;
            z-index: 2;
        }

        .img-overlay-text {
            color: #fff;
            font-weight: 600;
            font-size: 0.8rem;
            transform: translateY(8px);
            transition: transform 0.3s ease;
        }

        /* ===== BADGE / TAG ===== */
        .product-badge {
            position: absolute;
            top: 8px;
            right: 8px;
            background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
            color: #fff;
            padding: 3px 10px;
            border-radius: 16px;
            font-size: 0.65rem;
            font-weight: 700;
            z-index: 2;
            box-shadow: 0 3px 10px rgba(255, 107, 107, 0.3);
            letter-spacing: 0.3px;
        }

        /* ===== PREMIUM BUTTON ===== */
        .btn-premium-view {
            background: linear-gradient(135deg, #2e86de, #3085d6) !important;
            border: none !important;
            color: #fff !important;
            font-weight: 700 !important;
            border-radius: 10px !important;
            padding: 8px 16px !important;
            font-size: 0.8rem !important;
            transition: all 0.3s ease !important;
            box-shadow: 0 3px 12px rgba(48, 133, 214, 0.25) !important;
            position: relative;
            overflow: hidden;
            white-space: nowrap;
            /* Đảm bảo tap target >= 44px trên mobile */
            min-height: 44px;
            display: inline-flex !important;
            align-items: center !important;
            justify-content: center !important;
        }

        .btn-premium-view::after {
            content: '';
            position: absolute;
            top: 50%;
            left: 50%;
            width: 0;
            height: 0;
            background: rgba(255,255,255,0.2);
            border-radius: 50%;
            transform: translate(-50%, -50%);
            transition: width 0.4s, height 0.4s;
        }

        .btn-premium-view:hover::after {
            width: 200px;
            height: 200px;
        }

        /* ===== PRICE TAG ===== */
        .price-tag .currency {
            font-size: 0.7rem;
            vertical-align: super;
            margin-left: 1px;
        }

        /* ===== LINE CLAMP ===== */
        .line-clamp-2 {
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
            font-size: 0.9rem;
            line-height: 1.4;
            min-height: 2.8em;
        }

        /* ===== CARD FOOTER (Giá + Nút) ===== */
        .card-footer-actions {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            margin-top: 0.75rem;
            padding-top: 0.75rem;
            border-top: 1px solid rgba(0,0,0,0.06);
        }

        [data-bs-theme="dark"] .card-footer-actions {
            border-top-color: rgba(255,255,255,0.06);
        }

        .price-section {
            display: flex;
            flex-direction: column;
            flex-shrink: 0;
        }

        .price-label {
            font-size: 0.65rem;
            font-weight: 700;
            text-transform: uppercase;
            color: #999;
            letter-spacing: 0.5px;
            margin-bottom: 2px;
        }

        .price-value {
            font-size: 1.1rem;
            font-weight: 800;
            color: #3085d6;
            white-space: nowrap;
        }

        /* ===== STAGGERED ANIMATION ===== */
        .stagger-in {
            opacity: 0;
            transform: translateY(30px);
            animation: staggerFadeIn 0.5s ease forwards;
        }

        @keyframes staggerFadeIn {
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }

        /* ===== WALLET BUTTON ===== */
        .wallet-btn {
            background: linear-gradient(135deg, #00b894, #00a885) !important;
            border: none !important;
            color: #fff !important;
            font-weight: 700 !important;
            border-radius: 10px !important;
            padding: 8px 14px !important;
            font-size: 0.8rem !important;
            transition: all 0.3s ease !important;
            box-shadow: 0 3px 12px rgba(0, 184, 148, 0.25) !important;
            min-height: 44px;
            display: inline-flex !important;
            align-items: center !important;
            white-space: nowrap;
        }

        /* ===== BREADCRUMB ===== */
        .breadcrumb-item a {
            transition: color 0.3s ease;
        }

        .breadcrumb-item a:hover {
            color: #3085d6 !important;
        }

        /* ===== SECTION DIVIDER ===== */
        .section-divider {
            height: 1px;
            background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
            margin: 1.5rem 0;
        }

        [data-bs-theme="dark"] .section-divider {
            background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
        }

        /* ===== EMPTY STATE ===== */
        .empty-state-icon {
            font-size: 3rem;
            opacity: 0.4;
            color: #999;
        }

        /* ===== SCROLLBAR ===== */
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb {
            background: linear-gradient(135deg, #667eea, #764ba2);
            border-radius: 3px;
        }

        /* ===================================================
           RESPONSIVE BREAKPOINTS
           =================================================== */

        /* --- Mobile nhỏ: < 400px --- */
        @media (max-width: 399.98px) {
            .hero-bg {
                min-height: 160px;
                border-radius: 12px;
                padding: 1.25rem 0.75rem;
                margin-bottom: 1rem;
            }

            .hero-title {
                font-size: 1.2rem !important;
            }

            .hero-subtitle {
                font-size: 0.78rem !important;
            }

            .premium-product-card {
                border-radius: 12px !important;
                padding: 0.75rem !important;
            }

            .product-img-wrapper {
                border-radius: 10px;
            }

            .line-clamp-2 {
                font-size: 0.85rem;
                min-height: 2.4em;
            }

            /* Xếp dọc giá và nút khi quá hẹp */
            .card-footer-actions {
                flex-direction: column;
                align-items: stretch;
                gap: 0.6rem;
            }

            .price-section {
                align-items: flex-start;
            }

            .btn-premium-view {
                width: 100%;
                justify-content: center !important;
            }

            .price-value {
                font-size: 1rem;
            }

            .product-badge {
                top: 6px;
                right: 6px;
                padding: 2px 8px;
                font-size: 0.6rem;
            }

            .page-heading {
                font-size: 1.1rem !important;
            }

            .page-heading i {
                display: none;
            }

            .breadcrumb {
                display: none !important;
            }

            .section-divider {
                margin: 1rem 0;
            }
        }

        /* --- Mobile chuẩn: 400px - 575px --- */
        @media (min-width: 400px) and (max-width: 575.98px) {
            .hero-bg {
                min-height: 180px;
                border-radius: 14px;
                padding: 1.5rem 1rem;
                margin-bottom: 1.25rem;
            }

            .hero-title {
                font-size: 1.4rem !important;
            }

            .hero-subtitle {
                font-size: 0.82rem !important;
            }

            .premium-product-card {
                border-radius: 14px !important;
                padding: 0.875rem !important;
            }

            .product-img-wrapper {
                border-radius: 10px;
            }

            .line-clamp-2 {
                font-size: 0.88rem;
            }

            .price-value {
                font-size: 1.05rem;
            }

            .btn-premium-view {
                padding: 8px 14px !important;
                font-size: 0.78rem !important;
            }

            .page-heading {
                font-size: 1.2rem !important;
            }

            .breadcrumb {
                font-size: 0.7rem !important;
            }

            .section-divider {
                margin: 1.25rem 0;
            }
        }

        /* --- Tablet nhỏ: 576px - 767px --- */
        @media (min-width: 576px) and (max-width: 767.98px) {
            .hero-bg {
                min-height: 220px;
                border-radius: 16px;
                margin-bottom: 1.5rem;
            }

            .hero-title {
                font-size: 1.8rem !important;
            }

            .hero-subtitle {
                font-size: 0.95rem !important;
            }

            .premium-product-card {
                padding: 1rem !important;
            }

            .line-clamp-2 {
                font-size: 0.92rem;
            }

            .price-value {
                font-size: 1.15rem;
            }

            .btn-premium-view {
                padding: 8px 18px !important;
                font-size: 0.82rem !important;
            }
        }

        /* --- Tablet lớn: 768px - 991px --- */
        @media (min-width: 768px) and (max-width: 991.98px) {
            .hero-bg {
                min-height: 250px;
                border-radius: 18px;
                margin-bottom: 1.75rem;
            }

            .hero-title {
                font-size: 2.2rem !important;
            }

            .hero-subtitle {
                font-size: 1rem !important;
            }

            .premium-product-card {
                padding: 1.25rem !important;
                border-radius: 18px !important;
            }

            .product-img-wrapper {
                border-radius: 14px;
            }

            .line-clamp-2 {
                font-size: 0.95rem;
            }

            .price-value {
                font-size: 1.2rem;
            }

            .btn-premium-view {
                padding: 10px 20px !important;
                font-size: 0.85rem !important;
            }
        }

        /* --- Desktop: 992px - 1199px --- */
        @media (min-width: 992px) and (max-width: 1199.98px) {
            .hero-bg {
                min-height: 270px;
                border-radius: 20px;
                margin-bottom: 2rem;
            }

            .hero-title {
                font-size: 2.5rem !important;
            }

            .hero-subtitle {
                font-size: 1.05rem !important;
            }

            .premium-product-card {
                padding: 1.375rem !important;
                border-radius: 20px !important;
            }

            .product-img-wrapper {
                border-radius: 14px;
            }

            /* Bật hiệu ứng hover trên desktop */
            .premium-product-card:hover {
                transform: translateY(-10px) scale(1.02);
                box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
                border-color: rgba(48, 133, 214, 0.3) !important;
            }

            [data-bs-theme="dark"] .premium-product-card:hover {
                box-shadow: 0 20px 40px rgba(0, 0, 0, 0.35) !important;
            }

            .premium-product-card:hover .product-img-wrapper img {
                transform: scale(1.08);
            }

            .premium-product-card:hover .img-overlay {
                opacity: 1;
            }

            .premium-product-card:hover .img-overlay-text {
                transform: translateY(0);
            }

            .btn-premium-view:hover {
                transform: translateY(-2px) scale(1.03) !important;
                box-shadow: 0 6px 20px rgba(48, 133, 214, 0.4) !important;
            }

            .btn-premium-view:active {
                transform: translateY(0) scale(0.98) !important;
            }

            .wallet-btn:hover {
                transform: translateY(-2px) !important;
                box-shadow: 0 5px 18px rgba(0, 184, 148, 0.35) !important;
            }

            .price-value {
                font-size: 1.3rem;
            }

            .btn-premium-view {
                padding: 10px 22px !important;
                font-size: 0.85rem !important;
            }
        }

        /* --- Desktop lớn: 1200px - 1399px --- */
        @media (min-width: 1200px) and (max-width: 1399.98px) {
            .hero-bg {
                min-height: 290px;
                border-radius: 20px;
                margin-bottom: 2rem;
            }

            .hero-title {
                font-size: 2.8rem !important;
            }

            .hero-subtitle {
                font-size: 1.1rem !important;
            }

            .premium-product-card {
                padding: 1.5rem !important;
            }

            .product-img-wrapper {
                border-radius: 16px;
            }

            .premium-product-card:hover {
                transform: translateY(-12px) scale(1.02);
                box-shadow: 0 25px 50px rgba(0, 0, 0, 0.12) !important;
                border-color: rgba(48, 133, 214, 0.3) !important;
            }

            [data-bs-theme="dark"] .premium-product-card:hover {
                box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4) !important;
            }

            .premium-product-card:hover .product-img-wrapper img {
                transform: scale(1.1);
            }

            .premium-product-card:hover .img-overlay {
                opacity: 1;
            }

            .premium-product-card:hover .img-overlay-text {
                transform: translateY(0);
            }

            .btn-premium-view:hover {
                transform: translateY(-2px) scale(1.05) !important;
                box-shadow: 0 8px 25px rgba(48, 133, 214, 0.45) !important;
            }

            .btn-premium-view:active {
                transform: translateY(0) scale(0.98) !important;
            }

            .wallet-btn:hover {
                transform: translateY(-2px) !important;
                box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4) !important;
            }

            .price-value {
                font-size: 1.4rem;
            }

            .btn-premium-view {
                padding: 10px 24px !important;
            }
        }

        /* --- Extra large: >= 1400px --- */
        @media (min-width: 1400px) {
            .hero-bg {
                min-height: 320px;
                border-radius: 20px;
                margin-bottom: 2.5rem;
            }

            .hero-title {
                font-size: 3rem !important;
            }

            .hero-subtitle {
                font-size: 1.15rem !important;
            }

            .premium-product-card {
                padding: 1.5rem !important;
                border-radius: 20px !important;
            }

            .product-img-wrapper {
                border-radius: 16px;
            }

            .premium-product-card:hover {
                transform: translateY(-12px) scale(1.02);
                box-shadow: 0 25px 50px rgba(0, 0, 0, 0.12) !important;
                border-color: rgba(48, 133, 214, 0.3) !important;
            }

            [data-bs-theme="dark"] .premium-product-card:hover {
                box-shadow: 0 25px 50px rgba(0, 0, 0, 0.4) !important;
            }

            .premium-product-card:hover .product-img-wrapper img {
                transform: scale(1.1);
            }

            .premium-product-card:hover .img-overlay {
                opacity: 1;
            }

            .premium-product-card:hover .img-overlay-text {
                transform: translateY(0);
            }

            .btn-premium-view:hover {
                transform: translateY(-2px) scale(1.05) !important;
                box-shadow: 0 8px 25px rgba(48, 133, 214, 0.45) !important;
            }

            .btn-premium-view:active {
                transform: translateY(0) scale(0.98) !important;
            }

            .wallet-btn:hover {
                transform: translateY(-2px) !important;
                box-shadow: 0 6px 20px rgba(0, 184, 148, 0.4) !important;
            }

            .price-value {
                font-size: 1.5rem;
            }
        }

        /* ===== TOUCH DEVICE — Chỉ bật khi không có hover (mobile thực sự) ===== */
        @media (hover: none) and (pointer: coarse) {
            .particle {
                display: none !important;
            }

            .hero-bg::before {
                animation: none !important;
            }

            .premium-product-card::before {
                display: none;
            }

            .premium-product-card:active {
                transform: scale(0.98);
                box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
            }

            [data-bs-theme="dark"] .premium-product-card:active {
                box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
            }

            .img-overlay {
                opacity: 1;
                background: linear-gradient(to top, rgba(0,0,0,0.35) 0%, transparent 60%);
            }

            .img-overlay-text {
                transform: translateY(0);
            }

            .btn-premium-view:active {
                transform: scale(0.96) !important;
            }

            .wallet-btn:active {
                transform: scale(0.96) !important;
            }
        }

        /* ===== REDUCED MOTION ===== */
        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }

            .stagger-in {
                opacity: 1;
                transform: none;
            }
        }

        /* ===== GRID GUTTER TỐI ƯU ===== */
        .product-grid {
            --grid-gap: 0.75rem;
            display: grid;
            grid-template-columns: 1fr;
            gap: var(--grid-gap);
        }

        @media (min-width: 400px) {
            .product-grid { --grid-gap: 0.875rem; }
        }

        @media (min-width: 576px) {
            .product-grid {
                grid-template-columns: repeat(2, 1fr);
                --grid-gap: 1rem;
            }
        }

        @media (min-width: 768px) {
            .product-grid { --grid-gap: 1.125rem; }
        }

        @media (min-width: 992px) {
            .product-grid {
                grid-template-columns: repeat(3, 1fr);
                --grid-gap: 1.25rem;
            }
        }

        @media (min-width: 1200px) {
            .product-grid {
                grid-template-columns: repeat(3, 1fr);
                --grid-gap: 1.5rem;
            }
        }

        @media (min-width: 1400px) {
            .product-grid {
                grid-template-columns: repeat(4, 1fr);
                --grid-gap: 1.5rem;
            }
        }

        /* ===== TOOLBAR RESPONSIVE ===== */
        .toolbar-inner {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 0.75rem;
            flex-wrap: wrap;
        }

        @media (max-width: 575.98px) {
            .toolbar-inner {
                gap: 0.5rem;
            }

            #kt_app_toolbar {
                padding-top: 0.75rem !important;
                padding-bottom: 0.75rem !important;
            }

            #kt_app_toolbar_container {
                padding-left: 1rem !important;
                padding-right: 1rem !important;
            }
        }
    </style>
</head>

<body id="kt_app_body" data-kt-app-layout="light-sidebar" data-kt-app-header-fixed="true"
    data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-hoverable="true"
    data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true"
    data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true" class="app-default">

    <script>var defaultThemeMode = "light"; var themeMode; if (document.documentElement) { if (document.documentElement.hasAttribute("data-bs-theme-mode")) { themeMode = document.documentElement.getAttribute("data-bs-theme-mode"); } else { if (localStorage.getItem("data-bs-theme") !== null) { themeMode = localStorage.getItem("data-bs-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-bs-theme", themeMode); }</script>

    <div class="d-flex flex-column flex-root app-root" id="kt_app_root">
        <div class="app-page flex-column flex-column-fluid" id="kt_app_page">

            <div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
                <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/sider.php';?>
            </div>

            <div class="app-main flex-column flex-row-fluid" id="kt_app_main">
                <div class="d-flex flex-column flex-column-fluid">

                    <!-- TOOLBAR -->
                    <div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
                        <div id="kt_app_toolbar_container" class="app-container container-fluid">
                            <div class="toolbar-inner">
                                <div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
                                    <h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">
                                        <i class="fa-solid fa-shapes text-primary fs-4 mb-1"></i> Kho Giao Diện Website
                                    </h1>
                                    <ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
                                        <li class="breadcrumb-item text-muted"><a href="/" class="text-muted text-hover-primary">Home</a></li>
                                        <li class="breadcrumb-item"><span class="bullet bg-gray-400 w-5px h-2px"></span></li>
                                        <li class="breadcrumb-item text-muted">Bảng Tính</li>
                                    </ul>
                                </div>
                                <div class="d-flex align-items-center gap-2">
                                    <a href="#" class="wallet-btn" data-bs-toggle="modal" data-bs-target="#kt_modal_create_app">
                                        <i class="fa-solid fa-wallet me-1"></i> <?=tien($user['money']);?>đ
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>

                    <!-- HERO SECTION -->
                    <div id="kt_app_content" class="app-content flex-column-fluid">
                        <div class="container-xxl px-3 px-sm-4 px-lg-5" id="kt_content_container">

                            <div class="hero-bg">
                                <!-- Particles chỉ hiện trên màn hình >= 768px -->
                                <div class="particle d-none d-md-block" style="width: 60px; height: 60px; top: 20%; left: 10%; animation-delay: 0s;"></div>
                                <div class="particle d-none d-md-block" style="width: 40px; height: 40px; top: 60%; left: 80%; animation-delay: 1s;"></div>
                                <div class="particle d-none d-md-block" style="width: 80px; height: 80px; top: 40%; left: 60%; animation-delay: 2s;"></div>
                                <div class="particle d-none d-md-block" style="width: 30px; height: 30px; top: 80%; left: 30%; animation-delay: 3s;"></div>
                                <div class="particle d-none d-md-block" style="width: 50px; height: 50px; top: 10%; left: 70%; animation-delay: 1.5s;"></div>

                                <div class="hero-content">
                                    <h2 class="hero-title">Khám Phá Kho Giao Diện</h2>
                                    <p class="hero-subtitle">Hàng trăm mẫu website đẹp mắt, hiện đại và chuyên nghiệp</p>
                                </div>
                            </div>

                            <!-- DANH SÁCH MẪU WEB — Dùng CSS Grid thay Bootstrap Row -->
                            <div class="product-grid" id="product-grid">
                                <?php
                                    $delay = 0;
                                    $result = mysqli_query($ketnoi,"SELECT * FROM `list_mau_web` WHERE `status`='ON' ORDER BY `id` DESC ");
                                    while($row = mysqli_fetch_assoc($result)) { 
                                    $delay += 0.08;
                                    if ($delay > 0.72) $delay = 0.08;
                                ?>

                                    <div class="stagger-in" style="animation-delay: <?=$delay;?>s;">
                                        <div class="premium-product-card h-100 d-flex flex-column justify-content-between">
                                            <div>
                                                <!-- Khung Ảnh -->
                                                <div class="product-img-wrapper mb-3">
                                                    <img src="<?=$row['img'];?>" alt="<?=htmlspecialchars($row['title']);?>" loading="lazy" />
                                                    <div class="img-overlay">
                                                        <span class="img-overlay-text">
                                                            <i class="fa-solid fa-eye me-1"></i> Xem trước
                                                        </span>
                                                    </div>
                                                    <span class="product-badge">HOT</span>
                                                </div>

                                                <!-- Tiêu đề -->
                                                <h3 class="text-dark fs-5 fw-bold text-hover-primary mb-0 line-clamp-2">
                                                    <?=$row['title'];?>
                                                </h3>
                                            </div>

                                            <!-- Giá & Nút -->
                                            <div class="card-footer-actions">
                                                <div class="price-section">
                                                    <span class="price-label">Chi phí tạo</span>
                                                    <span class="price-value price-tag">
                                                        <?=tien($row['gia']);?><span class="currency">đ</span>
                                                    </span>
                                                </div>

                                                <a href="/tao-web/<?=$row['id'];?>" class="btn btn-sm btn-premium-view">
                                                    <i class="fa-solid fa-fire" style="font-size: 0.75rem;"></i>
                                                    <span class="ms-1">Khám Phá</span>
                                                </a>
                                            </div>
                                        </div>
                                    </div>

                                <?php } ?>
                            </div>

                            <div class="section-divider"></div>

                            <!-- Empty state -->
                            <?php 
                            $count_result = mysqli_query($ketnoi, "SELECT COUNT(*) as total FROM `list_mau_web` WHERE `status`='ON'");
                            $count_row = mysqli_fetch_assoc($count_result);
                            if ($count_row['total'] == 0) { 
                            ?>
                            <div class="text-center py-5">
                                <div class="mb-3">
                                    <i class="fa-solid fa-box-open empty-state-icon"></i>
                                </div>
                                <h3 class="text-muted fw-bold mb-2" style="font-size: 1.1rem;">Chưa có mẫu website nào</h3>
                                <p class="text-muted" style="font-size: 0.9rem;">Vui lòng quay lại sau để khám phá các mẫu mới nhất!</p>
                            </div>
                            <?php } ?>

                        </div>
                    </div>

                </div>
                <!--begin::Footer-->
                <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/foot.php';?>
                <!--end::Footer-->
            </div>
        </div>
    </div>

    <script>
    document.addEventListener('DOMContentLoaded', function() {
        /* === Intersection Observer: chỉ chạy animation khi card visible === */
        if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
            const observerOptions = {
                root: null,
                rootMargin: '50px 0px', // Trigger sớm hơn một chút
                threshold: 0.05
            };

            const observer = new IntersectionObserver((entries) => {
                entries.forEach(entry => {
                    if (entry.isIntersecting) {
                        entry.target.style.animationPlayState = 'running';
                        observer.unobserve(entry.target);
                    }
                });
            }, observerOptions);

            document.querySelectorAll('.stagger-in').forEach(el => {
                el.style.animationPlayState = 'paused';
                observer.observe(el);
            });
        } else {
            // Reduced motion: hiện luôn không animation
            document.querySelectorAll('.stagger-in').forEach(el => {
                el.style.opacity = '1';
                el.style.transform = 'none';
            });
        }

        /* === Ripple effect cho nút (chỉ trên thiết bị có pointer) === */
        if (window.matchMedia('(hover: hover)').matches) {
            document.querySelectorAll('.btn-premium-view').forEach(btn => {
                btn.addEventListener('click', function(e) {
                    const ripple = document.createElement('span');
                    const rect = this.getBoundingClientRect();
                    const size = Math.max(rect.width, rect.height);
                    const x = e.clientX - rect.left - size / 2;
                    const y = e.clientY - rect.top - size / 2;

                    ripple.style.cssText = `
                        position: absolute;
                        width: ${size}px;
                        height: ${size}px;
                        left: ${x}px;
                        top: ${y}px;
                        background: rgba(255,255,255,0.35);
                        border-radius: 50%;
                        transform: scale(0);
                        animation: rippleEffect 0.5s ease-out;
                        pointer-events: none;
                    `;

                    this.appendChild(ripple);
                    setTimeout(() => ripple.remove(), 500);
                });
            });
        }
    });

    /* Ripple keyframes */
    const rippleStyle = document.createElement('style');
    rippleStyle.textContent = `
        @keyframes rippleEffect {
            to { transform: scale(2.5); opacity: 0; }
        }
    `;
    document.head.appendChild(rippleStyle);
    </script>

</body>
</html>

<style>
.product-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:20px}
.hero-bg{min-height:clamp(180px,30vw,320px);padding:clamp(20px,4vw,50px)}
.hero-title{font-size:clamp(1.4rem,4vw,3rem)!important}
.hero-subtitle{font-size:clamp(.85rem,2vw,1.15rem)!important}
.product-img-wrapper{aspect-ratio:16/9;padding-top:0}
@media(max-width:768px){
.toolbar-inner{flex-direction:column;align-items:stretch}
.page-title{text-align:center}
.btn-premium-view,.wallet-btn{width:100%;justify-content:center}
.card-footer-actions{flex-direction:column;align-items:stretch}
.price-section{text-align:center}
}
</style>
