<?php
function getCurrentUrl() {
    $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https://" : "http://";
    $host = $_SERVER['HTTP_HOST'];
    $uri = $_SERVER['REQUEST_URI'];
    return htmlspecialchars($protocol . $host . $uri, ENT_QUOTES, 'UTF-8');
}
?>

<?php
// Current URL
$urls = $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];
$url = urldecode($urls);

// Get path without extension (.php / .html)
$path = basename($_SERVER["REQUEST_URI"], '.php'); 
$path = basename($path, '.html');
$data = urldecode($path);

// Create variations from path
$keys = str_replace('-', ' ', $data);
$keyws = str_replace('-', '', $data);
$key = str_replace(['_', '-'], ' ', $data);
$key = ucwords($key); // Capitalize each word

// 🔥 Dynamic SEO Fallback Logic
$final_meta_title = !empty($meta_title) ? $meta_title : "$key Panel Chart Record | Live $key Matka Result";
$final_meta_desc = !empty($meta_description) ? $meta_description : "Get the latest Satta Matka $key Jodi and Panel results, updated $key charts, and expert tips. Fast and accurate $key market results.";
$final_seo_content = !empty($seo_content) ? $seo_content : "Here you will get the fastest and most accurate live record of the $key Panel Chart. On our website, daily updates, old records, and expert tips for $key Matka are updated first. Use both new and old Panel chart panels to make your game smarter, and keep visiting daily for regular live results.";

// Done — variables ready to echo
?> 
<?php include dirname(__DIR__, 3) . "/includes/minify.php"; ?>

<!DOCTYPE html>
<html lang="en-US" prefix="og: https://ogp.me/ns#">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <title><?php echo $final_meta_title; ?></title>
    <style>img:is([sizes="auto" i], [sizes^="auto," i]) { contain-intrinsic-size: 3000px 1500px }</style>
    <meta name="description" content="<?php echo $final_meta_desc; ?>"/>
    <meta name="robots" content="follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large"/>
    <link rel="canonical" href="<?php echo getCurrentUrl(); ?>" />
    
    <meta property="og:locale" content="en_US" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content="<?php echo $final_meta_title; ?>" />
    <meta property="og:description" content="<?php echo $final_meta_desc; ?>" />
    <meta property="og:url" content="<?php echo getCurrentUrl(); ?>" />
    <meta property="og:site_name" content="Satta Matka" /> 
    <meta name="twitter:card" content="summary_large_image" />
    <meta name="twitter:title" content="<?php echo $final_meta_title; ?>" />
    <meta name="twitter:description" content="<?php echo $final_meta_desc; ?>" />
    <meta name="twitter:label1" content="Written by" />
    <meta name="twitter:data1" content="admin" />

    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "WebPage",
      "name": "<?php echo $final_meta_title; ?>",
      "description": "<?php echo $final_meta_desc; ?>",
      "url": "<?php echo getCurrentUrl(); ?>"
    }
    </script>
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "BreadcrumbList",
      "itemListElement": [{
        "@type": "ListItem",
        "position": 1,
        "name": "Home",
        "item": "https://<?php echo $_SERVER['HTTP_HOST']; ?>"
      },{
        "@type": "ListItem",
        "position": 2,
        "name": "<?php echo $key; ?> Panel Chart",
        "item": "<?php echo getCurrentUrl(); ?>"
      }]
    }
    </script>

    <?php if(!empty($schema_data)) { echo $schema_data; } ?>

<?php  
 include dirname(__DIR__, 3) . "/content/themes/default/mod/_meta.php" ;
 include dirname(__DIR__, 3) . "/content/themes/default/mod/css.php" ;
 ?>
  
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;700;900&family=Montserrat:wght@600;800&display=swap');

