<div class="d-block d-md-none cs-space-40"></div>  
<div class="row">
<?php
  if($esea_categories){
    foreach ($esea_categories as $cid => $category) {
      $subject = $category["esea_api"];
      $ss = $this->api->esea_get_params($subject);
      
      // DEBUG TEMPORAL: Mostrar estructura de datos para usuarios logueados
      if (is_user_logged_in() && !empty($ss)) {
          echo "<div style='background: #fff3cd; border: 2px solid #856404; padding: 15px; margin: 10px;'>";
          echo "<strong>🔍 DEBUG - Datos de esea_get_params() para: " . esc_html($subject) . "</strong><br>";
          echo "<details><summary style='cursor: pointer; font-weight: bold;'>Ver datos completos (click para expandir)</summary>";
          echo "<pre style='background: white; padding: 10px; overflow: auto; max-height: 400px;'>";
          echo esc_html(print_r($ss, true));
          echo "</pre></details>";
          
          if (isset($ss[0])) {
              echo "<br><strong>Primer elemento:</strong><br>";
              echo "- Keys disponibles: " . esc_html(implode(', ', array_keys($ss[0]))) . "<br>";
              
              // API v2 usa "idFormulario" en lugar de "idDetalle"
              if (isset($ss[0]["idFormulario"])) {
                  echo "- ✅ idFormulario: <strong>" . esc_html($ss[0]["idFormulario"]) . "</strong><br>";
              } else {
                  echo "- ❌ idFormulario NO existe<br>";
              }
              
              if (isset($ss[0]["nombreEsp"])) {
                  echo "- nombreEsp: <strong>" . esc_html($ss[0]["nombreEsp"]) . "</strong><br>";
              }
          }
          echo "</div>";
      }
      ?>
      <div class="col-12 col-md-6 col-box">
          <div class="subjects-wraper">
              <div class="row">
                  <div class="col-3 col-md-2 d-flex d-md-block justify-content-center">
                      <img class="logo" src='<?php echo $category["esea_crb_cat_photo"]; ?>'>
                  </div>
                  <div class="col-9 col-md-10">
                   <h3><?php echo $category["esea_title"] ?></h3>
                        <?php foreach ($category["esea_sub_crb_cat"] as $scid => $subcat) { 
                        ;?>
                      <ul>
                          <li>
                            <a href="<?php echo get_permalink($pageID); ?>?active=<?php echo $cid; ?>&son=<?php echo $subcat["esea_title"] ?>&subject=<?php echo $ss[0]["nombreEsp"]; ?>&chartid=<?php echo $ss[0]["idFormulario"]; ?>&epID=<?php echo $scid; ?>"><?php echo $subcat["esea_title"] ?></a>
                          </li>
                      </ul>
                      <?php } ?>
                  </div>
              </div>
          </div>
      </div>
    <?php }
    }?>
</div>
