<!DOCTYPE html>
<html lang="en">
<!--begin::Head-->

<head>
    <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/head2.php';?>
    <title>Kho Mã Nguồn | <?=$lxtdev['ten_web'];?></title>
    <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/nav.php';?>

    <!-- Tích hợp bộ Icon FontAwesome trực quan -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    
    <style>
        /* Hiệu ứng thẻ mã nguồn cao cấp */
        .premium-code-card {
            border: 1px solid rgba(0, 0, 0, 0.04) !important;
            border-radius: 16px !important;
            transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1) !important;
            background: #ffffff;
            overflow: hidden;
        }
        
        [data-bs-theme="dark"] .premium-code-card {
            background: #1e1e2d;
            border: 1px solid rgba(255, 255, 255, 0.05) !important;
        }

        .premium-code-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.08) !important;
            border-color: rgba(48, 133, 214, 0.25) !important;
        }
        
        [data-bs-theme="dark"] .premium-code-card:hover {
            box-shadow: 0 15px 35px rgba(0, 0, 0, 0.35) !important;
        }

        /* Khung chứa ảnh tỉ lệ vàng 16:9 chống vỡ hàng */
        .code-img-wrapper {
            position: relative;
            width: 100%;
            padding-top: 56.25%; /* Tỉ lệ chuẩn */
            overflow: hidden;
            border-radius: 12px;
            background: #f5f8fa;
        }
        [data-bs-theme="dark"] .code-img-wrapper {
            background: #151521;
        }

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

        .premium-code-card:hover .code-img-wrapper img {
            transform: scale(1.06);
        }

        /* Nút bấm hiện đại */
        .btn-premium-action {
            background: linear-gradient(135deg, #2e86de, #3085d6) !important;
            border: none !important;
            color: #fff !important;
            font-weight: 700 !important;
            border-radius: 10px !important;
            padding: 10px 20px !important;
            transition: 0.3s !important;
            box-shadow: 0 4px 12px rgba(48, 133, 214, 0.2) !important;
        }

        .btn-premium-action:hover {
            transform: translateY(-1px) !important;
            box-shadow: 0 6px 16px rgba(48, 133, 214, 0.35) !important;
            color: #fff !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 CHỨA THÔNG TIN -->
                    <div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
                        <div id="kt_app_toolbar_container" class="app-container container-fluid d-flex flex-stack">
                            <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-code text-primary fs-4 mb-1"></i> Kho Mã Nguồn Cao Cấp
                                </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">Sản Phẩm</li>
                                </ul>
                            </div>
                            <div class="d-flex align-items-center gap-2 gap-lg-3">
                                <a href="#" class="btn btn-sm fw-bold btn-light-success px-4 py-3" 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>

                    <!-- DANH SÁCH SẢN PHẨM MÃ NGUỒN -->
                    <div id="kt_app_content" class="app-content flex-column-fluid">
                        <div class="container-xxl" id="kt_content_container">
                            
                            <!-- Cấu trúc lưới (Grid) tối ưu Responsive mượt mà -->
                            <div class="row row-cols-1 row-cols-md-2 row-cols-xl-3 g-6 g-xl-9">
                                <?php
                                    $result = mysqli_query($ketnoi,"SELECT * FROM `khocode` WHERE `status`='ON' ORDER BY `id` DESC ");
                                    while($row = mysqli_fetch_assoc($result)) { ?>
                                    
                                    <div class="col">
                                        <div class="card premium-code-card h-100 d-flex flex-column justify-content-between p-5">
                                            <div>
                                                <!-- Khung hiển thị ảnh cố định -->
                                                <div class="code-img-wrapper mb-4">
                                                    <img src="<?=$row['img'];?>" alt="<?=$row['title'];?>" loading="lazy" />
                                                </div>

                                                <!-- Nhãn chỉ số tương tác (Lượt xem / Lượt mua) -->
                                                <div class="d-flex gap-2 mb-3">
                                                    <span class="badge badge-light-body text-gray-600 fw-bold fs-8 px-2 py-1">
                                                        <i class="fa-regular fa-eye text-muted me-1"></i> <?=$row['view'];?>
                                                    </span>
                                                    <span class="badge badge-light-body text-gray-600 fw-bold fs-8 px-2 py-1">
                                                        <i class="fa-solid fa-basket-shopping text-muted me-1"></i> <?=$row['buy'];?> mua
                                                    </span>
                                                </div>

                                                <!-- Tên Sản Phẩm Giới Hạn 2 Dòng Tránh Lệch Khung -->
                                                <h3 class="text-dark fs-5 fw-bold text-hover-primary mb-3" style="min-height: 44px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4;">
                                                    <?=$row['title'];?>
                                                </h3>
                                            </div>

                                            <!-- Chân thẻ: Giá tiền và Nút xem -->
                                            <div class="d-flex align-items-center justify-content-between mt-4 pt-4 border-top border-gray-200 border-opacity-50">
                                                <div class="d-flex flex-column">
                                                    <span class="text-muted fs-8 fw-bold text-uppercase">Giá sở hữu</span>
                                                    <span class="fs-4 fw-black text-primary">
                                                        <?=tien($row['gia']);?><span class="fs-7 fw-bold ms-0.5">đ</span>
                                                    </span>
                                                </div>
                                                
                                                <a href="/ma-nguon/<?=$row['id'];?>" class="btn btn-sm btn-premium-action d-flex align-items-center gap-1">
                                                    <i class="fa-regular fa-folder-open fs-7"></i> Xem Ngay
                                                </a>
                                            </div>
                                        </div>
                                    </div>
                                    
                                <?php } ?>
                            </div>

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

</body>
</html>