:root {
  /* === 🎨 COLORS === */
  --bg-body: #f4f7f6;
  --bg-card: #ffffff;
  --c-primary: #1976d2;
  --c-secondary: #1976d2;
  --c-accent: #ffb300;
  --c-success: #0f9d58;
  --c-danger: #d32f2f;
  --text-main: #202124;
  --text-muted: #5f6368;

  /* === 🌈 GRADIENTS === */
  --bg-header: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  --bg-btn: linear-gradient(45deg, #ff512f, #dd2476);
  --txt-running: linear-gradient(90deg, #d81b60, #1976d2, #ffb300);

  /* === 🔠 FONT SIZES === */
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 18px;
  --fs-xl: 22px;
  --fs-title: 24px;

  /* === 🔲 BORDERS & RADIUS === */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-btn: 30px;
  --border-line: 1px solid #eeeeee;

  /* === ☁️ SHADOWS === */
  --shadow-card: 0 2px 8px rgba(0,0,0,0.06);
  --shadow-header: 0 4px 10px rgba(0,0,0,0.15);
}

/* === BASE STYLES === */
body {
  font-family: 'Roboto', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0; padding: 10px 8px 10px 8px; text-align: center;
}
a { color: var(--c-primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
ul, ol { padding-left: 20px; text-align: left; }
p { font-size: var(--fs-sm); line-height: 1.6; margin-bottom: 15px; }

/* === HEADER === */
.top-bar {
  position: fixed; top: 0; left: 0; width: 100%; z-index: 1000;
  background: var(--bg-header); padding: 12px 0; box-shadow: var(--shadow-header);
}
.top-bar h1 { margin: 0; font: 800 var(--fs-title) 'Montserrat', sans-serif; color: #fff; text-transform: uppercase; }
.top-bar h2 { color: var(--c-secondary); font-size: 14px; margin-top: 5px; font-weight: 400; }

/* === MAIN BOX / CARD === */
.card-box {
  background: var(--bg-card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); margin: 12px 0; padding: 15px;
  overflow: hidden;
  border: 1px solid var(--c-secondary);
}

/* === TYPOGRAPHY === */
.title-head {
  background: var(--bg-header); color: #fff; padding: 10px; border-radius: var(--radius-md);
  font: 800 var(--fs-lg) 'Montserrat', sans-serif; margin-top: 0; text-transform: uppercase;
}
.txt-lg { font-size: var(--fs-xl); font-weight: 900; margin: 5px 0; }
.txt-md { font-size: 16px; margin: 5px 0; font-weight: 700; color: var(--text-main); }
.txt-sm { color: var(--text-muted); font-size: var(--fs-sm); font-weight: 600; }
.color-primary { color: var(--c-primary); }

/* === BUTTONS === */
.btn-gradient {
  display: inline-block; background: var(--bg-btn); color: #fff !important; cursor: pointer; border: none;
  padding: 8px 20px; border-radius: var(--radius-btn); font-size: 14px; font-weight: bold;
  box-shadow: 0 4px 10px rgba(221, 36, 118, 0.3); margin: 10px 0; transition: transform 0.2s;
}
.btn-gradient:active { transform: scale(0.95); }

.btn-action {
  background: #fff; border: 2px solid #eee; padding: 10px 20px; color: var(--text-main);
  border-radius: var(--radius-btn); font-size: 15px; font-weight: bold; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.btn-action.full-width { width: 100%; margin: 10px 0; }

/* === LUCKY NUMBER BOX === */
.lucky-box { background: #fff; border-radius: var(--radius-lg); box-shadow: 0 4px 15px rgba(55, 27, 216, 0.2); margin: 15px 0; border: 0px solid var(--c-secondary); overflow: hidden; }
.lucky-box h4 { margin: 0 0 10px 0; color: var(--c-primary); font-size: var(--fs-lg); text-transform: uppercase; }
.lucky-box p { font-size: var(--fs-title); font-weight: 900; margin: 0; color: var(--text-main); }


/* === PANEL SPECIFIC TABLE STYLES (Retained & Optimized) === */
table { width: 100%; border-collapse: collapse; margin-top: 10px; background: #fff; }
table, th, td { border: 1px solid rgba(3, 169, 244, 0.3); }
thead, .tr { background: var(--bg-header); color: #fff; text-shadow: none; }
thead th { padding: 10px; font-size: 13px; font-weight: bold; }
tbody td { background-color: #fff; padding: 5px 0; font-size: 13px; color: var(--text-main); font-weight: 700; text-align: center; }

thead tr th:first-child { width: 100px; }
tbody td:nth-child(3n+2) { border-right-width: 0; font-size: 13px; }
tbody td:nth-child(3n+3) { border-left-width: 0; border-right-width: 0; font-size: 20px; } /* Final Jodi Size */
tbody td:nth-child(3n+4) { border-left-width: 0; font-size: 13px; }

@media only screen and (max-width: 770px) {
    tbody td { font-size: 11px; }
    tbody td:nth-child(3n+3) { font-size: 16px; }
}
</style>
</head>
<body>

   <div class="card-box" style="padding: 0;">
       <h1 class="title-head" style="margin: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0;">
        <a href="" style="color: #fff; text-decoration: none;"><?php echo $key; ?> Matka Panel Chart Record - Satta Matka</a>
       </h1>
   </div>
  
<div class="card-box txt-sm">
  Here you will get the fastest and most accurate live record of the <?php echo $key; ?> Panel Chart. On our website, daily updates, old records, and expert tips for <?php echo $key; ?> Matka are updated first. Use both new and old Panel chart panels to make your game smarter, and keep visiting daily for regular live results.
</div>




<div class="card-box lucky-box">
  <h4 class="color-primary"><?php echo $name; ?></h4>
  <p class="txt-lg"><span class="loading-emoji">🔄</span> 
  <span style='color:<?php echo $color; ?>;'><?php echo $final_result; ?></span></p>
  <button class="btn-gradient" onclick="window.location.reload()"><span class="loading-emoji">🔄</span> Refresh</button>
</div>

<button id="scrollToBottomBtn" class="btn-gradient">Scroll to Bottom</button>
<script>
    const scrollToBottomBtn = document.getElementById('scrollToBottomBtn');
    scrollToBottomBtn.addEventListener('click', () => {
        window.scrollTo({
            top: document.body.scrollHeight,
            behavior: 'smooth'
        });
    });
</script>

<?php if (!empty($top_content)): ?>
<div class="card-box txt-md" style="margin-bottom: 15px; text-align: left;">
    <?= $top_content ?>
</div>
<?php endif; ?>