<?php
/*
 * @ https://hospedagem.matrixch.store 
 * @ PHP 7.4
 * @ Decoder version: 1.0.2
 * @ Release: 17/06/2024
*/

ini_set("display_errors", 1);
error_reporting(32767);
include "includes/header.php";
$dbPath = "./api/.db.db";
$db = new SQLiteWrapper($dbPath);
if (isset($_POST["theme_id"])) {
    $themeData = ["theme_id" => $_POST["theme_id"]];
    $db->update("themes", $themeData, "id = :id", [":id" => 1]);
    echo "<script>window.location.href='" . basename($_SERVER["SCRIPT_NAME"]) . "?status=1'</script>";
}
$result = $db->select("themes", "theme_id", "id = 1", "");
$currentThemeId = !empty($result) ? $result[0]["theme_id"] : "1";
$currentThemeId = $db->select("themes", "theme_id", "id = 1", "")[0]["theme_id"];
echo "<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css\">\n<div class=\"col-md-10 mx-auto\">\n    <div class=\"card-body\">\n        <div class=\"card bg-primary text-white\">\n            <div class=\"card-header card-header-warning\">\n                <center><h2><i class=\"icon icon-bullhorn\"></i> Theme Settings</h2></center>\n            </div>\n            <div class=\"card-body\">\n                <!-- Theme Selection Form -->\n                <form method=\"post\">\n                    <div class=\"form-group\">\n                        <label for=\"theme-selector\">Select Theme:</label>\n                        <select class=\"form-control\" id=\"theme-selector\" name=\"theme_id\">\n                            ";
for ($i = 1; $i <= 5; $i++) {
    echo "                                <option value=\"";
    echo $i;
    echo "\" ";
    echo $currentThemeId == $i ? "selected" : "";
    echo ">\n                                    Theme ";
    echo $i;
    echo "                                </option>\n                            ";
}
echo "                        </select>\n                    </div>\n\n                    <button class=\"btn btn-info\" type=\"submit\">\n                        <i class=\"icon icon-check\"></i> Update Theme\n                    </button>\n                </form>\n\n                <!-- Theme Thumbnails -->\n             <div class=\"theme-thumbnails\">\n    ";
$themeNumbers = [1, 4, 2, 5, 3];
foreach ($themeNumbers as $num) {
    echo "        <div class=\"";
    echo $currentThemeId == $num ? "selected-theme" : "";
    echo "\">\n            <div class=\"theme-title\">Theme ";
    echo $num;
    echo "</div>\n            <img src=\"img/theme_";
    echo $num;
    echo ".png\" alt=\"Theme ";
    echo $num;
    echo "\">\n            <img src=\"img/selected.png\" alt=\"Selected\" class=\"selected-indicator\">\n        </div>\n    ";
}
echo "</div>\n            </div>\n        </div>\n    </div>\n</div>\n\n";
include "includes/footer.php";
echo "\n<style>\n.theme-thumbnails {\n    display: grid;\n    grid-template-columns: repeat(2, 1fr); /* Two columns */\n    gap: 20px;\n    justify-content: center;\n    margin-top: 20px;\n}\n\n.theme-thumbnails div {\n    display: flex;\n    flex-direction: column; /* Stack title and image vertically */\n    align-items: center;\n    justify-content: center;\n    text-align: center;\n    position: relative; /* Needed for absolute positioning of the selected indicator */\n}\n\n.theme-thumbnails .theme-title {\n    font-size: 24px; /* Increased font size */\n    color: white; /* White font color */\n    margin-bottom: 10px; /* Space between title and image */\n}\n\n.theme-thumbnails img {\n    max-width: 100%;\n    height: auto;\n    object-fit: contain; /* Ensures the entire image is visible */\n}\n\n.selected-indicator {\n    position: absolute;\n    bottom: 0; /* Align with the bottom of the parent div */\n    right: 0; /* Align with the right of the parent div */\n    display: none; /* Hide by default */\n    width: 70px; /* Adjust the size as needed */\n    height: auto;\n    z-index: 2; /* Ensure it's above the image */\n}\n\n\n.selected-theme .selected-indicator {\n    display: block; /* Show the indicator for the selected theme */\n}\n\n\n</style>\n";

?>